From: Martin Mares Date: Fri, 20 Aug 2010 15:13:13 +0000 (+0200) Subject: Include host name in the 1st line of output X-Git-Tag: v1.12~8 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=a1c072e0abf6c29ca885c90be40d15aefb585842;p=ywho.git Include host name in the 1st line of output --- diff --git a/ywho.c b/ywho.c index ecfc3ca..078b9a9 100644 --- a/ywho.c +++ b/ywho.c @@ -209,6 +209,7 @@ dispsys(void) char line[256]; char *z, *w; w = NULL; + if (f = fopen("/proc/version", "r")) { fgets(line, 256, f); @@ -227,6 +228,10 @@ dispsys(void) printf(line); fclose(f); } + + if (gethostname(line, sizeof(line)) >= 0) + printf(" (%s)", line); + if (f = fopen("/proc/cpuinfo", "r")) { char a[32], b[32], c[32]; @@ -286,6 +291,7 @@ dispsys(void) printf("/%s", c); fclose(f); } + if (f = fopen("/proc/uptime", "r")) { int p,q,p1,q1; @@ -297,6 +303,7 @@ dispsys(void) puttime(p-q); fclose(f); } + { struct tm *tm; char *days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; @@ -306,6 +313,7 @@ dispsys(void) tm->tm_year%100, tm->tm_hour, tm->tm_min, tm->tm_sec); printf(" (%u UE)\n", (unsigned int) now); } + if (f = fopen("/proc/loadavg", "r")) { int i = 3; @@ -331,6 +339,7 @@ dispsys(void) printf("LAV=%s", line); fclose(f); } + if (f = fopen("/proc/meminfo", "r")) { int free, buffers, cached, stotal, sfree;