aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Ton Voon <ton.voon@opsera.com> 2011-01-21 13:14:33 +0000
committerGravatar Ton Voon <ton.voon@opsera.com> 2011-01-21 13:14:33 +0000
commit1a5a83bb82c35d888229fe9f815fbc663c0f4d3c (patch)
tree56a059f3cb927547d2905e65ed837b36affcc565 /plugins
parentae2a66913706e4cb3fc870485abe34c0f3696124 (diff)
downloadmonitoring-plugins-1a5a83bb82c35d888229fe9f815fbc663c0f4d3c.tar.gz
Fix for regex input of '|', being output causing problems with Nagios' parsing of
performance data. Now replaced with ','
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_procs.c11
-rw-r--r--plugins/tests/check_procs.t6
2 files changed, 15 insertions, 2 deletions
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index 2151fb38..d875a618 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -318,6 +318,8 @@ process_arguments (int argc, char **argv)
int err;
int cflags = REG_NOSUB | REG_EXTENDED;
char errbuf[MAX_INPUT_BUFFER];
+ char *temp_string;
+ int i=0;
static struct option longopts[] = {
{"warning", required_argument, 0, 'w'},
{"critical", required_argument, 0, 'c'},
@@ -450,7 +452,14 @@ process_arguments (int argc, char **argv)
regerror (err, &re_args, errbuf, MAX_INPUT_BUFFER);
die (STATE_UNKNOWN, "PROCS %s: %s - %s\n", _("UNKNOWN"), _("Could not compile regular expression"), errbuf);
}
- asprintf (&fmt, "%s%sregex args '%s'", (fmt ? fmt : ""), (options ? ", " : ""), optarg);
+ /* Strip off any | within the regex optarg */
+ temp_string = strdup(optarg);
+ while(temp_string[i]!='\0'){
+ if(temp_string[i]=='|')
+ temp_string[i]=',';
+ i++;
+ }
+ asprintf (&fmt, "%s%sregex args '%s'", (fmt ? fmt : ""), (options ? ", " : ""), temp_string);
options |= EREG_ARGS;
break;
case 'r': /* RSS */
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t
index 1d0c034e..d71c83a2 100644
--- a/plugins/tests/check_procs.t
+++ b/plugins/tests/check_procs.t
@@ -8,7 +8,7 @@ use Test::More;
use NPTest;
if (-x "./check_procs") {
- plan tests => 48;
+ plan tests => 50;
} else {
plan skip_all => "No check_procs compiled";
}
@@ -113,3 +113,7 @@ $result = NPTest->testCmd( "$command --metric=RSS -c 70000 -v" );
is( $result->return_code, 2, "Checking against RSS > 70MB" );
is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowServer, SystemUIServer, Safari, Mail, Safari]', "Output correct" );
+$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" );
+is( $result->return_code, 0, "Checking no pipe symbol in output" );
+is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)'", "Output correct" );
+