--- projects/libstatgrab/src/statgrab/statgrab.c 2004/01/16 15:54:56 1.16 +++ projects/libstatgrab/src/statgrab/statgrab.c 2004/02/14 00:06:00 1.20 @@ -16,6 +16,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id: statgrab.c,v 1.20 2004/02/14 00:06:00 ats Exp $ */ #ifdef HAVE_CONFIG_H @@ -35,7 +37,9 @@ typedef enum { FLOAT, DOUBLE, STRING, - INT + INT, + BOOL, + DUPLEX } stat_type; typedef enum { @@ -346,6 +350,7 @@ void populate_proc() { void populate_net() { int n, i; network_stat_t *net; + network_iface_stat_t *iface; net = use_diffs ? get_network_stats_diff(&n) : get_network_stats(&n); if (net != NULL) { @@ -362,6 +367,20 @@ void populate_net() { "net", name, "systime", NULL); } } + + iface = get_network_iface_stats(&n); + if (iface != NULL) { + for (i = 0; i < n; i++) { + const char *name = iface[i].interface_name; + + add_stat(INT, &iface[i].speed, + "net", name, "speed", NULL); + add_stat(BOOL, &iface[i].up, + "net", name, "up", NULL); + add_stat(DUPLEX, &iface[i].dup, + "net", name, "duplex", NULL); + } + } } void populate_page() { @@ -457,6 +476,22 @@ void print_stat_value(const stat *s) { break; case INT: printf("%d", *(int *)v); + break; + case BOOL: + printf("%s", *(int *)v ? "true" : "false"); + break; + case DUPLEX: + switch (*(statgrab_duplex *) v) { + case FULL_DUPLEX: + printf("full"); + break; + case HALF_DUPLEX: + printf("half"); + break; + default: + printf("unknown"); + break; + } break; } }