Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / tools / munin-plugins-busybox / processes.c @ 20993707

Historique | Voir | Annoter | Télécharger (940 octets)

1
#include <string.h>
2
#include <stdio.h>
3
#include <sys/types.h>
4
#include <dirent.h>
5
#include <ctype.h>
6
#include "common.h"
7

    
8
int processes(int argc, char **argv) {
9
        DIR *d;
10
        struct dirent *e;
11
        char *s;
12
        int n=0;
13
        if(argc > 1) {
14
                if(!strcmp(argv[1], "config")) {
15
                        puts("graph_title Number of Processes\n"
16
                                "graph_args --base 1000 -l 0 \n"
17
                                "graph_vlabel number of processes\n"
18
                                "graph_category processes\n"
19
                                "graph_info This graph shows the number of processes in the system.\n"
20
                                "processes.label processes\n"
21
                                "processes.draw LINE2\n"
22
                                "processes.info The current number of processes.");
23
                        return 0;
24
                }
25
                if(!strcmp(argv[1], "autoconf"))
26
                        return writeyes();
27
        }
28
        if(!(d = opendir("/proc"))) {
29
                fputs("cannot open /proc\n", stderr);
30
                return 1;
31
        }
32
        while((e = readdir(d))) {
33
                for(s=e->d_name;*s;++s)
34
                        if(!isdigit(*s))
35
                                break;
36
                if(!*s)
37
                        ++n;
38
        }
39
        closedir(d);
40
        printf("processes.value %d\n", n);
41
        return 0;
42
}