- if (f = fopen("/proc/loadavg", "r"))
- {
- int i = 3;
- fgets(line, 256, f);
- *strchr(line, '\n') = 0;
- z = line-1;
- while (i-- && z)
- {
- *z = '/';
- z = strchr(z, ' ');
- }
- if (z)
- {
- char *k;
- *z++ = 0;
- k = strchr(z, ' ');
- if (k)
- *k = 0;
- printf("R/T=%s, ", z);
- }
- else
- z = line;
- printf("LAV=%s", line);
- fclose(f);
- }
- if (f = fopen("/proc/meminfo", "r"))
- {
- int total, used, free, shared, buffers, totals, useds, frees;
- fgets(line, 256, f);
- fgets(line, 256, f);
- sscanf(line, "Mem:%d%d%d%d%d", &total, &used, &free, &shared, &buffers);
- fgets(line, 256, f);
- sscanf(line, "Swap:%d%d%d", &totals, &useds, &frees);
- printf(", free ");
- memory(free+buffers);
- printf(" of RAM");
- if (useds)
- {
- printf(", used ");
- memory(useds);
- printf(" of swap");
- }
- }
- printf(", %d user%s.\n", usercnt, usercnt == 1 ? "" : "s");
+ else
+ z = line + strlen(line) - 1;
+ *z = 0;
+ z = strstr(line, " version");
+ if (z)
+ memmove(z, z+8, strlen(z+8)+1);
+ printf(line);
+ fclose(f);
+ }
+ if (f = fopen("/proc/cpuinfo", "r"))
+ {
+ strcpy(a, "???");
+ b[0] = 0;
+ c[0] = 0;
+ for(;;)
+ {
+ fgets(line, 256, f);
+ if (feof(f))
+ break;
+ if (!strncmp(line, "cpu\t\t: ", 7))
+ {
+ z = line+7;
+ w = a;
+ }
+ else if (!strncmp(line, "model\t\t: ", 9))
+ {
+ z = line+9;
+ w = b;
+ }
+ else if (!strncmp(line, "mask\t\t: ", 8))
+ {
+ z = line+8;
+ w = c;
+ }
+ else
+ z = NULL;
+ if (z)
+ {
+ line[strlen(line)-1] = 0;
+ strcpy(w, z);
+ if (!strcmp(w, "Unknown"))
+ w[0] = 0;
+ }
+ }
+ printf(" on %s", a);
+ if (*b)
+ printf("-%s", b);
+ if (*c)
+ printf("-%s", c);
+ fclose(f);
+ }
+ if (f = fopen("/proc/uptime", "r"))
+ {
+ int p,q,p1,q1;
+ fgets(line, 256, f);
+ sscanf(line, "%d.%d%d.%d", &p, &p1, &q, &q1);
+ printf(", up ");
+ puttime(p);
+ printf(", run ");
+ puttime(p-q);
+ fclose(f);
+ }
+ {
+ struct tm *tm;
+ now = time(NULL);
+ tm = localtime(&now);
+ printf(" at %02d-%02d-%02d/%d %02d.%02d:%02d\n", tm->tm_mday, tm->tm_mon+1,
+ tm->tm_year, (tm->tm_wday+6)%7, tm->tm_hour, tm->tm_min, tm->tm_sec);
+ }
+ if (f = fopen("/proc/loadavg", "r"))
+ {
+ int i = 3;
+ fgets(line, 256, f);
+ *strchr(line, '\n') = 0;
+ z = line-1;
+ while (i-- && z)
+ {
+ *z = '/';
+ z = strchr(z, ' ');
+ }
+ if (z)
+ {
+ char *k;
+ *z++ = 0;
+ k = strchr(z, ' ');
+ if (k)
+ *k = 0;
+ printf("R/T=%s, ", z);
+ }
+ else
+ z = line;
+ printf("LAV=%s", line);
+ fclose(f);
+ }
+ if (f = fopen("/proc/meminfo", "r"))
+ {
+ int free, buffers, stotal, sfree;
+ free = buffers = stotal = sfree = 0;
+ while (fgets(line, 256, f))
+ {
+ if (!strncmp(line, "MemFree:", 8))
+ sscanf(line+8, "%d", &free);
+ else if (!strncmp(line, "Buffers:", 8))
+ sscanf(line+8, "%d", &buffers);
+ else if (!strncmp(line, "SwapTotal:", 10))
+ sscanf(line+10, "%d", &stotal);
+ else if (!strncmp(line, "SwapFree:", 9))
+ sscanf(line+9, "%d", &sfree);
+ }
+ printf(", free ");
+ memory(1024*(free+buffers));
+ printf(" of RAM");
+ if (stotal != sfree)
+ {
+ printf(", used ");
+ memory(1024*(stotal - sfree));
+ printf(" of swap");
+ }
+ }
+ printf(", %d user%s.\n", usercnt, usercnt == 1 ? "" : "s");