Imported Upstream version 1.4.15
This commit is contained in:
		
							parent
							
								
									882cdeecca
								
							
						
					
					
						commit
						047baae1ca
					
				
					 386 changed files with 60019 additions and 38317 deletions
				
			
		| 
						 | 
				
			
			@ -34,9 +34,9 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
 | 
			
		|||
my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
 | 
			
		||||
my $ntp_warnmatch1 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
 | 
			
		||||
my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
 | 
			
		||||
my $ntp_okmatch2 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2}/';
 | 
			
		||||
my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2}/';
 | 
			
		||||
my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2}/';
 | 
			
		||||
my $ntp_okmatch2 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
 | 
			
		||||
my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
 | 
			
		||||
my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
 | 
			
		||||
my $ntp_noresponse = '/^(CRITICAL - Socket timeout after 3 seconds)|(NTP CRITICAL: No response from NTP server)$/';
 | 
			
		||||
my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -90,21 +90,21 @@ foreach my $plugin (@PLUGINS2) {
 | 
			
		|||
	SKIP: {
 | 
			
		||||
		skip "No NTP server defined", 1 unless $ntp_service;
 | 
			
		||||
		$res = NPTest->testCmd(
 | 
			
		||||
			"./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k 200000"
 | 
			
		||||
			"./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k 200000 -m 1: -n 0:"
 | 
			
		||||
			);
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 0, "$plugin: Good NTP result with jitter and stratum check" );
 | 
			
		||||
		like( $res->output, $ntp_okmatch2, "$plugin: Output match OK with jitter and stratum" );
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 0, "$plugin: Good NTP result with jitter, stratum, and truechimers check" );
 | 
			
		||||
		like( $res->output, $ntp_okmatch2, "$plugin: Output match OK with jitter, stratum, and truechimers" );
 | 
			
		||||
 | 
			
		||||
		$res = NPTest->testCmd(
 | 
			
		||||
			"./$plugin -H $ntp_service -w 1000 -c 2000 -W \\~:-1 -C 21 -j 100000 -k 200000"
 | 
			
		||||
			"./$plugin -H $ntp_service -w 1000 -c 2000 -W \\~:-1 -C 21 -j 100000 -k 200000 -m 1: -n 0:"
 | 
			
		||||
			);
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 1, "$plugin: Warning NTP result with jitter and stratum check" );
 | 
			
		||||
		like( $res->output, $ntp_warnmatch2, "$plugin: Output match WARNING with jitter and stratum" );
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 1, "$plugin: Warning NTP result with jitter, stratum, and truechimers check" );
 | 
			
		||||
		like( $res->output, $ntp_warnmatch2, "$plugin: Output match WARNING with jitter, stratum, and truechimers" );
 | 
			
		||||
 | 
			
		||||
		$res = NPTest->testCmd(
 | 
			
		||||
			"./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k \\~:-1"
 | 
			
		||||
			"./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k \\~:-1 -m 1: -n 0:"
 | 
			
		||||
			);
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 2, "$plugin: Critical NTP result with jitter and stratum check" );
 | 
			
		||||
		like( $res->output, $ntp_critmatch2, "$plugin: Output match CRITICAL with jitter and stratum" );
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 2, "$plugin: Critical NTP result with jitter, stratum, and truechimers check" );
 | 
			
		||||
		like( $res->output, $ntp_critmatch2, "$plugin: Output match CRITICAL with jitter, stratum, and truechimers" );
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,7 @@ use strict;
 | 
			
		|||
use Test::More;
 | 
			
		||||
use NPTest;
 | 
			
		||||
 | 
			
		||||
my $tests = 46;
 | 
			
		||||
my $tests = 8+38+2+2;
 | 
			
		||||
plan tests => $tests;
 | 
			
		||||
my $res;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -44,10 +44,10 @@ SKIP: {
 | 
			
		|||
	like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" );
 | 
			
		||||
 | 
			
		||||
	SKIP: {
 | 
			
		||||
		skip "no snmp host defined", 34 if ( ! $host_snmp );
 | 
			
		||||
		skip "no snmp host defined", 38 if ( ! $host_snmp );
 | 
			
		||||
 | 
			
		||||
		$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:");
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); 
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" );
 | 
			
		||||
		like($res->output, '/^SNMP OK - (\d+)/', "String contains SNMP OK");
 | 
			
		||||
		$res->output =~ /^SNMP OK - (\d+)/;
 | 
			
		||||
		my $value = $1;
 | 
			
		||||
| 
						 | 
				
			
			@ -59,19 +59,27 @@ SKIP: {
 | 
			
		|||
		like($res->output, '/^SNMP OK - \d+/', "String contains SNMP OK");
 | 
			
		||||
 | 
			
		||||
		$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0");
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 0, "Exit OK when querying sysDescr" ); 
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 0, "Exit OK when querying sysDescr" );
 | 
			
		||||
		unlike($res->perf_output, '/sysDescr/', "Perfdata doesn't contain string values");
 | 
			
		||||
 | 
			
		||||
		$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0,system.sysDescr.0");
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, comma-separated" );
 | 
			
		||||
		like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
 | 
			
		||||
 | 
			
		||||
		$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0 -o system.sysDescr.0");
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, repeated option" );
 | 
			
		||||
		like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
 | 
			
		||||
 | 
			
		||||
		$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1");
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrSWRunIndex.1" ); 
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrSWRunIndex.1" );
 | 
			
		||||
		like($res->output, '/^SNMP OK - 1\s.*$/', "String fits SNMP OK and output format");
 | 
			
		||||
 | 
			
		||||
		$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0   -c 1:");
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 1, "Exit WARNING when querying hrSWRunIndex.1 and warn-th doesn't apply " ); 
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 1, "Exit WARNING when querying hrSWRunIndex.1 and warn-th doesn't apply " );
 | 
			
		||||
		like($res->output, '/^SNMP WARNING - \*1\*\s.*$/', "String matches SNMP WARNING and output format");
 | 
			
		||||
 | 
			
		||||
		$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w  :0 -c 0");
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL when querying hrSWRunIndex.1 and crit-th doesn't apply" ); 
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL when querying hrSWRunIndex.1 and crit-th doesn't apply" );
 | 
			
		||||
		like($res->output, '/^SNMP CRITICAL - \*1\*\s.*$/', "String matches SNMP CRITICAL and output format");
 | 
			
		||||
 | 
			
		||||
		$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2 -c 1:2");
 | 
			
		||||
| 
						 | 
				
			
			@ -123,14 +131,14 @@ SKIP: {
 | 
			
		|||
	SKIP: {
 | 
			
		||||
		skip "no non responsive host defined", 2 if ( ! $host_nonresponsive );
 | 
			
		||||
		$res = NPTest->testCmd( "./check_snmp -H $host_nonresponsive -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:");
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); 
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" );
 | 
			
		||||
		like($res->output, '/External command error: Timeout: No Response from /', "String matches timeout problem");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	SKIP: {
 | 
			
		||||
		skip "no non invalid host defined", 2 if ( ! $hostname_invalid );
 | 
			
		||||
		$res = NPTest->testCmd( "./check_snmp -H $hostname_invalid   -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:");
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); 
 | 
			
		||||
		cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" );
 | 
			
		||||
		like($res->output, '/External command error: .*(nosuchhost|Name or service not known|Unknown host)/', "String matches invalid host");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue