mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-04-25 16:17:16 -04:00
Fix performance data label containing spaces in check_snmp (Jochen Bern)
Add --perf-oids option for check_snmp to retain optional 1.4.14 compatibility
This commit is contained in:
parent
cf07b50a82
commit
9c886d049d
4 changed files with 48 additions and 4 deletions
2
NEWS
2
NEWS
|
|
@ -16,6 +16,7 @@ This file documents the major additions and syntax changes between releases.
|
|||
Add perfdata to check_disk_smb (Debian #654259 - Charles-Henri Larose)
|
||||
Updated Nagios::Plugin perl module
|
||||
Add warning threshold to certificate expiration checks of check_tcp/http/smtp (William Leibzon)
|
||||
Add --perf-oids option for check_snmp (Jochen Bern)
|
||||
|
||||
FIXES
|
||||
Fix check_disk free space calculation if blocksizes differ within a disk group (Bekar - #2973603)
|
||||
|
|
@ -28,6 +29,7 @@ This file documents the major additions and syntax changes between releases.
|
|||
Fix check_ping's parsing of ping6(1) output (#1894850, Debian #514588, Debian #662638 - Matej Vela)
|
||||
Fix a check_dhcp bug which was triggered by checking Windows 2003 DHCP servers (#3503921)
|
||||
Disable RFC4507 support, to work around SSL negotiation issues with (at least) some Tomcat versions
|
||||
Fix performance data label containing spaces in check_snmp (Jochen Bern)
|
||||
|
||||
1.4.15 27th July 2010
|
||||
ENHANCEMENTS
|
||||
|
|
|
|||
|
|
@ -273,3 +273,4 @@ Jason Ellison
|
|||
Charles-Henri Larose
|
||||
Tobias Brox
|
||||
William Leibzon
|
||||
Jochen Bern
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ int calculate_rate = 0;
|
|||
int rate_multiplier = 1;
|
||||
state_data *previous_state;
|
||||
double previous_value[MAX_OIDS];
|
||||
int perf_labels = 1;
|
||||
|
||||
|
||||
int
|
||||
|
|
@ -169,6 +170,7 @@ main (int argc, char **argv)
|
|||
char *state_string=NULL;
|
||||
size_t response_length, current_length, string_length;
|
||||
char *temp_string=NULL;
|
||||
char *quote_string=NULL;
|
||||
time_t current_time;
|
||||
double temp_double;
|
||||
time_t duration;
|
||||
|
|
@ -485,11 +487,22 @@ main (int argc, char **argv)
|
|||
ptr = NULL;
|
||||
strtod(show, &ptr);
|
||||
if (ptr > show) {
|
||||
if (nlabels >= (size_t)1 && (size_t)i < nlabels && labels[i] != NULL)
|
||||
if (perf_labels && nlabels >= (size_t)1 && (size_t)i < nlabels && labels[i] != NULL)
|
||||
temp_string=labels[i];
|
||||
else
|
||||
temp_string=oidname;
|
||||
strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1);
|
||||
if (strpbrk (temp_string, " ='\"") == NULL) {
|
||||
strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1);
|
||||
} else {
|
||||
if (strpbrk (temp_string, "\"") == NULL) {
|
||||
quote_string="\"";
|
||||
} else {
|
||||
quote_string="'";
|
||||
}
|
||||
strncat(perfstr, quote_string, sizeof(perfstr)-strlen(perfstr)-1);
|
||||
strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1);
|
||||
strncat(perfstr, quote_string, sizeof(perfstr)-strlen(perfstr)-1);
|
||||
}
|
||||
strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1);
|
||||
len = sizeof(perfstr)-strlen(perfstr)-1;
|
||||
strncat(perfstr, show, len>ptr-show ? ptr-show : len);
|
||||
|
|
@ -583,6 +596,7 @@ process_arguments (int argc, char **argv)
|
|||
{"rate", no_argument, 0, L_CALCULATE_RATE},
|
||||
{"rate-multiplier", required_argument, 0, L_RATE_MULTIPLIER},
|
||||
{"invert-search", no_argument, 0, L_INVERT_SEARCH},
|
||||
{"perf-oids", no_argument, 0, 'O'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
|
@ -600,7 +614,7 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
|
||||
while (1) {
|
||||
c = getopt_long (argc, argv, "nhvVt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:L:U:a:x:A:X:",
|
||||
c = getopt_long (argc, argv, "nhvVOt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:L:U:a:x:A:X:",
|
||||
longopts, &option);
|
||||
|
||||
if (c == -1 || c == EOF)
|
||||
|
|
@ -798,6 +812,9 @@ process_arguments (int argc, char **argv)
|
|||
case L_INVERT_SEARCH:
|
||||
invert_search=1;
|
||||
break;
|
||||
case 'O':
|
||||
perf_labels=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1063,6 +1080,9 @@ print_help (void)
|
|||
printf (" %s\n", "-e, --retries=INTEGER");
|
||||
printf (" %s\n", _("Number of retries to be used in the requests"));
|
||||
|
||||
printf (" %s\n", "-O, --perf-oids");
|
||||
printf (" %s\n", _("Label performance data with OIDs instead of --label's"));
|
||||
|
||||
printf (UT_VERBOSE);
|
||||
|
||||
printf ("\n");
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use Test::More;
|
|||
use NPTest;
|
||||
use FindBin qw($Bin);
|
||||
|
||||
my $tests = 41;
|
||||
my $tests = 51;
|
||||
# Check that all dependent modules are available
|
||||
eval {
|
||||
require NetSNMP::OID;
|
||||
|
|
@ -144,6 +144,27 @@ is($res->return_code, 0, "OK as no thresholds" );
|
|||
is($res->output, "SNMP RATE OK - inoctets 333 | inoctets=333 ", "Check rate decreases due to longer interval");
|
||||
|
||||
|
||||
# label performance data check
|
||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l test" );
|
||||
is($res->return_code, 0, "OK as no thresholds" );
|
||||
is($res->output, "SNMP OK - test 67996 | test=67996c ", "Check label");
|
||||
|
||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l \"test'test\"" );
|
||||
is($res->return_code, 0, "OK as no thresholds" );
|
||||
is($res->output, "SNMP OK - test'test 68662 | \"test'test\"=68662c ", "Check label");
|
||||
|
||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l 'test\"test'" );
|
||||
is($res->return_code, 0, "OK as no thresholds" );
|
||||
is($res->output, "SNMP OK - test\"test 69328 | 'test\"test'=69328c ", "Check label");
|
||||
|
||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l test -O" );
|
||||
is($res->return_code, 0, "OK as no thresholds" );
|
||||
is($res->output, "SNMP OK - test 69994 | iso.3.6.1.4.1.8072.3.2.67.10=69994c ", "Check label");
|
||||
|
||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10" );
|
||||
is($res->return_code, 0, "OK as no thresholds" );
|
||||
is($res->output, "SNMP OK - 70660 | iso.3.6.1.4.1.8072.3.2.67.10=70660c ", "Check label");
|
||||
|
||||
|
||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets_per_minute --rate-multiplier=60" );
|
||||
is($res->return_code, 0, "OK for first call" );
|
||||
|
|
|
|||
Loading…
Reference in a new issue