}
static void
-dispsys(void)
+line1(void)
{
FILE *f;
char line[256];
- char *z, *w;
- w = NULL;
+ char *z;
+ int num_cpus = 0;
if (f = fopen("/proc/version", "r"))
{
if (f = fopen("/proc/cpuinfo", "r"))
{
- char a[32], b[32], c[32];
- strcpy(a, "???");
- b[0] = 0;
- c[0] = 0;
- for(;;)
+ while (fgets(line, 256, f))
{
- fgets(line, 256, f);
- if (feof(f))
- break;
- if (!strncmp(line, "cpu\t\t: ", 7))
- {
- z = line+7;
- w = a;
- }
- else if (!strncmp(line, "cpu family\t: ",13))
- {
- z = line+13; strcpy(z + 1, "86\n");
- w = a;
- }
- else if (!strncmp(line, "model\t\t: ", 9))
- {
- z = line+9;
- w = b;
- }
- else if (!strncmp(line, "model name\t: ", 13))
- {
- z = line+13;
- if (!strncmp(z, "AMD-K6", 6))
- {
- z[3] = ' ';
- if ((w = strstr(z, "tm w/ multimedia")))
- strcpy(w, "-1\n");
- else if ((w = strstr(z, "(tm) 3D")))
- strcpy(w, "-2\n");
- }
- 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;
- }
+ if (!strncmp(line, "processor\t", 9))
+ num_cpus++;
}
- printf(" on %s", *b ? b : a);
- if (*c)
- printf("/%s", c);
+ printf(" [%d CPU%s]", num_cpus, (num_cpus != 1 ? "s" : ""));
fclose(f);
}
sscanf(line, "%d.%d%d.%d", &p, &p1, &q, &q1);
printf(" up ");
puttime(p);
- printf(" run ");
- puttime(p-q);
+ printf(" idle ");
+ puttime(q);
fclose(f);
}
tm->tm_year%100, tm->tm_hour, tm->tm_min, tm->tm_sec);
printf(" (%u UE)\n", (unsigned int) now);
}
+}
+
+static void
+line2(void)
+{
+ FILE *f;
+ char line[256];
+ char *z;
if (f = fopen("/proc/loadavg", "r"))
{
int main(void)
{
readutmp();
- dispsys();
+ line1();
+ line2();
readproc();
solve();
sort();