--- projects/libstatgrab/src/statgrab/statgrab.c 2003/08/26 12:09:44 1.1 +++ projects/libstatgrab/src/statgrab/statgrab.c 2003/08/29 06:48:04 1.6 @@ -18,6 +18,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -75,10 +79,7 @@ void clear_stats() { for (i = 0; i < num_stats; i++) free(stats[i].name); - free(stats); - stats = NULL; num_stats = 0; - alloc_stats = 0; } /* Add a stat. The varargs make up the name, joined with dots; the name is @@ -183,7 +184,7 @@ void get_stats(int use_diffs) { "cpu", "swap", NULL); add_stat(FLOAT, &cpu_p->nice, "cpu", "nice", NULL); - add_stat(TIME_T, &cpu_s->systime, + add_stat(TIME_T, &cpu_p->systime, "cpu", "time_taken", NULL); } } else { @@ -414,9 +415,11 @@ void usage() { " -s Display stat differences repeatedly\n" " -o Display stat differences once\n" " -t DELAY When repeating, wait DELAY seconds between updates (default 1)\n" - " -p Display CPU usage as percentages rather than absolute values\n" + " -p Display CPU usage differences as percentages rather than\n" + " absolute values\n" "\n"); - printf("Report bugs to .\n"); + printf("Version %s - report bugs to <%s>.\n", + PACKAGE_VERSION, PACKAGE_BUGREPORT); exit(1); } @@ -462,9 +465,12 @@ int main(int argc, char **argv) { if (display_mode == DISPLAY_MRTG) { if ((argc - optind) != 2) die("mrtg mode: must specify exactly two stats"); - if (repeat_mode != REPEAT_NONE) + if (repeat_mode == REPEAT_FOREVER) die("mrtg mode: cannot repeat display"); } + + if (use_cpu_percent && repeat_mode == REPEAT_NONE) + die("CPU percentage usage display requires stat differences"); switch (repeat_mode) { case REPEAT_NONE: