mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
added if_err_ plugin
This commit is contained in:
parent
a61fdfd103
commit
bdf2dd257a
@ -1,9 +1,9 @@
|
||||
CC=gcc
|
||||
CFLAGS=-W -Wall -pedantic -Wextra -g -O2
|
||||
OBJS=main.o common.o cpu.o entropy.o forks.o fw_packets.o interrupts.o load.o \
|
||||
open_files.o open_inodes.o processes.o swap.o uptime.o
|
||||
LINKS=cpu entropy forks fw_packets interrupts load open_files open_inodes \
|
||||
processes swap uptime
|
||||
OBJS=main.o common.o cpu.o entropy.o forks.o fw_packets.o interrupts.o \
|
||||
if_err_.o load.o open_files.o open_inodes.o processes.o swap.o uptime.o
|
||||
LINKS=cpu entropy forks fw_packets interrupts if_err_eth0 load open_files \
|
||||
open_inodes processes swap uptime
|
||||
|
||||
%.o:%.c
|
||||
${CC} ${CFLAGS} -c $< -o $@
|
||||
|
123
tools/munin-plugins-busybox/if_err_.c
Normal file
123
tools/munin-plugins-busybox/if_err_.c
Normal file
@ -0,0 +1,123 @@
|
||||
#include <ctype.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define PROC_NET_DEV "/proc/net/dev"
|
||||
|
||||
int if_err_(int argc, char **argv) {
|
||||
char *interface;
|
||||
FILE *f;
|
||||
char buff[256], *s;
|
||||
int i;
|
||||
|
||||
interface = basename(argv[0]);
|
||||
if(strncmp(interface, "if_err_", 7) != 0) {
|
||||
fputs("if_err_ invoked with invalid basename\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
interface += 7;
|
||||
|
||||
if(argc > 1) {
|
||||
if(!strcmp(argv[1], "autoconf")) {
|
||||
if(access(PROC_NET_DEV, R_OK) == 0) {
|
||||
puts("yes");
|
||||
return 0;
|
||||
} else {
|
||||
puts("no (/proc/net/dev not found)");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if(!strcmp(argv[1], "suggest")) {
|
||||
if(NULL == (f = fopen(PROC_NET_DEV, "r")))
|
||||
return 1;
|
||||
while(fgets(buff, 256, f)) {
|
||||
for(s=buff;*s == ' ';++s)
|
||||
;
|
||||
i = 0;
|
||||
if(!strncmp(s, "eth", 3))
|
||||
i = 3;
|
||||
else if(!strncmp(s, "wlan", 4))
|
||||
i = 4;
|
||||
else if(!strncmp(s, "ath", 3))
|
||||
i = 3;
|
||||
else if(!strncmp(s, "ra", 2))
|
||||
i = 2;
|
||||
if(i == 0)
|
||||
continue;
|
||||
while(isdigit(s[i]))
|
||||
++i;
|
||||
if(s[i] != ':')
|
||||
continue;
|
||||
s[i] = '\0';
|
||||
puts(s);
|
||||
}
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
if(!strcmp(argv[1], "config")) {
|
||||
puts("graph_order rcvd trans");
|
||||
printf("graph_title %s errors\n", interface);
|
||||
puts("graph_args --base 1000\n"
|
||||
"graph_vlabel packets in (-) / out (+) per "
|
||||
"${graph_period}\n"
|
||||
"graph_category network");
|
||||
printf("graph_info This graph shows the amount of "
|
||||
"errors on the %s network interface.\n",
|
||||
interface);
|
||||
puts("rcvd.label packets\n"
|
||||
"rcvd.type COUNTER\n"
|
||||
"rcvd.graph no\n"
|
||||
"rcvd.warning 1\n"
|
||||
"trans.label packets\n"
|
||||
"trans.type COUNTER\n"
|
||||
"trans.negative rcvd\n"
|
||||
"trans.warning 1");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if(NULL == (f = fopen(PROC_NET_DEV, "r")))
|
||||
return 1;
|
||||
while(fgets(buff, 256, f)) {
|
||||
for(s=buff;*s == ' ';++s)
|
||||
;
|
||||
if(0 != strncmp(s, interface, strlen(interface)))
|
||||
continue;
|
||||
s += strlen(interface);
|
||||
if(*s != ':')
|
||||
continue;
|
||||
++s;
|
||||
|
||||
while(*s == ' ')
|
||||
++s;
|
||||
|
||||
for(i=1;i<3;++i) {
|
||||
while(isdigit(*s))
|
||||
++s;
|
||||
while(isspace(*s))
|
||||
++s;
|
||||
}
|
||||
for(i=0;isdigit(s[i]);++i)
|
||||
;
|
||||
printf("rcvd.value ");
|
||||
fwrite(s, 1, i, stdout);
|
||||
putchar('\n');
|
||||
s += i;
|
||||
while(isspace(*s))
|
||||
++s;
|
||||
|
||||
for(i=4;i<11;++i) {
|
||||
while(isdigit(*s))
|
||||
++s;
|
||||
while(isspace(*s))
|
||||
++s;
|
||||
}
|
||||
for(i=0;isdigit(s[i]);++i)
|
||||
;
|
||||
printf("trans.value ");
|
||||
fwrite(s, 1, i, stdout);
|
||||
putchar('\n');
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -6,6 +6,7 @@ int cpu(int argc, char **argv);
|
||||
int entropy(int argc, char **argv);
|
||||
int forks(int argc, char **argv);
|
||||
int fw_packets(int argc, char **argv);
|
||||
int if_err_(int argc, char **argv);
|
||||
int interrupts(int argc, char **argv);
|
||||
int load(int argc, char **argv);
|
||||
int open_files(int argc, char **argv);
|
||||
@ -35,6 +36,8 @@ int main(int argc, char **argv) {
|
||||
case 'i':
|
||||
if(!strcmp(progname+1, "nterrupts"))
|
||||
return interrupts(argc, argv);
|
||||
if(!strncmp(progname+1, "f_err_", 6))
|
||||
return if_err_(argc, argv);
|
||||
break;
|
||||
case 'l':
|
||||
if(!strcmp(progname+1, "oad"))
|
||||
|
Loading…
Reference in New Issue
Block a user