--- projects/libstatgrab/src/statgrab/statgrab.c 2005/04/25 12:04:30 1.33 +++ projects/libstatgrab/src/statgrab/statgrab.c 2006/03/17 13:23:05 1.37 @@ -17,7 +17,7 @@ * 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.33 2005/04/25 12:04:30 tdb Exp $ + * $Id: statgrab.c,v 1.37 2006/03/17 13:23:05 ats Exp $ */ #ifdef HAVE_CONFIG_H @@ -121,18 +121,19 @@ void add_stat(stat_type type, void *stat, ...) { break; partlen = strlen(part); memcpy(p, part, partlen); - p += partlen; + + /* Replace spaces and dots with underscores. */ + while (partlen-- > 0) { + if (*p == ' ' || *p == '.') + *p = '_'; + p++; + } + *p++ = '.'; } va_end(ap); *--p = '\0'; - /* Replace spaces with underscores. */ - for (p = name; *p != '\0'; p++) { - if (*p == ' ') - *p = '_'; - } - /* Stretch the stats array if necessary. */ if (num_stats >= alloc_stats) { alloc_stats += INCREMENT_STATS; @@ -313,6 +314,20 @@ void populate_fs() { "fs", name, "used_inodes", NULL); add_stat(LONG_LONG, &disk[i].free_inodes, "fs", name, "free_inodes", NULL); + add_stat(LONG_LONG, &disk[i].avail_inodes, + "fs", name, "avail_inodes", NULL); + add_stat(LONG_LONG, &disk[i].io_size, + "fs", name, "io_size", NULL); + add_stat(LONG_LONG, &disk[i].block_size, + "fs", name, "block_size", NULL); + add_stat(LONG_LONG, &disk[i].total_blocks, + "fs", name, "total_blocks", NULL); + add_stat(LONG_LONG, &disk[i].free_blocks, + "fs", name, "free_blocks", NULL); + add_stat(LONG_LONG, &disk[i].avail_blocks, + "fs", name, "avail_blocks", NULL); + add_stat(LONG_LONG, &disk[i].used_blocks, + "fs", name, "used_blocks", NULL); free(buf); } @@ -412,7 +427,7 @@ void populate_net() { "net", name, "speed", NULL); add_stat(BOOL, &iface[i].up, "net", name, "up", NULL); - add_stat(DUPLEX, &iface[i].dup, + add_stat(DUPLEX, &iface[i].duplex, "net", name, "duplex", NULL); } } @@ -497,14 +512,22 @@ void print_stat_value(const stat *s) { switch (s->type) { case LONG_LONG: +#ifdef WIN32 /* Windows printf does not understand %lld, so use %I64d instead */ + printf("%I64d", *(long long *)v); +#else printf("%lld", *(long long *)v); +#endif break; case BYTES: llv = *(long long *)v; if (bytes_scale_factor != 0) { llv /= bytes_scale_factor; } +#ifdef WIN32 + printf("%I64d", llv); +#else printf("%lld", llv); +#endif break; case TIME_T: /* FIXME option for formatted time? */ @@ -720,6 +743,7 @@ int main(int argc, char **argv) { /* We don't care if sg_init fails, because we can just display the statistics that can be read as non-root. */ sg_init(); + sg_snapshot(); if (sg_drop_privileges() != 0) die("Failed to drop setuid/setgid privileges"); @@ -731,6 +755,7 @@ int main(int argc, char **argv) { case REPEAT_ONCE: get_stats(); sleep(repeat_time); + sg_snapshot(); get_stats(); print_stats(argc, argv); break; @@ -740,6 +765,7 @@ int main(int argc, char **argv) { print_stats(argc, argv); printf("\n"); sleep(repeat_time); + sg_snapshot(); } } @@ -747,6 +773,8 @@ int main(int argc, char **argv) { printf("\n"); printf("statgrab\n"); } + + sg_shutdown(); return 0; }