mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Merge remote branch 'helmut/improvements'
This commit is contained in:
commit
cdf38620d2
@ -1,4 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -5,5 +5,6 @@
|
||||
|
||||
int writeyes(void);
|
||||
int writeno(const char *);
|
||||
int getenvint(const char *, int);
|
||||
|
||||
#endif
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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"))
|
||||
|
Loading…
Reference in New Issue
Block a user