38 |
|
DOUBLE, |
39 |
|
STRING, |
40 |
|
INT, |
41 |
+ |
BOOL, |
42 |
|
DUPLEX |
43 |
|
} stat_type; |
44 |
|
|
363 |
|
"net", name, "tx", NULL); |
364 |
|
add_stat(LONG_LONG, &net[i].rx, |
365 |
|
"net", name, "rx", NULL); |
366 |
+ |
add_stat(LONG_LONG, &net[i].ipackets, |
367 |
+ |
"net", name, "ipackets", NULL); |
368 |
+ |
add_stat(LONG_LONG, &net[i].opackets, |
369 |
+ |
"net", name, "opackets", NULL); |
370 |
+ |
add_stat(LONG_LONG, &net[i].ierrors, |
371 |
+ |
"net", name, "ierrors", NULL); |
372 |
+ |
add_stat(LONG_LONG, &net[i].oerrors, |
373 |
+ |
"net", name, "oerrors", NULL); |
374 |
+ |
add_stat(LONG_LONG, &net[i].collisions, |
375 |
+ |
"net", name, "collisions", NULL); |
376 |
|
add_stat(TIME_T, &net[i].systime, |
377 |
|
"net", name, "systime", NULL); |
378 |
|
} |
385 |
|
|
386 |
|
add_stat(INT, &iface[i].speed, |
387 |
|
"net", name, "speed", NULL); |
388 |
+ |
add_stat(BOOL, &iface[i].up, |
389 |
+ |
"net", name, "up", NULL); |
390 |
|
add_stat(DUPLEX, &iface[i].dup, |
391 |
|
"net", name, "duplex", NULL); |
392 |
|
} |
459 |
|
t->populate(); |
460 |
|
} |
461 |
|
|
462 |
< |
qsort(stats, num_stats, sizeof *stats, stats_compare); |
462 |
> |
if (stats != NULL) |
463 |
> |
qsort(stats, num_stats, sizeof *stats, stats_compare); |
464 |
|
} |
465 |
|
|
466 |
|
/* Print the value of a stat. */ |
467 |
|
void print_stat_value(const stat *s) { |
468 |
|
void *v = s->stat; |
469 |
+ |
long l; |
470 |
|
|
471 |
|
switch (s->type) { |
472 |
|
case LONG_LONG: |
474 |
|
break; |
475 |
|
case TIME_T: |
476 |
|
/* FIXME option for formatted time? */ |
477 |
< |
printf("%ld", *(time_t *)v); |
477 |
> |
l = *(time_t *)v; |
478 |
> |
printf("%ld", l); |
479 |
|
break; |
480 |
|
case FLOAT: |
481 |
|
printf("%f", *(float *)v); |
490 |
|
case INT: |
491 |
|
printf("%d", *(int *)v); |
492 |
|
break; |
493 |
+ |
case BOOL: |
494 |
+ |
printf("%s", *(int *)v ? "true" : "false"); |
495 |
+ |
break; |
496 |
|
case DUPLEX: |
497 |
< |
switch (*(duplex *) v) { |
497 |
> |
switch (*(statgrab_duplex *) v) { |
498 |
|
case FULL_DUPLEX: |
499 |
|
printf("full"); |
500 |
|
break; |
548 |
|
else |
549 |
|
compare = stats_compare; |
550 |
|
|
551 |
< |
s = (const stat *)bsearch(&key, stats, num_stats, |
552 |
< |
sizeof *stats, compare); |
551 |
> |
if (stats == NULL) { |
552 |
> |
s = NULL; |
553 |
> |
} else { |
554 |
> |
s = (const stat *)bsearch(&key, stats, |
555 |
> |
num_stats, |
556 |
> |
sizeof *stats, |
557 |
> |
compare); |
558 |
> |
} |
559 |
> |
|
560 |
|
if (s == NULL) { |
561 |
|
printf("Unknown stat %s\n", name); |
562 |
|
continue; |