2008-06-21 13:33:06 +02:00
|
|
|
#include <libgen.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
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);
|
2009-01-22 15:30:31 +01:00
|
|
|
int if_err_(int argc, char **argv);
|
2008-06-21 13:33:06 +02:00
|
|
|
int interrupts(int argc, char **argv);
|
|
|
|
int load(int argc, char **argv);
|
|
|
|
int open_files(int argc, char **argv);
|
|
|
|
int open_inodes(int argc, char **argv);
|
|
|
|
int processes(int argc, char **argv);
|
|
|
|
int swap(int argc, char **argv);
|
|
|
|
int uptime(int argc, char **argv);
|
|
|
|
|
2013-01-28 15:53:30 +01:00
|
|
|
int busybox(int argc, char **argv) {
|
|
|
|
if(argc < 2) {
|
|
|
|
fprintf(stderr, "missing parameter\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if(0 != strcmp(argv[1], "listplugins")) {
|
|
|
|
fprintf(stderr, "unknown parameter\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
puts("cpu\nentropy\nforks\nfw_packets\ninterrupts\nload\n"
|
|
|
|
"open_files\nopen_inodes\nprocesses\nswap\nuptime");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-21 13:33:06 +02:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
char *progname;
|
|
|
|
progname = basename(argv[0]);
|
|
|
|
switch(*progname) {
|
|
|
|
case 'c':
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strcmp(progname, "cpu"))
|
2008-06-21 13:33:06 +02:00
|
|
|
return cpu(argc, argv);
|
|
|
|
break;
|
|
|
|
case 'e':
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strcmp(progname, "entropy"))
|
2008-06-21 13:33:06 +02:00
|
|
|
return entropy(argc, argv);
|
|
|
|
break;
|
|
|
|
case 'f':
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strcmp(progname, "forks"))
|
2008-06-21 13:33:06 +02:00
|
|
|
return forks(argc, argv);
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strcmp(progname, "fw_packets"))
|
2008-06-21 13:33:06 +02:00
|
|
|
return fw_packets(argc, argv);
|
|
|
|
break;
|
|
|
|
case 'i':
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strcmp(progname, "interrupts"))
|
2008-06-21 13:33:06 +02:00
|
|
|
return interrupts(argc, argv);
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strncmp(progname, "if_err_", 6))
|
2009-01-22 15:30:31 +01:00
|
|
|
return if_err_(argc, argv);
|
2008-06-21 13:33:06 +02:00
|
|
|
break;
|
|
|
|
case 'l':
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strcmp(progname, "load"))
|
2008-06-21 13:33:06 +02:00
|
|
|
return load(argc, argv);
|
|
|
|
break;
|
2013-01-28 15:53:30 +01:00
|
|
|
case 'm':
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strcmp(progname, "munin-plugins-busybox"))
|
2013-01-28 15:53:30 +01:00
|
|
|
return busybox(argc, argv);
|
|
|
|
break;
|
2008-06-21 13:33:06 +02:00
|
|
|
case 'o':
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strcmp(progname, "open_files"))
|
2008-06-21 13:33:06 +02:00
|
|
|
return open_files(argc, argv);
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strcmp(progname, "open_inodes"))
|
2008-06-21 13:33:06 +02:00
|
|
|
return open_inodes(argc, argv);
|
|
|
|
break;
|
|
|
|
case 'p':
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strcmp(progname, "processes"))
|
2008-06-21 13:33:06 +02:00
|
|
|
return processes(argc, argv);
|
|
|
|
break;
|
|
|
|
case 's':
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strcmp(progname, "swap"))
|
2008-06-21 13:33:06 +02:00
|
|
|
return swap(argc, argv);
|
|
|
|
break;
|
|
|
|
case 'u':
|
2013-02-08 18:08:41 +01:00
|
|
|
if(!strcmp(progname, "uptime"))
|
2008-06-21 13:33:06 +02:00
|
|
|
return uptime(argc, argv);
|
|
|
|
break;
|
|
|
|
}
|
2013-01-28 15:53:30 +01:00
|
|
|
fprintf(stderr, "unknown basename\n");
|
2008-06-21 13:33:06 +02:00
|
|
|
return 1;
|
|
|
|
}
|