1 |
|
/* |
2 |
|
* i-scream central monitoring system |
3 |
|
* http://www.i-scream.org |
4 |
< |
* Copyright (C) 2000-2003 i-scream |
4 |
> |
* Copyright (C) 2000-2004 i-scream |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or |
7 |
|
* modify it under the terms of the GNU General Public License |
16 |
|
* You should have received a copy of the GNU General Public License |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
+ |
* |
20 |
+ |
* $Id$ |
21 |
|
*/ |
22 |
|
|
23 |
|
#ifdef HAVE_CONFIG_H |
37 |
|
FLOAT, |
38 |
|
DOUBLE, |
39 |
|
STRING, |
40 |
< |
INT |
40 |
> |
INT, |
41 |
> |
BOOL, |
42 |
> |
DUPLEX |
43 |
|
} stat_type; |
44 |
|
|
45 |
|
typedef enum { |
350 |
|
void populate_net() { |
351 |
|
int n, i; |
352 |
|
network_stat_t *net; |
353 |
+ |
network_iface_stat_t *iface; |
354 |
|
|
355 |
|
net = use_diffs ? get_network_stats_diff(&n) : get_network_stats(&n); |
356 |
|
if (net != NULL) { |
367 |
|
"net", name, "systime", NULL); |
368 |
|
} |
369 |
|
} |
370 |
+ |
|
371 |
+ |
iface = get_network_iface_stats(&n); |
372 |
+ |
if (iface != NULL) { |
373 |
+ |
for (i = 0; i < n; i++) { |
374 |
+ |
const char *name = iface[i].interface_name; |
375 |
+ |
|
376 |
+ |
add_stat(INT, &iface[i].speed, |
377 |
+ |
"net", name, "speed", NULL); |
378 |
+ |
add_stat(BOOL, &iface[i].up, |
379 |
+ |
"net", name, "up", NULL); |
380 |
+ |
add_stat(DUPLEX, &iface[i].dup, |
381 |
+ |
"net", name, "duplex", NULL); |
382 |
+ |
} |
383 |
+ |
} |
384 |
|
} |
385 |
|
|
386 |
|
void populate_page() { |
477 |
|
case INT: |
478 |
|
printf("%d", *(int *)v); |
479 |
|
break; |
480 |
+ |
case BOOL: |
481 |
+ |
printf("%s", *(int *)v ? "true" : "false"); |
482 |
+ |
break; |
483 |
+ |
case DUPLEX: |
484 |
+ |
switch (*(statgrab_duplex *) v) { |
485 |
+ |
case FULL_DUPLEX: |
486 |
+ |
printf("full"); |
487 |
+ |
break; |
488 |
+ |
case HALF_DUPLEX: |
489 |
+ |
printf("half"); |
490 |
+ |
break; |
491 |
+ |
default: |
492 |
+ |
printf("unknown"); |
493 |
+ |
break; |
494 |
+ |
} |
495 |
+ |
break; |
496 |
|
} |
497 |
|
} |
498 |
|
|
643 |
|
/* We don't care if statgrab_init fails, because we can just display |
644 |
|
the statistics that can be read as non-root. */ |
645 |
|
statgrab_init(); |
646 |
< |
#ifdef ALLBSD |
647 |
< |
if (setegid(getgid()) != 0) |
613 |
< |
die("Failed to lose effective group"); |
614 |
< |
#endif |
646 |
> |
if (statgrab_drop_privileges() != 0) |
647 |
> |
die("Failed to drop setuid/setgid privileges"); |
648 |
|
|
649 |
|
switch (repeat_mode) { |
650 |
|
case REPEAT_NONE: |