diff --git a/tools/munin-plugins-busybox/common.c b/tools/munin-plugins-busybox/common.c index 3d78e518..fd291f06 100644 --- a/tools/munin-plugins-busybox/common.c +++ b/tools/munin-plugins-busybox/common.c @@ -1,4 +1,5 @@ #include +#include int writeyes(void) { puts("yes"); @@ -12,3 +13,11 @@ int writeno(const char *s) { puts("no"); return 1; } + +int getenvint(const char *name, int defvalue) { + const char *value; + value = getenv(name); + if(value == NULL) + return defvalue; + return atoi(value); +} diff --git a/tools/munin-plugins-busybox/common.h b/tools/munin-plugins-busybox/common.h index 8db440a9..2a344085 100644 --- a/tools/munin-plugins-busybox/common.h +++ b/tools/munin-plugins-busybox/common.h @@ -5,5 +5,6 @@ int writeyes(void); int writeno(const char *); +int getenvint(const char *, int); #endif diff --git a/tools/munin-plugins-busybox/cpu.c b/tools/munin-plugins-busybox/cpu.c index 3f9d9ff7..2c68f889 100644 --- a/tools/munin-plugins-busybox/cpu.c +++ b/tools/munin-plugins-busybox/cpu.c @@ -12,7 +12,7 @@ int cpu(int argc, char **argv) { FILE *f; char buff[256], *s; - int ncpu=0, extinfo=0, scaleto100=0; + int ncpu=0, extinfo=0, scaleto100=0, hz; if(argc > 1) { if(!strcmp(argv[1], "config")) { s = getenv("scaleto100"); @@ -111,6 +111,26 @@ int cpu(int argc, char **argv) { "irq.cdef irq,%d,/\n" "softirq.cdef softirq,%d,/\n", ncpu, ncpu, ncpu); } + if(extinfo >= 8) { + puts("steal.label steal\n" + "steal.draw STACK\n" + "steal.min 0"); + printf("steal.max %d\n", 100 * ncpu); + puts("steal.type DERIVE\n" + "steal.info The time that a virtual CPU had runnable tasks, but the virtual CPU itself was not running"); + if(scaleto100) + printf("steal.cdef steal,%d,/\n", ncpu); + } + if(extinfo >= 9) { + puts("guest.label guest\n" + "guest.draw STACK\n" + "guest.min 0"); + printf("guest.max %d\n", 100 * ncpu); + puts("guest.type DERIVE\n" + "guest.info The time spent running a virtual CPU for guest operating systems under the control of the Linux kernel."); + if(scaleto100) + printf("guest.cdef guest,%d,/\n", ncpu); + } return 0; } if(!strcmp(argv[1], "autoconf")) { @@ -125,29 +145,36 @@ int cpu(int argc, char **argv) { return 1; } while(fgets(buff, 256, f)) { + hz = getenvint("HZ", 100); if(!strncmp(buff, "cpu ", 4)) { fclose(f); if(!(s = strtok(buff+4, " \t"))) break; - printf("user.value %s\n", s); + printf("user.value %ld\n", atol(s) * 100 / hz); if(!(s = strtok(NULL, " \t"))) break; - printf("nice.value %s\n", s); + printf("nice.value %ld\n", atol(s) * 100 / hz); if(!(s = strtok(NULL, " \t"))) break; - printf("system.value %s\n", s); + printf("system.value %ld\n", atol(s) * 100 / hz); if(!(s = strtok(NULL, " \t"))) break; - printf("idle.value %s\n", s); + printf("idle.value %ld\n", atol(s) * 100 / hz); if(!(s = strtok(NULL, " \t"))) return 0; - printf("iowait.value %s\n", s); + printf("iowait.value %ld\n", atol(s) * 100 / hz); if(!(s = strtok(NULL, " \t"))) return 0; - printf("irq.value %s\n", s); + printf("irq.value %ld\n", atol(s) * 100 / hz); if(!(s = strtok(NULL, " \t"))) return 0; - printf("softirq.value %s\n", s); + printf("softirq.value %ld\n", atol(s) * 100 / hz); + if(!(s = strtok(NULL, " \t"))) + return 0; + printf("steal.value %ld\n", atol(s) * 100 / hz); + if(!(s = strtok(NULL, " \t"))) + return 0; + printf("guest.value %ld\n", atol(s) * 100 / hz); return 0; } } diff --git a/tools/munin-plugins-busybox/load.c b/tools/munin-plugins-busybox/load.c index 27e18437..ee1491c1 100644 --- a/tools/munin-plugins-busybox/load.c +++ b/tools/munin-plugins-busybox/load.c @@ -7,28 +7,18 @@ int load(int argc, char **argv) { FILE *f; - int warn, crit; float val; - char *s; if(argc > 1) { if(!strcmp(argv[1], "config")) { - s = getenv("load_warn"); - if(s) - warn = atoi(s); - else - warn = 10; - s = getenv("load_crit"); - if(s) - crit = atoi(s); - else - crit = 120; puts("graph_title Load average\n" "graph_args --base 1000 -l 0\n" "graph_vlabel load\n" "graph_scale no\n" "graph_category system\n" "load.label load"); - printf("load.warning %d\nload.critical %d\n", warn, crit); + printf("load.warning %d\nload.critical %d\n", + getenvint("load_warn", 10), + getenvint("load_crit", 120)); return 0; } if(!strcmp(argv[1], "autoconf"))