summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 249bed2)
raw | patch | inline | side by side (parent: 249bed2)
author | Matthias Eble <psychotrahe@users.sourceforge.net> | |
Mon, 10 Dec 2007 00:19:27 +0000 (00:19 +0000) | ||
committer | Matthias Eble <psychotrahe@users.sourceforge.net> | |
Mon, 10 Dec 2007 00:19:27 +0000 (00:19 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1851 f882894a-f735-0410-b71e-b25c423dba1c
NEWS | patch | blob | history | |
plugins/check_load.c | patch | blob | history | |
plugins/t/check_load.t | patch | blob | history |
index 6473ec892fd3e7f8d62ef0cdfe763add4f9ba672..a481b58a6394d0aeba9a69a550fead6aafcca19e 100644 (file)
--- a/NEWS
+++ b/NEWS
implement stratum thresholds support (feature request #1703823).
Fix check_disk reporting OK if disk usage grows over 100% (bug #1348746).
The problem happens to be in Gnulib but a workaround have been implemented in check_disk.c
+ Fix check_load argument handling when not passing triplets (bug #1831890)
1.4.10 28th September 2007
Fix check_http buffer overflow vulnerability when following HTTP redirects
diff --git a/plugins/check_load.c b/plugins/check_load.c
index 9de8ff78546ae6718e102ab9735c7f06a1735d4d..5503204a88509524b3ea7addc2b61d41e281a57b 100644 (file)
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
get_threshold(char *arg, double *th)
{
size_t i, n;
+ int valid = 0;
char *str = arg, *p;
n = strlen(arg);
th[i] = strtod(str, &p);
if(p == str) break;
+ valid = 1;
str = p + 1;
if(n <= (size_t)(str - arg)) break;
}
/* empty argument or non-floatish, so warn about it and die */
- if(!i) usage (_("Warning threshold must be float or float triplet!\n"));
+ if(!i && !valid) usage (_("Warning threshold must be float or float triplet!\n"));
if(i != 2) {
/* 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 da87d168a25bb81bc4d0acc00f82f9d0679ce0ed..8987b84cc9efbf61fa32466bca995db47cccb78c 100644 (file)
--- a/plugins/t/check_load.t
+++ b/plugins/t/check_load.t
my $res;
-my $successOutput = '/^OK - load average: [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+/';
-my $failureOutput = '/^CRITICAL - load average: [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+/';
+my $loadValue = "[0-9]+\.?[0-9]+";
+my $successOutput = "/^OK - load average: $loadValue, $loadValue, $loadValue/";
+my $failureOutput = "/^CRITICAL - load average: $loadValue, $loadValue, $loadValue/";
-plan tests => 6;
+plan tests => 11;
$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" );
cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division");
like( $res->output, $failureOutput, "Output OK");
+$res = NPTest->testCmd( "./check_load -w 100 -c 100,110" );
+cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments");
+like( $res->output, $successOutput, "Output OK");
+like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)");
+like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)");
+like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)");