Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Apr 2020 07:46:39 +0000 (UTC)
From:      Takahashi Yoshihiro <nyan@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r359799 - stable/11/usr.bin/ruptime
Message-ID:  <202004110746.03B7kdq7074540@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nyan
Date: Sat Apr 11 07:46:38 2020
New Revision: 359799
URL: https://svnweb.freebsd.org/changeset/base/359799

Log:
  MFC: r342965
  
  > Fix indentation in ruptime command output for hosts in the "down" state.
  
  MFC: r359631
  
  > Remove extra spaces for the load average of machines that are down.
  
  PR:		234239, 245296

Modified:
  stable/11/usr.bin/ruptime/ruptime.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/ruptime/ruptime.c
==============================================================================
--- stable/11/usr.bin/ruptime/ruptime.c	Sat Apr 11 07:37:10 2020	(r359798)
+++ stable/11/usr.bin/ruptime/ruptime.c	Sat Apr 11 07:46:38 2020	(r359799)
@@ -232,18 +232,21 @@ ruptime(const char *host, int aflg, int (*cmp)(const v
 
 		if (hostnamewidth < (int)strlen(wd->wd_hostname))
 			hostnamewidth = (int)strlen(wd->wd_hostname);
-		for (i = 0; i < 3; i++) {
-			w = iwidth(wd->wd_loadav[i] / 100) + 3;
-			if (loadavwidth[i] < w)
-				loadavwidth[i] = w;
+
+		if (!ISDOWN(hsp)) {
+			for (i = 0; i < 3; i++) {
+				w = iwidth(wd->wd_loadav[i] / 100) + 3;
+				if (loadavwidth[i] < w)
+					loadavwidth[i] = w;
+			}
+			for (hsp->hs_nusers = 0, we = &wd->wd_we[0];
+			     (char *)(we + 1) <= (char *)wd + cc; we++)
+				if (aflg || we->we_idle < 3600)
+					++hsp->hs_nusers;
+			if (userswidth < iwidth(hsp->hs_nusers))
+				userswidth = iwidth(hsp->hs_nusers);
 		}
 
-		for (hsp->hs_nusers = 0, we = &wd->wd_we[0];
-		    (char *)(we + 1) <= (char *)wd + cc; we++)
-			if (aflg || we->we_idle < 3600)
-				++hsp->hs_nusers;
-		if (userswidth < iwidth(hsp->hs_nusers))
-			userswidth = iwidth(hsp->hs_nusers);
 		++hsp;
 		++nhosts;
 	}
@@ -262,7 +265,7 @@ ruptime(const char *host, int aflg, int (*cmp)(const v
 		hsp = &hs[i];
 		wd = &hsp->hs_wd;
 		if (ISDOWN(hsp)) {
-			(void)printf("%-*.*s%s\n",
+			(void)printf("%-*.*s  %s\n",
 			    hostnamewidth, hostnamewidth, wd->wd_hostname,
 			    interval(now - hsp->hs_wd.wd_recvtime, "down"));
 			continue;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004110746.03B7kdq7074540>