| 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 | > | DUPLEX | 
 
 
 
 
 
 
 
 
 
 
 | 42 |  | } stat_type; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 43 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 44 |  | typedef enum { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 282 |  | die("out of memory"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 283 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 284 |  | name = buf; | 
 
 
 
 
 
 
 
 | 285 | + | if (strlen(name) == 2 && name[1] == ':') | 
 
 
 
 
 
 
 
 | 286 | + | name[1] = '\0'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 287 |  | if (strncmp(name, "/dev/", 5) == 0) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 288 |  | name += 5; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 289 |  | while ((p = strchr(name, '/')) != NULL) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 349 |  | void populate_net() { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 350 |  | int n, i; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 351 |  | network_stat_t *net; | 
 
 
 
 
 
 
 
 | 352 | + | network_iface_stat_t *iface; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 353 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 354 |  | net = use_diffs ? get_network_stats_diff(&n) : get_network_stats(&n); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 355 |  | if (net != NULL) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 366 |  | "net", name, "systime", NULL); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 367 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 368 |  | } | 
 
 
 
 
 
 
 
 | 369 | + |  | 
 
 
 
 
 
 
 
 | 370 | + | iface = get_network_iface_stats(&n); | 
 
 
 
 
 
 
 
 | 371 | + | if (iface != NULL) { | 
 
 
 
 
 
 
 
 | 372 | + | for (i = 0; i < n; i++) { | 
 
 
 
 
 
 
 
 | 373 | + | const char *name = iface[i].interface_name; | 
 
 
 
 
 
 
 
 | 374 | + |  | 
 
 
 
 
 
 
 
 | 375 | + | add_stat(INT, &iface[i].speed, | 
 
 
 
 
 
 
 
 | 376 | + | "net", name, "speed", NULL); | 
 
 
 
 
 
 
 
 | 377 | + | add_stat(DUPLEX, &iface[i].dup, | 
 
 
 
 
 
 
 
 | 378 | + | "net", name, "duplex", NULL); | 
 
 
 
 
 
 
 
 | 379 | + | } | 
 
 
 
 
 
 
 
 | 380 | + | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 381 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 382 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 383 |  | void populate_page() { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 387 |  | if (page != NULL) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 388 |  | add_stat(LONG_LONG, &page->pages_pagein, "page", "in", NULL); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 389 |  | add_stat(LONG_LONG, &page->pages_pageout, "page", "out", NULL); | 
 
 
 
 
 
 
 
 
 
 
 | 390 | < | add_stat(LONG_LONG, &page->systime, "page", "systime", NULL); | 
 
 
 
 
 
 
 
 
 | 390 | > | add_stat(TIME_T, &page->systime, "page", "systime", NULL); | 
 
 
 
 
 
 
 
 
 
 
 | 391 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 392 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 393 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 474 |  | case INT: | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 475 |  | printf("%d", *(int *)v); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 476 |  | break; | 
 
 
 
 
 
 
 
 | 477 | + | case DUPLEX: | 
 
 
 
 
 
 
 
 | 478 | + | switch (*(duplex *) v) { | 
 
 
 
 
 
 
 
 | 479 | + | case FULL_DUPLEX: | 
 
 
 
 
 
 
 
 | 480 | + | printf("full"); | 
 
 
 
 
 
 
 
 | 481 | + | break; | 
 
 
 
 
 
 
 
 | 482 | + | case HALF_DUPLEX: | 
 
 
 
 
 
 
 
 | 483 | + | printf("half"); | 
 
 
 
 
 
 
 
 | 484 | + | break; | 
 
 
 
 
 
 
 
 | 485 | + | default: | 
 
 
 
 
 
 
 
 | 486 | + | printf("unknown"); | 
 
 
 
 
 
 
 
 | 487 | + | break; | 
 
 
 
 
 
 
 
 | 488 | + | } | 
 
 
 
 
 
 
 
 | 489 | + | break; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 490 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 491 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 492 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 633 |  | use_diffs = 1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 634 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 635 |  | select_interesting(argc - optind, &argv[optind]); | 
 
 
 
 
 
 
 
 | 636 | + |  | 
 
 
 
 
 
 
 
 | 637 | + | /* We don't care if statgrab_init fails, because we can just display | 
 
 
 
 
 
 
 
 | 638 | + | the statistics that can be read as non-root. */ | 
 
 
 
 
 
 
 
 | 639 | + | statgrab_init(); | 
 
 
 
 
 
 
 
 | 640 | + | if (statgrab_drop_privileges() != 0) | 
 
 
 
 
 
 
 
 | 641 | + | die("Failed to drop setuid/setgid privileges"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 642 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 643 |  | switch (repeat_mode) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 644 |  | case REPEAT_NONE: |