diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | plugins/check_load.c | 4 | ||||
-rw-r--r-- | plugins/t/check_load.t | 13 |
3 files changed, 14 insertions, 4 deletions
@@ -15,6 +15,7 @@ This file documents the major additions and syntax changes between releases. | |||
15 | implement stratum thresholds support (feature request #1703823). | 15 | implement stratum thresholds support (feature request #1703823). |
16 | Fix check_disk reporting OK if disk usage grows over 100% (bug #1348746). | 16 | Fix check_disk reporting OK if disk usage grows over 100% (bug #1348746). |
17 | The problem happens to be in Gnulib but a workaround have been implemented in check_disk.c | 17 | The problem happens to be in Gnulib but a workaround have been implemented in check_disk.c |
18 | Fix check_load argument handling when not passing triplets (bug #1831890) | ||
18 | 19 | ||
19 | 1.4.10 28th September 2007 | 20 | 1.4.10 28th September 2007 |
20 | Fix check_http buffer overflow vulnerability when following HTTP redirects | 21 | Fix check_http buffer overflow vulnerability when following HTTP redirects |
diff --git a/plugins/check_load.c b/plugins/check_load.c index 9de8ff78..5503204a 100644 --- a/plugins/check_load.c +++ b/plugins/check_load.c | |||
@@ -77,6 +77,7 @@ static void | |||
77 | get_threshold(char *arg, double *th) | 77 | get_threshold(char *arg, double *th) |
78 | { | 78 | { |
79 | size_t i, n; | 79 | size_t i, n; |
80 | int valid = 0; | ||
80 | char *str = arg, *p; | 81 | char *str = arg, *p; |
81 | 82 | ||
82 | n = strlen(arg); | 83 | n = strlen(arg); |
@@ -84,12 +85,13 @@ get_threshold(char *arg, double *th) | |||
84 | th[i] = strtod(str, &p); | 85 | th[i] = strtod(str, &p); |
85 | if(p == str) break; | 86 | if(p == str) break; |
86 | 87 | ||
88 | valid = 1; | ||
87 | str = p + 1; | 89 | str = p + 1; |
88 | if(n <= (size_t)(str - arg)) break; | 90 | if(n <= (size_t)(str - arg)) break; |
89 | } | 91 | } |
90 | 92 | ||
91 | /* empty argument or non-floatish, so warn about it and die */ | 93 | /* empty argument or non-floatish, so warn about it and die */ |
92 | if(!i) usage (_("Warning threshold must be float or float triplet!\n")); | 94 | if(!i && !valid) usage (_("Warning threshold must be float or float triplet!\n")); |
93 | 95 | ||
94 | if(i != 2) { | 96 | if(i != 2) { |
95 | /* one or more numbers were given, so fill array with last | 97 | /* one or more numbers were given, so fill array with last |
diff --git a/plugins/t/check_load.t b/plugins/t/check_load.t index da87d168..8987b84c 100644 --- a/plugins/t/check_load.t +++ b/plugins/t/check_load.t | |||
@@ -11,10 +11,11 @@ use NPTest; | |||
11 | 11 | ||
12 | my $res; | 12 | my $res; |
13 | 13 | ||
14 | my $successOutput = '/^OK - load average: [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+/'; | 14 | my $loadValue = "[0-9]+\.?[0-9]+"; |
15 | my $failureOutput = '/^CRITICAL - load average: [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+/'; | 15 | my $successOutput = "/^OK - load average: $loadValue, $loadValue, $loadValue/"; |
16 | my $failureOutput = "/^CRITICAL - load average: $loadValue, $loadValue, $loadValue/"; | ||
16 | 17 | ||
17 | plan tests => 6; | 18 | plan tests => 11; |
18 | 19 | ||
19 | $res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" ); | 20 | $res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" ); |
20 | cmp_ok( $res->return_code, 'eq', 0, "load not over 100"); | 21 | cmp_ok( $res->return_code, 'eq', 0, "load not over 100"); |
@@ -28,3 +29,9 @@ $res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" ); | |||
28 | cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division"); | 29 | cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division"); |
29 | like( $res->output, $failureOutput, "Output OK"); | 30 | like( $res->output, $failureOutput, "Output OK"); |
30 | 31 | ||
32 | $res = NPTest->testCmd( "./check_load -w 100 -c 100,110" ); | ||
33 | cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments"); | ||
34 | like( $res->output, $successOutput, "Output OK"); | ||
35 | like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)"); | ||
36 | like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)"); | ||
37 | like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)"); | ||