update to new fs
[unix-history] / usr / src / usr.bin / ruptime / ruptime.c
index e11713d..3945c5f 100644 (file)
@@ -1,10 +1,10 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)ruptime.c  4.1 82/04/02";
+static char sccsid[] = "@(#)ruptime.c  4.4 82/05/09";
 #endif
 
 #endif
 
-#include <sys/types.h>         /* botch in ndir.h */
+#include <sys/param.h>
 #include <stdio.h>
 #include <stdio.h>
-#include <ndir.h>
+#include <dir.h>
 #include <utmp.h>
 #include "rwhod.h"
 
 #include <utmp.h>
 #include "rwhod.h"
 
@@ -36,6 +36,7 @@ main(argc, argv)
        register struct hs *hsp = hs;
        register struct whod *wd;
        register struct whoent *we;
        register struct hs *hsp = hs;
        register struct whod *wd;
        register struct whoent *we;
+       int maxloadav = 0;
 
        time(&t);
        argc--, argv++;
 
        time(&t);
        argc--, argv++;
@@ -71,6 +72,9 @@ again:
                                wd = (struct whod *)buf;
                                bcopy(buf, hsp->hs_wd, WHDRSIZE);
                                hsp->hs_nusers = 0;
                                wd = (struct whod *)buf;
                                bcopy(buf, hsp->hs_wd, WHDRSIZE);
                                hsp->hs_nusers = 0;
+                               for (i = 0; i < 2; i++)
+                                       if (wd->wd_loadav[i] > maxloadav)
+                                               maxloadav = wd->wd_loadav[i];
                                we = (struct whoent *)(buf+cc);
                                while (--we >= wd->wd_we)
                                        if (aflg || we->we_idle < 3600)
                                we = (struct whoent *)(buf+cc);
                                while (--we >= wd->wd_we)
                                        if (aflg || we->we_idle < 3600)
@@ -93,15 +97,18 @@ again:
                            interval(now - hsp->hs_wd->wd_recvtime, "down"));
                        continue;
                }
                            interval(now - hsp->hs_wd->wd_recvtime, "down"));
                        continue;
                }
-               printf("%-8.8s%s,  %4d user%s  load %4.2f, %4.2f, %4.2f\n",
+               printf("%-8.8s%s,  %4d user%s  load %*.2f, %*.2f, %*.2f\n",
                    hsp->hs_wd->wd_hostname,
                    interval(hsp->hs_wd->wd_sendtime -
                        hsp->hs_wd->wd_bootime, "  up"),
                    hsp->hs_nusers,
                    hsp->hs_nusers == 1 ? ", " : "s,",
                    hsp->hs_wd->wd_hostname,
                    interval(hsp->hs_wd->wd_sendtime -
                        hsp->hs_wd->wd_bootime, "  up"),
                    hsp->hs_nusers,
                    hsp->hs_nusers == 1 ? ", " : "s,",
-                   hsp->hs_wd->wd_loadav[0] / 100.0,
-                   hsp->hs_wd->wd_loadav[1] / 100.0,
-                   hsp->hs_wd->wd_loadav[2] / 100.0);
+                   maxloadav >= 1000 ? 5 : 4,
+                       hsp->hs_wd->wd_loadav[0] / 100.0,
+                   maxloadav >= 1000 ? 5 : 4,
+                       hsp->hs_wd->wd_loadav[1] / 100.0,
+                   maxloadav >= 1000 ? 5 : 4,
+                       hsp->hs_wd->wd_loadav[2] / 100.0);
                cfree(hsp->hs_wd);
        }
        exit(0);
                cfree(hsp->hs_wd);
        }
        exit(0);