From: Ben Gras Date: Mon, 14 Nov 2005 15:51:28 +0000 (+0000) Subject: last.c displays load average for uptime(1) X-Git-Tag: v3.1.2a~499 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/ddns-confgen.html?a=commitdiff_plain;h=1266ebcc937aefc88503995b97179b0c21dea1c4;p=minix.git last.c displays load average for uptime(1) --- diff --git a/commands/simple/last.c b/commands/simple/last.c index 2343fb9d3..74124b052 100755 --- a/commands/simple/last.c +++ b/commands/simple/last.c @@ -308,6 +308,9 @@ long to; */ void Print_Uptime() { +#define NLOADS 3 + int nloads; + double loads[NLOADS]; char *utmp_file = _PATH_UTMP; unsigned nusers; struct utmp ut; @@ -345,7 +348,14 @@ void Print_Uptime() printf(" %lu day%s,", days, days == 1 ? "" : "s"); } printf(" %lu:%02lu,", (up % (24 * 3600L)) / 3600, (up % 3600) / 60); - printf(" %u user%s\n", nusers, nusers == 1 ? "" : "s"); + printf(" %u user%s", nusers, nusers == 1 ? "" : "s"); + if((nloads = getloadavg(loads, NLOADS)) > 0) { + int i; + printf(", load averages:"); + for(i = 0; i < nloads; i++) + printf("%s %.2f", (i > 0) ? "," : "", loads[i]); + } + printf("\n"); }