diff options
Diffstat (limited to 'web/attachments/339420-check_procs_openvz.patch')
-rw-r--r-- | web/attachments/339420-check_procs_openvz.patch | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/web/attachments/339420-check_procs_openvz.patch b/web/attachments/339420-check_procs_openvz.patch new file mode 100644 index 0000000..2a2a28c --- /dev/null +++ b/web/attachments/339420-check_procs_openvz.patch | |||
@@ -0,0 +1,41 @@ | |||
1 | diff --git a/plugins/check_procs.c b/plugins/check_procs.c | ||
2 | index 937c0ad..d1d5378 100644 | ||
3 | --- a/plugins/check_procs.c | ||
4 | +++ b/plugins/check_procs.c | ||
5 | @@ -203,6 +203,9 @@ main (int argc, char **argv) | ||
6 | |||
7 | /* Ignore self */ | ||
8 | if (mypid == procpid) continue; | ||
9 | + | ||
10 | + /* Ignore child containers if we're on an OpenVZ hardware node */ | ||
11 | + if (read_openvz_id(1) == 0 && read_openvz_id(procpid) != 0) continue; | ||
12 | |||
13 | if ((options & STAT) && (strstr (statopts, procstat))) | ||
14 | resultsum |= STAT; | ||
15 | @@ -666,6 +669,26 @@ convert_to_seconds(char *etime) { | ||
16 | return total; | ||
17 | } | ||
18 | |||
19 | +/* Returns the OpenVZ enviroment ID of the specified process, or -1 if we're not on OpenVZ */ | ||
20 | +int | ||
21 | +read_openvz_id(int procid) { | ||
22 | + FILE *file; | ||
23 | + char *filename = strdup(""); | ||
24 | + char line[64]; | ||
25 | + int result = -1; | ||
26 | + | ||
27 | + asprintf(&filename, "/proc/%d/status", procid); | ||
28 | + | ||
29 | + if ((file = fopen(filename, "r")) == NULL) return -1; | ||
30 | + | ||
31 | + while (fgets(line, sizeof(line), file) != NULL) { | ||
32 | + sscanf(line, "envID:\t%d", &result); | ||
33 | + } | ||
34 | + | ||
35 | + fclose(file); | ||
36 | + return result; | ||
37 | +} | ||
38 | + | ||
39 | |||
40 | void | ||
41 | print_help (void) | ||