ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/statgrab/statgrab.c
(Generate patch)

Comparing projects/libstatgrab/src/statgrab/statgrab.c (file contents):
Revision 1.13 by ats, Mon Nov 10 23:35:43 2003 UTC vs.
Revision 1.18 by ats, Fri Feb 13 12:52:40 2004 UTC

# Line 1 | Line 1
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
# Line 16 | Line 16
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
# Line 35 | Line 37 | typedef enum {
37          FLOAT,
38          DOUBLE,
39          STRING,
40 <        INT
40 >        INT,
41 >        DUPLEX
42   } stat_type;
43  
44   typedef enum {
# Line 346 | Line 349 | void populate_proc() {
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) {
# Line 362 | Line 366 | void populate_net() {
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() {
# Line 458 | Line 474 | void print_stat_value(const stat *s) {
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  
# Line 608 | Line 637 | int main(int argc, char **argv) {
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 < #ifdef ALLBSD
641 <        if (setegid(getgid()) != 0)
613 <                die("Failed to lose effective group");
614 < #endif
640 >        if (statgrab_drop_privileges() != 0)
641 >                die("Failed to drop setuid/setgid privileges");
642  
643          switch (repeat_mode) {
644          case REPEAT_NONE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines