diff options
author | Helmut Grohne <helmut@subdivi.de> | 2008-06-21 11:33:06 +0000 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2008-06-21 11:33:06 +0000 |
commit | f481beb2dc4e6db37ea79f32960cbfa4a148eb90 (patch) | |
tree | 9c1f37c19b727d34fd8ab23e6e10b8866d46bb43 /processes.c | |
download | munin-plugins-busybox-f481beb2dc4e6db37ea79f32960cbfa4a148eb90.tar.gz |
initial tree
Diffstat (limited to 'processes.c')
-rw-r--r-- | processes.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/processes.c b/processes.c new file mode 100644 index 0000000..b522768 --- /dev/null +++ b/processes.c @@ -0,0 +1,42 @@ +#include <string.h> +#include <stdio.h> +#include <sys/types.h> +#include <dirent.h> +#include <ctype.h> +#include "common.h" + +int processes(int argc, char **argv) { + DIR *d; + struct dirent *e; + char *s; + int n=0; + if(argc > 1) { + if(!strcmp(argv[1], "config")) { + puts("graph_title Number of Processes\n" + "graph_args --base 1000 -l 0 \n" + "graph_vlabel number of processes\n" + "graph_category processes\n" + "graph_info This graph shows the number of processes in the system.\n" + "processes.label processes\n" + "processes.draw LINE2\n" + "processes.info The current number of processes."); + return 0; + } + if(!strcmp(argv[1], "autoconf")) + return writeyes(); + } + if(!(d = opendir("/proc"))) { + fputs("cannot open /proc\n", stderr); + return 1; + } + while((e = readdir(d))) { + for(s=e->d_name;*s;++s) + if(!isdigit(*s)) + break; + if(!*s) + ++n; + } + closedir(d); + printf("processes.value %d\n", n); + return 0; +} |