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;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to