From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- web/attachments/339420-check_procs_openvz.patch | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 web/attachments/339420-check_procs_openvz.patch (limited to 'web/attachments/339420-check_procs_openvz.patch') 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 @@ +diff --git a/plugins/check_procs.c b/plugins/check_procs.c +index 937c0ad..d1d5378 100644 +--- a/plugins/check_procs.c ++++ b/plugins/check_procs.c +@@ -203,6 +203,9 @@ main (int argc, char **argv) + + /* Ignore self */ + if (mypid == procpid) continue; ++ ++ /* Ignore child containers if we're on an OpenVZ hardware node */ ++ if (read_openvz_id(1) == 0 && read_openvz_id(procpid) != 0) continue; + + if ((options & STAT) && (strstr (statopts, procstat))) + resultsum |= STAT; +@@ -666,6 +669,26 @@ convert_to_seconds(char *etime) { + return total; + } + ++/* Returns the OpenVZ enviroment ID of the specified process, or -1 if we're not on OpenVZ */ ++int ++read_openvz_id(int procid) { ++ FILE *file; ++ char *filename = strdup(""); ++ char line[64]; ++ int result = -1; ++ ++ asprintf(&filename, "/proc/%d/status", procid); ++ ++ if ((file = fopen(filename, "r")) == NULL) return -1; ++ ++ while (fgets(line, sizeof(line), file) != NULL) { ++ sscanf(line, "envID:\t%d", &result); ++ } ++ ++ fclose(file); ++ return result; ++} ++ + + void + print_help (void) -- cgit v1.2.3-74-g34f1