diff options
| -rw-r--r-- | .travis.yml | 6 | ||||
| -rw-r--r-- | Makefile.am | 1 | ||||
| -rw-r--r-- | NPTest.pm | 252 | ||||
| -rw-r--r-- | plugins-scripts/t/check_file_age.t | 103 | ||||
| -rw-r--r-- | plugins/t/NPTest.cache.travis | 46 | ||||
| -rw-r--r-- | plugins/t/check_by_ssh.t | 14 | ||||
| -rw-r--r-- | plugins/t/check_fping.t | 12 | ||||
| -rw-r--r-- | plugins/t/check_ftp.t | 11 | ||||
| -rw-r--r-- | plugins/t/check_http.t | 52 | ||||
| -rw-r--r-- | plugins/t/check_imap.t | 15 | ||||
| -rw-r--r-- | plugins/t/check_jabber.t | 20 | ||||
| -rw-r--r-- | plugins/t/check_ldap.t | 17 | ||||
| -rw-r--r-- | plugins/t/check_mysql.t | 29 | ||||
| -rw-r--r-- | plugins/t/check_mysql_query.t | 11 | ||||
| -rw-r--r-- | plugins/t/check_snmp.t | 16 | ||||
| -rw-r--r-- | plugins/t/check_ssh.t | 14 | ||||
| -rw-r--r-- | plugins/t/check_tcp.t | 20 | ||||
| -rw-r--r-- | plugins/t/check_time.t | 11 | 
18 files changed, 212 insertions, 438 deletions
| diff --git a/.travis.yml b/.travis.yml index 123e1783..712f2475 100644 --- a/.travis.yml +++ b/.travis.yml | |||
| @@ -42,9 +42,6 @@ before_install: | |||
| 42 | - sudo add-apt-repository -y ppa:waja/trusty-backports | 42 | - sudo add-apt-repository -y ppa:waja/trusty-backports | 
| 43 | - sudo apt-get update -qq | 43 | - sudo apt-get update -qq | 
| 44 | - sudo apt-get purge -qq gawk | 44 | - sudo apt-get purge -qq gawk | 
| 45 | # http://docs.travis-ci.com/user/trusty-ci-environment/ indicates, no MySQL on Trusty (yet) | ||
| 46 | # # ensure we have a test database in place for tests | ||
| 47 | # - mysql -e "create database IF NOT EXISTS test;" -uroot | ||
| 48 | 45 | ||
| 49 | install: | 46 | install: | 
| 50 | - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libradcli-dev libkrb5-dev libnet-snmp-perl procps | 47 | - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libradcli-dev libkrb5-dev libnet-snmp-perl procps | 
| @@ -74,6 +71,7 @@ before_script: | |||
| 74 | - tools/setup | 71 | - tools/setup | 
| 75 | - ./configure --enable-libtap | 72 | - ./configure --enable-libtap | 
| 76 | - make | 73 | - make | 
| 74 | - export NPTEST_ACCEPTDEFAULT=1 | ||
| 77 | - export NPTEST_CACHE="$(pwd)/plugins/t/NPTest.cache.travis" | 75 | - export NPTEST_CACHE="$(pwd)/plugins/t/NPTest.cache.travis" | 
| 78 | - ssh-keygen -t dsa -N "" -f ~/.ssh/id_dsa | 76 | - ssh-keygen -t dsa -N "" -f ~/.ssh/id_dsa | 
| 79 | - cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys | 77 | - cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys | 
| @@ -82,7 +80,7 @@ before_script: | |||
| 82 | - sudo rm -f /usr/share/mibs/ietf/SNMPv2-PDU /usr/share/mibs/ietf/IPSEC-SPD-MIB /usr/share/mibs/ietf/IPATM-IPMC-MIB /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB | 80 | - sudo rm -f /usr/share/mibs/ietf/SNMPv2-PDU /usr/share/mibs/ietf/IPSEC-SPD-MIB /usr/share/mibs/ietf/IPATM-IPMC-MIB /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB | 
| 83 | - sudo mkdir -p /var/lib/snmp/mib_indexes | 81 | - sudo mkdir -p /var/lib/snmp/mib_indexes | 
| 84 | - sudo mkdir /media/ramdisk && sudo chmod 777 /media/ramdisk && sudo mount -t tmpfs -o size=20% none /media/ramdisk | 82 | - sudo mkdir /media/ramdisk && sudo chmod 777 /media/ramdisk && sudo mount -t tmpfs -o size=20% none /media/ramdisk | 
| 85 | - sed "/host_tls_cert/s/.*/'host_tls_cert' => '$(hostname)',/" -i $NPTEST_CACHE | 83 | - sed "/NP_HOST_TLS_CERT/s/.*/'NP_HOST_TLS_CERT' => '$(hostname)',/" -i $NPTEST_CACHE | 
| 86 | 84 | ||
| 87 | script: | 85 | script: | 
| 88 | - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make test; fi | 86 | - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make test; fi | 
| diff --git a/Makefile.am b/Makefile.am index 7e0d4131..df1bcbb3 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -34,6 +34,7 @@ test test-debug: | |||
| 34 | if test "$(PERLMODS_DIR)" != ""; then cd perlmods && $(MAKE) $@; fi | 34 | if test "$(PERLMODS_DIR)" != ""; then cd perlmods && $(MAKE) $@; fi | 
| 35 | cd plugins && $(MAKE) $@ | 35 | cd plugins && $(MAKE) $@ | 
| 36 | cd plugins-scripts && $(MAKE) $@ | 36 | cd plugins-scripts && $(MAKE) $@ | 
| 37 | cd plugins-root && $(MAKE) $@ | ||
| 37 | 38 | ||
| 38 | # Solaris pkgmk | 39 | # Solaris pkgmk | 
| 39 | BUILDDIR = build-solaris | 40 | BUILDDIR = build-solaris | 
| @@ -53,8 +53,8 @@ developer to interactively request test parameter information from the | |||
| 53 | user. The user can accept the developer's default value or reply "none" | 53 | user. The user can accept the developer's default value or reply "none" | 
| 54 | which will then be returned as "" for the test to skip if appropriate. | 54 | which will then be returned as "" for the test to skip if appropriate. | 
| 55 | 55 | ||
| 56 | If a parameter needs to be entered and the test is run without a tty | 56 | If a parameter needs to be entered and the test is run without a tty | 
| 57 | attached (such as a cronjob), the parameter will be assigned as if it | 57 | attached (such as a cronjob), the parameter will be assigned as if it | 
| 58 | was "none". Tests can check for the parameter and skip if not set. | 58 | was "none". Tests can check for the parameter and skip if not set. | 
| 59 | 59 | ||
| 60 | Responses are stored in an external, file-based cache so subsequent test | 60 | Responses are stored in an external, file-based cache so subsequent test | 
| @@ -62,17 +62,6 @@ runs will use these values. The user is able to change the values by | |||
| 62 | amending the values in the file /var/tmp/NPTest.cache, or by setting | 62 | amending the values in the file /var/tmp/NPTest.cache, or by setting | 
| 63 | the appropriate environment variable before running the test. | 63 | the appropriate environment variable before running the test. | 
| 64 | 64 | ||
| 65 | The option exists to store parameters in a scoped means, allowing a | ||
| 66 | test harness to a localise a parameter should the need arise. This | ||
| 67 | allows a parameter of the same name to exist in a test harness | ||
| 68 | specific scope, while not affecting the globally scoped parameter. The | ||
| 69 | scoping identifier is the name of the test harness sans the trailing | ||
| 70 | ".t". All cache searches first look to a scoped parameter before | ||
| 71 | looking for the parameter at global scope. Thus for a test harness | ||
| 72 | called "check_disk.t" requesting the parameter "mountpoint_valid", the | ||
| 73 | cache is first searched for "check_disk"/"mountpoint_valid", if this | ||
| 74 | fails, then a search is conducted for "mountpoint_valid". | ||
| 75 | |||
| 76 | To facilitate quick testing setup, it is possible to accept all the | 65 | To facilitate quick testing setup, it is possible to accept all the | 
| 77 | developer provided defaults by setting the environment variable | 66 | developer provided defaults by setting the environment variable | 
| 78 | "NPTEST_ACCEPTDEFAULT" to "1" (or any other perl truth value). Note | 67 | "NPTEST_ACCEPTDEFAULT" to "1" (or any other perl truth value). Note | 
| @@ -249,26 +238,26 @@ sub checkCmd | |||
| 249 | { | 238 | { | 
| 250 | if ( scalar( grep { $_ == $exitStatus } @{$desiredExitStatus} ) ) | 239 | if ( scalar( grep { $_ == $exitStatus } @{$desiredExitStatus} ) ) | 
| 251 | { | 240 | { | 
| 252 | $desiredExitStatus = $exitStatus; | 241 | $desiredExitStatus = $exitStatus; | 
| 253 | } | 242 | } | 
| 254 | else | 243 | else | 
| 255 | { | 244 | { | 
| 256 | $desiredExitStatus = -1; | 245 | $desiredExitStatus = -1; | 
| 257 | } | 246 | } | 
| 258 | } | 247 | } | 
| 259 | elsif ( ref $desiredExitStatus eq "HASH" ) | 248 | elsif ( ref $desiredExitStatus eq "HASH" ) | 
| 260 | { | 249 | { | 
| 261 | if ( exists( ${$desiredExitStatus}{$exitStatus} ) ) | 250 | if ( exists( ${$desiredExitStatus}{$exitStatus} ) ) | 
| 262 | { | 251 | { | 
| 263 | if ( defined( ${$desiredExitStatus}{$exitStatus} ) ) | 252 | if ( defined( ${$desiredExitStatus}{$exitStatus} ) ) | 
| 264 | { | 253 | { | 
| 265 | $testOutput = ${$desiredExitStatus}{$exitStatus}; | 254 | $testOutput = ${$desiredExitStatus}{$exitStatus}; | 
| 266 | } | 255 | } | 
| 267 | $desiredExitStatus = $exitStatus; | 256 | $desiredExitStatus = $exitStatus; | 
| 268 | } | 257 | } | 
| 269 | else | 258 | else | 
| 270 | { | 259 | { | 
| 271 | $desiredExitStatus = -1; | 260 | $desiredExitStatus = -1; | 
| 272 | } | 261 | } | 
| 273 | } | 262 | } | 
| 274 | 263 | ||
| @@ -327,78 +316,51 @@ sub skipMsg | |||
| 327 | return $testStatus; | 316 | return $testStatus; | 
| 328 | } | 317 | } | 
| 329 | 318 | ||
| 330 | sub getTestParameter | 319 | sub getTestParameter { | 
| 331 | { | 320 | my($param, $description, $default) = @_; | 
| 332 | my( $param, $envvar, $default, $brief, $scoped ); | ||
| 333 | my $new_style; | ||
| 334 | if (scalar @_ <= 3) { | ||
| 335 | ($param, $brief, $default) = @_; | ||
| 336 | $envvar = $param; | ||
| 337 | $new_style = 1; | ||
| 338 | } else { | ||
| 339 | ( $param, $envvar, $default, $brief, $scoped ) = @_; | ||
| 340 | $new_style = 0; | ||
| 341 | } | ||
| 342 | |||
| 343 | # Apply default values for optional arguments | ||
| 344 | $scoped = ( defined( $scoped ) && $scoped ); | ||
| 345 | |||
| 346 | my $testharness = basename( (caller(0))[1], ".t" ); # used for scoping | ||
| 347 | 321 | ||
| 348 | if ( defined( $envvar ) && exists( $ENV{$envvar} ) && $ENV{$envvar} ) | 322 | if($param !~ m/^NP_[A-Z0-9_]+$/mx) { | 
| 349 | { | 323 | die("parameter should be all uppercase and start with NP_ (requested from ".(caller(0))[1].")"); | 
| 350 | return $ENV{$envvar}; | ||
| 351 | } | 324 | } | 
| 352 | 325 | ||
| 353 | my $cachedValue = SearchCache( $param, $testharness ); | 326 | return $ENV{$param} if $ENV{$param}; | 
| 354 | if ( defined( $cachedValue ) ) | 327 | |
| 355 | { | 328 | my $cachedValue = SearchCache($param); | 
| 356 | # This save required to convert to new style because the key required is | 329 | if(defined $cachedValue) { | 
| 357 | # changing to the environment variable | ||
| 358 | if ($new_style == 0) { | ||
| 359 | SetCacheParameter( $envvar, undef, $cachedValue ); | ||
| 360 | } | ||
| 361 | return $cachedValue; | 330 | return $cachedValue; | 
| 362 | } | 331 | } | 
| 363 | 332 | ||
| 364 | my $defaultValid = ( defined( $default ) && $default ); | 333 | if($ENV{'NPTEST_ACCEPTDEFAULT'}) { | 
| 365 | my $autoAcceptDefault = ( exists( $ENV{'NPTEST_ACCEPTDEFAULT'} ) && $ENV{'NPTEST_ACCEPTDEFAULT'} ); | 334 | return $default if $default; | 
| 366 | 335 | return ""; | |
| 367 | if ( $autoAcceptDefault && $defaultValid ) | ||
| 368 | { | ||
| 369 | return $default; | ||
| 370 | } | 336 | } | 
| 371 | 337 | ||
| 372 | # Set "none" if no terminal attached (eg, tinderbox build servers when new variables set) | 338 | # Set "none" if no terminal attached (eg, tinderbox build servers when new variables set) | 
| 373 | return "" unless (-t STDIN); | 339 | return "" unless (-t STDIN); | 
| 374 | 340 | ||
| 375 | my $userResponse = ""; | 341 | my $userResponse = ""; | 
| 376 | 342 | while($userResponse eq "") { | |
| 377 | while ( $userResponse eq "" ) | ||
| 378 | { | ||
| 379 | print STDERR "\n"; | 343 | print STDERR "\n"; | 
| 380 | print STDERR "Test Harness : $testharness\n"; | 344 | print STDERR "Test File : ".(caller(0))[1]."\n"; | 
| 381 | print STDERR "Test Parameter : $param\n"; | 345 | print STDERR "Test Parameter : $param\n"; | 
| 382 | print STDERR "Environment Variable : $envvar\n" if ($param ne $envvar); | 346 | print STDERR "Description : $description\n"; | 
| 383 | print STDERR "Brief Description : $brief\n"; | 347 | print STDERR "Enter value (or 'none') ", ($default ? "[${default}]" : "[]"), " => "; | 
| 384 | print STDERR "Enter value (or 'none') ", ($defaultValid ? "[${default}]" : "[]"), " => "; | ||
| 385 | $userResponse = <STDIN>; | 348 | $userResponse = <STDIN>; | 
| 386 | $userResponse = "" if ! defined( $userResponse ); # Handle EOF | 349 | $userResponse = "" if ! defined( $userResponse ); # Handle EOF | 
| 387 | chomp( $userResponse ); | 350 | chomp($userResponse); | 
| 388 | if ( $defaultValid && $userResponse eq "" ) | 351 | if($default && $userResponse eq "") { | 
| 389 | { | ||
| 390 | $userResponse = $default; | 352 | $userResponse = $default; | 
| 391 | } | 353 | } | 
| 392 | } | 354 | } | 
| 393 | 355 | ||
| 394 | print STDERR "\n"; | 356 | print STDERR "\n"; | 
| 395 | 357 | ||
| 396 | if ($userResponse =~ /^(na|none)$/) { | 358 | if($userResponse =~ /^(na|none)$/) { | 
| 397 | $userResponse = ""; | 359 | $userResponse = ""; | 
| 398 | } | 360 | } | 
| 399 | 361 | ||
| 400 | # define all user responses at global scope | 362 | # store user responses | 
| 401 | SetCacheParameter( $param, ( $scoped ? $testharness : undef ), $userResponse ); | 363 | SetCacheParameter($param, $userResponse); | 
| 402 | 364 | ||
| 403 | return $userResponse; | 365 | return $userResponse; | 
| 404 | } | 366 | } | 
| @@ -407,37 +369,20 @@ sub getTestParameter | |||
| 407 | # Internal Cache Management Functions | 369 | # Internal Cache Management Functions | 
| 408 | # | 370 | # | 
| 409 | 371 | ||
| 410 | sub SearchCache | 372 | sub SearchCache { | 
| 411 | { | 373 | my($param) = @_; | 
| 412 | my( $param, $scope ) = @_; | ||
| 413 | 374 | ||
| 414 | LoadCache(); | 375 | LoadCache(); | 
| 415 | 376 | ||
| 416 | if ( exists( $CACHE{$scope} ) && exists( $CACHE{$scope}{$param} ) ) | 377 | if(exists $CACHE{$param}) { | 
| 417 | { | ||
| 418 | return $CACHE{$scope}{$param}; | ||
| 419 | } | ||
| 420 | |||
| 421 | if ( exists( $CACHE{$param} ) ) | ||
| 422 | { | ||
| 423 | return $CACHE{$param}; | 378 | return $CACHE{$param}; | 
| 424 | } | 379 | } | 
| 425 | return undef; # Need this to say "nothing found" | 380 | return undef; # Need this to say "nothing found" | 
| 426 | } | 381 | } | 
| 427 | 382 | ||
| 428 | sub SetCacheParameter | 383 | sub SetCacheParameter { | 
| 429 | { | 384 | my($param, $value) = @_; | 
| 430 | my( $param, $scope, $value ) = @_; | 385 | $CACHE{$param} = $value; | 
| 431 | |||
| 432 | if ( defined( $scope ) ) | ||
| 433 | { | ||
| 434 | $CACHE{$scope}{$param} = $value; | ||
| 435 | } | ||
| 436 | else | ||
| 437 | { | ||
| 438 | $CACHE{$param} = $value; | ||
| 439 | } | ||
| 440 | |||
| 441 | SaveCache(); | 386 | SaveCache(); | 
| 442 | } | 387 | } | 
| 443 | 388 | ||
| @@ -475,6 +420,11 @@ sub SaveCache | |||
| 475 | delete $CACHE{'_cache_loaded_'}; | 420 | delete $CACHE{'_cache_loaded_'}; | 
| 476 | my $oldFileContents = delete $CACHE{'_original_cache'}; | 421 | my $oldFileContents = delete $CACHE{'_original_cache'}; | 
| 477 | 422 | ||
| 423 | # clean up old style params | ||
| 424 | for my $key (keys %CACHE) { | ||
| 425 | delete $CACHE{$key} if $key !~ m/^NP_[A-Z0-9_]+$/mx; | ||
| 426 | } | ||
| 427 | |||
| 478 | my($dataDumper) = new Data::Dumper([\%CACHE]); | 428 | my($dataDumper) = new Data::Dumper([\%CACHE]); | 
| 479 | $dataDumper->Terse(1); | 429 | $dataDumper->Terse(1); | 
| 480 | $dataDumper->Sortkeys(1); | 430 | $dataDumper->Sortkeys(1); | 
| @@ -486,7 +436,7 @@ sub SaveCache | |||
| 486 | if($oldFileContents ne $data) { | 436 | if($oldFileContents ne $data) { | 
| 487 | my($fileHandle) = new IO::File; | 437 | my($fileHandle) = new IO::File; | 
| 488 | if (!$fileHandle->open( "> ${CACHEFILENAME}")) { | 438 | if (!$fileHandle->open( "> ${CACHEFILENAME}")) { | 
| 489 | print STDERR "NPTest::LoadCache() : Problem saving ${CACHEFILENAME} : $!\n"; | 439 | print STDERR "NPTest::SaveCache() : Problem saving ${CACHEFILENAME} : $!\n"; | 
| 490 | return; | 440 | return; | 
| 491 | } | 441 | } | 
| 492 | print $fileHandle $data; | 442 | print $fileHandle $data; | 
| @@ -542,10 +492,10 @@ sub DetermineTestHarnessDirectory | |||
| 542 | push ( @dirs, "./tests"); | 492 | push ( @dirs, "./tests"); | 
| 543 | } | 493 | } | 
| 544 | 494 | ||
| 545 | if ( @dirs > 0 ) | 495 | if ( @dirs > 0 ) | 
| 546 | { | 496 | { | 
| 547 | return @dirs; | 497 | return @dirs; | 
| 548 | } | 498 | } | 
| 549 | 499 | ||
| 550 | # To be honest I don't understand which case satisfies the | 500 | # To be honest I don't understand which case satisfies the | 
| 551 | # original code in test.pl : when $tstdir == `pwd` w.r.t. | 501 | # original code in test.pl : when $tstdir == `pwd` w.r.t. | 
| @@ -611,73 +561,73 @@ sub TestsFrom | |||
| 611 | 561 | ||
| 612 | # All the new object oriented stuff below | 562 | # All the new object oriented stuff below | 
| 613 | 563 | ||
| 614 | sub new { | 564 | sub new { | 
| 615 | my $type = shift; | 565 | my $type = shift; | 
| 616 | my $self = {}; | 566 | my $self = {}; | 
| 617 | return bless $self, $type; | 567 | return bless $self, $type; | 
| 618 | } | 568 | } | 
| 619 | 569 | ||
| 620 | # Accessors | 570 | # Accessors | 
| 621 | sub return_code { | 571 | sub return_code { | 
| 622 | my $self = shift; | 572 | my $self = shift; | 
| 623 | if (@_) { | 573 | if (@_) { | 
| 624 | return $self->{return_code} = shift; | 574 | return $self->{return_code} = shift; | 
| 625 | } else { | 575 | } else { | 
| 626 | return $self->{return_code}; | 576 | return $self->{return_code}; | 
| 627 | } | 577 | } | 
| 628 | } | 578 | } | 
| 629 | sub output { | 579 | sub output { | 
| 630 | my $self = shift; | 580 | my $self = shift; | 
| 631 | if (@_) { | 581 | if (@_) { | 
| 632 | return $self->{output} = shift; | 582 | return $self->{output} = shift; | 
| 633 | } else { | 583 | } else { | 
| 634 | return $self->{output}; | 584 | return $self->{output}; | 
| 635 | } | 585 | } | 
| 636 | } | 586 | } | 
| 637 | 587 | ||
| 638 | sub perf_output { | 588 | sub perf_output { | 
| 639 | my $self = shift; | 589 | my $self = shift; | 
| 640 | $_ = $self->{output}; | 590 | $_ = $self->{output}; | 
| 641 | /\|(.*)$/; | 591 | /\|(.*)$/; | 
| 642 | return $1 || ""; | 592 | return $1 || ""; | 
| 643 | } | 593 | } | 
| 644 | 594 | ||
| 645 | sub only_output { | 595 | sub only_output { | 
| 646 | my $self = shift; | 596 | my $self = shift; | 
| 647 | $_ = $self->{output}; | 597 | $_ = $self->{output}; | 
| 648 | /(.*?)\|/; | 598 | /(.*?)\|/; | 
| 649 | return $1 || ""; | 599 | return $1 || ""; | 
| 650 | } | 600 | } | 
| 651 | 601 | ||
| 652 | sub testCmd { | 602 | sub testCmd { | 
| 653 | my $class = shift; | 603 | my $class = shift; | 
| 654 | my $command = shift or die "No command passed to testCmd"; | 604 | my $command = shift or die "No command passed to testCmd"; | 
| 655 | my $timeout = shift || 120; | 605 | my $timeout = shift || 120; | 
| 656 | my $object = $class->new; | 606 | my $object = $class->new; | 
| 657 | 607 | ||
| 658 | local $SIG{'ALRM'} = sub { die("timeout in command: $command"); }; | 608 | local $SIG{'ALRM'} = sub { die("timeout in command: $command"); }; | 
| 659 | alarm($timeout); # no test should take longer than 120 seconds | 609 | alarm($timeout); # no test should take longer than 120 seconds | 
| 660 | 610 | ||
| 661 | my $output = `$command`; | 611 | my $output = `$command`; | 
| 662 | $object->return_code($? >> 8); | 612 | $object->return_code($? >> 8); | 
| 663 | $_ = $? & 127; | 613 | $_ = $? & 127; | 
| 664 | if ($_) { | 614 | if ($_) { | 
| 665 | die "Got signal $_ for command $command"; | 615 | die "Got signal $_ for command $command"; | 
| 666 | } | 616 | } | 
| 667 | chomp $output; | 617 | chomp $output; | 
| 668 | $object->output($output); | 618 | $object->output($output); | 
| 669 | 619 | ||
| 670 | alarm(0); | 620 | alarm(0); | 
| 671 | 621 | ||
| 672 | my ($pkg, $file, $line) = caller(0); | 622 | my ($pkg, $file, $line) = caller(0); | 
| 673 | print "Testing: $command", $/; | 623 | print "Testing: $command", $/; | 
| 674 | if ($ENV{'NPTEST_DEBUG'}) { | 624 | if ($ENV{'NPTEST_DEBUG'}) { | 
| 675 | print "testCmd: Called from line $line in $file", $/; | 625 | print "testCmd: Called from line $line in $file", $/; | 
| 676 | print "Output: ", $object->output, $/; | 626 | print "Output: ", $object->output, $/; | 
| 677 | print "Return code: ", $object->return_code, $/; | 627 | print "Return code: ", $object->return_code, $/; | 
| 678 | } | 628 | } | 
| 679 | 629 | ||
| 680 | return $object; | 630 | return $object; | 
| 681 | } | 631 | } | 
| 682 | 632 | ||
| 683 | # do we have ipv6 | 633 | # do we have ipv6 | 
| diff --git a/plugins-scripts/t/check_file_age.t b/plugins-scripts/t/check_file_age.t index ebf673f5..8b876708 100644 --- a/plugins-scripts/t/check_file_age.t +++ b/plugins-scripts/t/check_file_age.t | |||
| @@ -20,105 +20,74 @@ my $temp_link = "/tmp/check_file_age.link.tmp"; | |||
| 20 | 20 | ||
| 21 | unlink $temp_file, $temp_link; | 21 | unlink $temp_file, $temp_link; | 
| 22 | 22 | ||
| 23 | $result = NPTest->testCmd( | 23 | $result = NPTest->testCmd("./check_file_age"); | 
| 24 | "./check_file_age" | ||
| 25 | ); | ||
| 26 | cmp_ok( $result->return_code, '==', 3, "Missing parameters" ); | 24 | cmp_ok( $result->return_code, '==', 3, "Missing parameters" ); | 
| 27 | like ( $result->output, $unknownOutput, "Output for unknown correct" ); | 25 | like ( $result->output, $unknownOutput, "Output for unknown correct" ); | 
| 28 | 26 | ||
| 29 | $result = NPTest->testCmd( | 27 | $result = NPTest->testCmd("./check_file_age -f $temp_file"); | 
| 30 | "./check_file_age -f $temp_file" | ||
| 31 | ); | ||
| 32 | cmp_ok( $result->return_code, '==', 2, "File not exists" ); | 28 | cmp_ok( $result->return_code, '==', 2, "File not exists" ); | 
| 33 | like ( $result->output, $criticalOutput, "Output for file missing correct" ); | 29 | like ( $result->output, $criticalOutput, "Output for file missing correct" ); | 
| 34 | 30 | ||
| 35 | write_chars(100); | 31 | write_chars(100); | 
| 36 | $result = NPTest->testCmd( | 32 | $result = NPTest->testCmd("./check_file_age -f $temp_file"); | 
| 37 | "./check_file_age -f $temp_file" | ||
| 38 | ); | ||
| 39 | cmp_ok( $result->return_code, '==', 0, "File is new enough" ); | 33 | cmp_ok( $result->return_code, '==', 0, "File is new enough" ); | 
| 40 | like ( $result->output, $successOutput, "Output for success correct" ); | 34 | like ( $result->output, $successOutput, "Output for success correct" ); | 
| 41 | 35 | ||
| 42 | sleep 2; | 36 | sleep 2; | 
| 43 | 37 | ||
| 44 | $result = NPTest->testCmd( | 38 | $result = NPTest->testCmd("./check_file_age -f $temp_file -w 1"); | 
| 45 | "./check_file_age -f $temp_file -w 1" | ||
| 46 | ); | ||
| 47 | cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" ); | 39 | cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" ); | 
| 48 | like ( $result->output, $warningOutput, "Output for warning correct" ); | 40 | like ( $result->output, $warningOutput, "Output for warning correct" ); | 
| 49 | 41 | ||
| 50 | $result = NPTest->testCmd( | 42 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1"); | 
| 51 | "./check_file_age -f $temp_file -w 0:1" | ||
| 52 | ); | ||
| 53 | cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old by range" ); | ||
| 54 | like ( $result->output, $warningOutput, "Output for warning by range correct" ); | ||
| 55 | |||
| 56 | $result = NPTest->testCmd( | ||
| 57 | "./check_file_age -f $temp_file -c 1" | ||
| 58 | ); | ||
| 59 | cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" ); | 43 | cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" ); | 
| 60 | like ( $result->output, $criticalOutput, "Output for critical correct" ); | 44 | like ( $result->output, $criticalOutput, "Output for critical correct" ); | 
| 61 | 45 | ||
| 62 | $result = NPTest->testCmd( | 46 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100"); | 
| 63 | "./check_file_age -f $temp_file -c 0:1" | ||
| 64 | ); | ||
| 65 | cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old by range" ); | ||
| 66 | like ( $result->output, $criticalOutput, "Output for critical by range correct" ); | ||
| 67 | |||
| 68 | $result = NPTest->testCmd( | ||
| 69 | "./check_file_age -f $temp_file -c 1000 -W 100" | ||
| 70 | ); | ||
| 71 | cmp_ok( $result->return_code, '==', 0, "Checking file size" ); | 47 | cmp_ok( $result->return_code, '==', 0, "Checking file size" ); | 
| 72 | 48 | ||
| 73 | $result = NPTest->testCmd( | 49 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100"); | 
| 74 | "./check_file_age -f $temp_file -c 0:1000 -W 0:100" | ||
| 75 | ); | ||
| 76 | cmp_ok( $result->return_code, '==', 0, "Checking file size by range" ); | ||
| 77 | |||
| 78 | $result = NPTest->testCmd( | ||
| 79 | "./check_file_age -f $temp_file -c 1000 -W 100" | ||
| 80 | ); | ||
| 81 | like( $result->output, $performanceOutput, "Checking for performance Output" ); | 50 | like( $result->output, $performanceOutput, "Checking for performance Output" ); | 
| 82 | 51 | ||
| 83 | $result = NPTest->testCmd( | 52 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100"); | 
| 84 | "./check_file_age -f $temp_file -c 1000 -W 100" | ||
| 85 | ); | ||
| 86 | like( $result->output, $performanceOutput, "Checking for performance Output from range" ); | 53 | like( $result->output, $performanceOutput, "Checking for performance Output from range" ); | 
| 87 | 54 | ||
| 88 | $result = NPTest->testCmd( | 55 | $result = NPTest->testCmd("./check_file_age -f /non/existent --ignore-missing"); | 
| 89 | "./check_file_age -f /non/existent --ignore-missing" | ||
| 90 | ); | ||
| 91 | cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" ); | 56 | cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" ); | 
| 92 | 57 | ||
| 93 | $result = NPTest->testCmd( | 58 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 101"); | 
| 94 | "./check_file_age -f $temp_file -c 1000 -W 101" | ||
| 95 | ); | ||
| 96 | cmp_ok( $result->return_code, '==', 1, "One byte too short" ); | 59 | cmp_ok( $result->return_code, '==', 1, "One byte too short" ); | 
| 97 | 60 | ||
| 98 | $result = NPTest->testCmd( | 61 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 101"); | 
| 99 | "./check_file_age -f $temp_file -c 1000 -W 101:" | ||
| 100 | ); | ||
| 101 | cmp_ok( $result->return_code, '==', 1, "One byte too short by range" ); | ||
| 102 | |||
| 103 | $result = NPTest->testCmd( | ||
| 104 | "./check_file_age -f $temp_file -c 1000 -C 101" | ||
| 105 | ); | ||
| 106 | cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" ); | 62 | cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" ); | 
| 107 | 63 | ||
| 108 | $result = NPTest->testCmd( | 64 | SKIP: { | 
| 109 | "./check_file_age -f $temp_file -c 1000 -C 101:" | 65 | eval 'use Monitoring::Plugin::Range'; | 
| 110 | ); | 66 | skip "Monitoring::Plugin::Range module require", 9 if $@; | 
| 111 | cmp_ok( $result->return_code, '==', 2, "One byte too short by range - critical" ); | 67 | |
| 68 | $result = NPTest->testCmd("./check_file_age -f $temp_file -w 0:1"); | ||
| 69 | cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old by range" ); | ||
| 70 | like ( $result->output, $warningOutput, "Output for warning by range correct" ); | ||
| 71 | |||
| 72 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 0:1"); | ||
| 73 | cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old by range" ); | ||
| 74 | like ( $result->output, $criticalOutput, "Output for critical by range correct" ); | ||
| 75 | |||
| 76 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 0:1000 -W 0:100"); | ||
| 77 | cmp_ok( $result->return_code, '==', 0, "Checking file size by range" ); | ||
| 78 | |||
| 79 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 101:"); | ||
| 80 | cmp_ok( $result->return_code, '==', 1, "One byte too short by range" ); | ||
| 81 | |||
| 82 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 0:99"); | ||
| 83 | cmp_ok( $result->return_code, '==', 1, "One byte too long by range" ); | ||
| 112 | 84 | ||
| 113 | $result = NPTest->testCmd( | 85 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 101:"); | 
| 114 | "./check_file_age -f $temp_file -c 1000 -W 0:99" | 86 | cmp_ok( $result->return_code, '==', 2, "One byte too short by range - critical" ); | 
| 115 | ); | ||
| 116 | cmp_ok( $result->return_code, '==', 1, "One byte too long by range" ); | ||
| 117 | 87 | ||
| 118 | $result = NPTest->testCmd( | 88 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 0:99"); | 
| 119 | "./check_file_age -f $temp_file -c 1000 -C 0:99" | 89 | cmp_ok( $result->return_code, '==', 2, "One byte too long by range - critical" ); | 
| 120 | ); | 90 | }; | 
| 121 | cmp_ok( $result->return_code, '==', 2, "One byte too long by range - critical" ); | ||
| 122 | 91 | ||
| 123 | symlink $temp_file, $temp_link or die "Cannot create symlink"; | 92 | symlink $temp_file, $temp_link or die "Cannot create symlink"; | 
| 124 | $result = NPTest->testCmd("./check_file_age -f $temp_link -c 10"); | 93 | $result = NPTest->testCmd("./check_file_age -f $temp_link -c 10"); | 
| diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis index 28437a00..6ee45053 100644 --- a/plugins/t/NPTest.cache.travis +++ b/plugins/t/NPTest.cache.travis | |||
| @@ -1,64 +1,54 @@ | |||
| 1 | { | 1 | { | 
| 2 | 'MYSQL_LOGIN_DETAILS' => '-u root -d test', | ||
| 3 | 'NP_ALLOW_SUDO' => 'yes', | 2 | 'NP_ALLOW_SUDO' => 'yes', | 
| 4 | 'NP_DNS_SERVER' => '8.8.8.8', | 3 | 'NP_DNS_SERVER' => '8.8.8.8', | 
| 5 | 'NP_GOOD_NTP_SERVICE' => '', | 4 | 'NP_GOOD_NTP_SERVICE' => '', | 
| 5 | 'NP_HOST_DHCP_RESPONSIVE' => '', | ||
| 6 | 'NP_HOST_HPJD_PORT_INVALID' => '161', | ||
| 7 | 'NP_HOST_HPJD_PORT_VALID' => '', | ||
| 8 | 'NP_HOSTNAME_INVALID_CIDR' => '130.133.8.39/30', | ||
| 6 | 'NP_HOSTNAME_INVALID' => 'nosuchhost', | 9 | 'NP_HOSTNAME_INVALID' => 'nosuchhost', | 
| 7 | 'NP_HOSTNAME_VALID' => 'monitoring-plugins.org', | ||
| 8 | 'NP_HOSTNAME_VALID_IP' => '130.133.8.40', | ||
| 9 | 'NP_HOSTNAME_VALID_CIDR' => '130.133.8.41/30', | 10 | 'NP_HOSTNAME_VALID_CIDR' => '130.133.8.41/30', | 
| 10 | 'NP_HOSTNAME_INVALID_CIDR' => '130.133.8.39/30', | 11 | 'NP_HOSTNAME_VALID_IP' => '130.133.8.40', | 
| 12 | 'NP_HOSTNAME_VALID' => 'monitoring-plugins.org', | ||
| 11 | 'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.', | 13 | 'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.', | 
| 12 | 'NP_HOST_DHCP_RESPONSIVE' => '', | ||
| 13 | 'NP_HOST_NONRESPONSIVE' => '10.0.0.1', | 14 | 'NP_HOST_NONRESPONSIVE' => '10.0.0.1', | 
| 14 | 'NP_HOST_RESPONSIVE' => 'localhost', | 15 | 'NP_HOST_RESPONSIVE' => 'localhost', | 
| 15 | 'NP_HOST_SMB' => '', | 16 | 'NP_HOST_SMB' => '', | 
| 16 | 'NP_HOST_SNMP' => 'localhost', | 17 | 'NP_HOST_SNMP' => '', | 
| 17 | 'NP_HOST_TCP_FTP' => '', | 18 | 'NP_HOST_TCP_FTP' => '', | 
| 18 | 'NP_HOST_TCP_HPJD' => '', | 19 | 'NP_HOST_TCP_HPJD' => '', | 
| 19 | 'NP_HOST_HPJD_PORT_INVALID' => '161', | ||
| 20 | 'NP_HOST_HPJD_PORT_VALID' => '', | ||
| 21 | 'NP_HOST_TCP_HTTP' => 'localhost', | ||
| 22 | 'NP_HOST_TCP_HTTP2' => 'test.monitoring-plugins.org', | 20 | 'NP_HOST_TCP_HTTP2' => 'test.monitoring-plugins.org', | 
| 21 | 'NP_HOST_TCP_HTTP' => 'localhost', | ||
| 23 | 'NP_HOST_TCP_IMAP' => 'imap.web.de', | 22 | 'NP_HOST_TCP_IMAP' => 'imap.web.de', | 
| 23 | 'NP_HOST_TCP_JABBER' => 'jabber.org', | ||
| 24 | 'NP_HOST_TCP_LDAP' => 'localhost', | 24 | 'NP_HOST_TCP_LDAP' => 'localhost', | 
| 25 | 'NP_HOST_TCP_POP' => 'pop.web.de', | 25 | 'NP_HOST_TCP_POP' => 'pop.web.de', | 
| 26 | 'NP_HOST_TCP_PROXY' => 'localhost', | ||
| 26 | 'NP_HOST_TCP_SMTP' => 'localhost', | 27 | 'NP_HOST_TCP_SMTP' => 'localhost', | 
| 27 | 'NP_HOST_TCP_SMTP_NOTLS' => '', | 28 | 'NP_HOST_TCP_SMTP_NOTLS' => '', | 
| 28 | 'NP_HOST_TCP_SMTP_TLS' => '', | 29 | 'NP_HOST_TCP_SMTP_TLS' => '', | 
| 30 | 'NP_HOST_TLS_CERT' => 'localhost, | ||
| 31 | 'NP_HOST_TLS_HTTP' => 'localhost', | ||
| 32 | 'NP_HOST_UDP_TIME' => 'none', | ||
| 29 | 'NP_INTERNET_ACCESS' => 'yes', | 33 | 'NP_INTERNET_ACCESS' => 'yes', | 
| 30 | 'NP_LDAP_BASE_DN' => 'cn=admin,dc=nodomain', | 34 | 'NP_LDAP_BASE_DN' => 'cn=admin,dc=nodomain', | 
| 31 | 'NP_MOUNTPOINT2_VALID' => '/media/ramdisk', | 35 | 'NP_MOUNTPOINT2_VALID' => '/media/ramdisk', | 
| 32 | 'NP_MOUNTPOINT_VALID' => '/', | 36 | 'NP_MOUNTPOINT_VALID' => '/', | 
| 37 | 'NP_MYSQL_LOGIN_DETAILS' => '-u root -d test', | ||
| 33 | 'NP_MYSQL_SERVER' => 'localhost', | 38 | 'NP_MYSQL_SERVER' => 'localhost', | 
| 34 | 'NP_HOST_UDP_TIME' => 'localhost', | ||
| 35 | 'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock', | 39 | 'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock', | 
| 36 | 'NP_MYSQL_WITH_SLAVE' => '', | 40 | 'NP_MYSQL_WITH_SLAVE' => '', | 
| 37 | 'NP_MYSQL_WITH_SLAVE_LOGIN' => '', | 41 | 'NP_MYSQL_WITH_SLAVE_LOGIN' => '', | 
| 38 | 'NP_NO_NTP_SERVICE' => 'localhost', | 42 | 'NP_NO_NTP_SERVICE' => 'localhost', | 
| 43 | 'NP_PORT_TCP_PROXY' => '3128', | ||
| 39 | 'NP_SMB_SHARE' => '', | 44 | 'NP_SMB_SHARE' => '', | 
| 40 | 'NP_SMB_SHARE_DENY' => '', | 45 | 'NP_SMB_SHARE_DENY' => '', | 
| 41 | 'NP_SMB_SHARE_SPC' => '', | 46 | 'NP_SMB_SHARE_SPC' => '', | 
| 42 | 'NP_SMB_VALID_USER' => '', | 47 | 'NP_SMB_VALID_USER' => '', | 
| 43 | 'NP_SMB_VALID_USER_PASS' => '', | 48 | 'NP_SMB_VALID_USER_PASS' => '', | 
| 44 | 'NP_SNMP_COMMUNITY' => 'public', | 49 | 'NP_SNMP_COMMUNITY' => '', | 
| 50 | 'NP_SNMP_USER' => '', | ||
| 45 | 'NP_SSH_CONFIGFILE' => '~/.ssh/config', | 51 | 'NP_SSH_CONFIGFILE' => '~/.ssh/config', | 
| 46 | 'NP_SSH_HOST' => 'localhost', | 52 | 'NP_SSH_HOST' => 'localhost', | 
| 47 | 'NP_SSH_IDENTITY' => '~/.ssh/id_dsa', | 53 | 'NP_SSH_IDENTITY' => '~/.ssh/id_dsa' | 
| 48 | 'NP_HOST_TCP_JABBER' => 'jabber.org', | ||
| 49 | 'host_nonresponsive' => '10.0.0.1', | ||
| 50 | 'host_responsive' => 'localhost', | ||
| 51 | 'host_snmp' => '', | ||
| 52 | 'host_tcp_ftp' => '', | ||
| 53 | 'host_tcp_http' => 'localhost', | ||
| 54 | 'host_tcp_imap' => 'imap.nierlein.de', | ||
| 55 | 'host_tcp_smtp' => 'localhost', | ||
| 56 | 'hostname_invalid' => 'nosuchhost', | ||
| 57 | 'snmp_community' => '', | ||
| 58 | 'user_snmp' => '', | ||
| 59 | 'host_udp_time' => 'none', | ||
| 60 | 'host_tls_http' => 'localhost', | ||
| 61 | 'host_tls_cert' => 'localhost', | ||
| 62 | 'NP_HOST_TCP_PROXY' => 'localhost', | ||
| 63 | 'NP_PORT_TCP_PROXY' => '3128', | ||
| 64 | } | 54 | } | 
| diff --git a/plugins/t/check_by_ssh.t b/plugins/t/check_by_ssh.t index 4797390d..1d2939e9 100644 --- a/plugins/t/check_by_ssh.t +++ b/plugins/t/check_by_ssh.t | |||
| @@ -9,17 +9,9 @@ use Test::More; | |||
| 9 | use NPTest; | 9 | use NPTest; | 
| 10 | 10 | ||
| 11 | # Required parameters | 11 | # Required parameters | 
| 12 | my $ssh_service = getTestParameter( "NP_SSH_HOST", | 12 | my $ssh_service = getTestParameter("NP_SSH_HOST", "A host providing SSH service", "localhost"); | 
| 13 | "A host providing SSH service", | 13 | my $ssh_key = getTestParameter("NP_SSH_IDENTITY", "A key allowing access to NP_SSH_HOST", "~/.ssh/id_dsa"); | 
| 14 | "localhost"); | 14 | my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE", "A config file with ssh settings", "~/.ssh/config"); | 
| 15 | |||
| 16 | my $ssh_key = getTestParameter( "NP_SSH_IDENTITY", | ||
| 17 | "A key allowing access to NP_SSH_HOST", | ||
| 18 | "~/.ssh/id_dsa"); | ||
| 19 | |||
| 20 | my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE", | ||
| 21 | "A config file with ssh settings", | ||
| 22 | "~/.ssh/config"); | ||
| 23 | 15 | ||
| 24 | 16 | ||
| 25 | plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key); | 17 | plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key); | 
| diff --git a/plugins/t/check_fping.t b/plugins/t/check_fping.t index 08692e46..342b0a7e 100644 --- a/plugins/t/check_fping.t +++ b/plugins/t/check_fping.t | |||
| @@ -15,15 +15,9 @@ BEGIN {$tests = 4; plan tests => $tests} | |||
| 15 | my $successOutput = '/^FPING OK - /'; | 15 | my $successOutput = '/^FPING OK - /'; | 
| 16 | my $failureOutput = '/^FPING CRITICAL - /'; | 16 | my $failureOutput = '/^FPING CRITICAL - /'; | 
| 17 | 17 | ||
| 18 | my $host_responsive = getTestParameter( "host_responsive", "NP_HOST_RESPONSIVE", "localhost", | 18 | my $host_responsive = getTestParameter("NP_HOST_RESPONSIVE", "The hostname of system responsive to network requests", "localhost"); | 
| 19 | "The hostname of system responsive to network requests" ); | 19 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | 
| 20 | 20 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | |
| 21 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
| 22 | "The hostname of system not responsive to network requests" ); | ||
| 23 | |||
| 24 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
| 25 | "An invalid (not known to DNS) hostname" ); | ||
| 26 | |||
| 27 | 21 | ||
| 28 | my $t; | 22 | my $t; | 
| 29 | 23 | ||
| diff --git a/plugins/t/check_ftp.t b/plugins/t/check_ftp.t index de6831ba..93a7d7c3 100644 --- a/plugins/t/check_ftp.t +++ b/plugins/t/check_ftp.t | |||
| @@ -11,14 +11,9 @@ use NPTest; | |||
| 11 | use vars qw($tests); | 11 | use vars qw($tests); | 
| 12 | BEGIN {$tests = 4; plan tests => $tests} | 12 | BEGIN {$tests = 4; plan tests => $tests} | 
| 13 | 13 | ||
| 14 | my $host_tcp_ftp = getTestParameter( "host_tcp_ftp", "NP_HOST_TCP_FTP", "localhost", | 14 | my $host_tcp_ftp = getTestParameter("NP_HOST_TCP_FTP", "A host providing the FTP Service (an FTP server)", "localhost"); | 
| 15 | "A host providing the FTP Service (an FTP server)"); | 15 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | 
| 16 | 16 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | |
| 17 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
| 18 | "The hostname of system not responsive to network requests" ); | ||
| 19 | |||
| 20 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
| 21 | "An invalid (not known to DNS) hostname" ); | ||
| 22 | 17 | ||
| 23 | my $successOutput = '/FTP OK -\s+[0-9]?\.?[0-9]+ second response time/'; | 18 | my $successOutput = '/FTP OK -\s+[0-9]?\.?[0-9]+ second response time/'; | 
| 24 | 19 | ||
| diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 416fbbcb..b3760ebe 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
| @@ -9,46 +9,21 @@ use Test::More; | |||
| 9 | use POSIX qw/mktime strftime/; | 9 | use POSIX qw/mktime strftime/; | 
| 10 | use NPTest; | 10 | use NPTest; | 
| 11 | 11 | ||
| 12 | plan tests => 55; | 12 | plan tests => 50; | 
| 13 | 13 | ||
| 14 | my $successOutput = '/OK.*HTTP.*second/'; | 14 | my $successOutput = '/OK.*HTTP.*second/'; | 
| 15 | 15 | ||
| 16 | my $res; | 16 | my $res; | 
| 17 | 17 | ||
| 18 | my $host_tcp_http = getTestParameter( "NP_HOST_TCP_HTTP", | 18 | my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost"); | 
| 19 | "A host providing the HTTP Service (a web server)", | 19 | my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost"); | 
| 20 | "localhost" ); | 20 | my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost"); | 
| 21 | 21 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | |
| 22 | my $host_tls_http = getTestParameter( "host_tls_http", "NP_HOST_TLS_HTTP", "localhost", | 22 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | 
| 23 | "A host providing the HTTPS Service (a tls web server)" ); | 23 | my $internet_access = getTestParameter("NP_INTERNET_ACCESS", "Is this system directly connected to the internet?", "yes"); | 
| 24 | 24 | my $host_tcp_http2 = getTestParameter("NP_HOST_TCP_HTTP2", "A host providing an index page containing the string 'monitoring'", "test.monitoring-plugins.org"); | |
| 25 | my $host_tls_cert = getTestParameter( "host_tls_cert", "NP_HOST_TLS_CERT", "localhost", | 25 | my $host_tcp_proxy = getTestParameter("NP_HOST_TCP_PROXY", "A host providing a HTTP proxy with CONNECT support", "localhost"); | 
| 26 | "the common name of the certificate." ); | 26 | my $port_tcp_proxy = getTestParameter("NP_PORT_TCP_PROXY", "Port of the proxy with HTTP and CONNECT support", "3128"); | 
| 27 | |||
| 28 | |||
| 29 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", | ||
| 30 | "The hostname of system not responsive to network requests", | ||
| 31 | "10.0.0.1" ); | ||
| 32 | |||
| 33 | my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", | ||
| 34 | "An invalid (not known to DNS) hostname", | ||
| 35 | "nosuchhost"); | ||
| 36 | |||
| 37 | my $internet_access = getTestParameter( "NP_INTERNET_ACCESS", | ||
| 38 | "Is this system directly connected to the internet?", | ||
| 39 | "yes"); | ||
| 40 | |||
| 41 | my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2", | ||
| 42 | "A host providing an index page containing the string 'monitoring'", | ||
| 43 | "test.monitoring-plugins.org" ); | ||
| 44 | |||
| 45 | my $host_tcp_proxy = getTestParameter( "NP_HOST_TCP_PROXY", | ||
| 46 | "A host providing a HTTP proxy with CONNECT support", | ||
| 47 | "localhost"); | ||
| 48 | |||
| 49 | my $port_tcp_proxy = getTestParameter( "NP_PORT_TCP_PROXY", | ||
| 50 | "Port of the proxy with HTTP and CONNECT support", | ||
| 51 | "3128"); | ||
| 52 | 27 | ||
| 53 | my $faketime = -x '/usr/bin/faketime' ? 1 : 0; | 28 | my $faketime = -x '/usr/bin/faketime' ? 1 : 0; | 
| 54 | 29 | ||
| @@ -158,7 +133,7 @@ SKIP: { | |||
| 158 | 133 | ||
| 159 | # run some certificate checks with faketime | 134 | # run some certificate checks with faketime | 
| 160 | SKIP: { | 135 | SKIP: { | 
| 161 | skip "No faketime binary found", 12 if !$faketime; | 136 | skip "No faketime binary found", 7 if !$faketime; | 
| 162 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./check_http -C 1 $host_tls_http"); | 137 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./check_http -C 1 $host_tls_http"); | 
| 163 | like($res->output, qr/OK - Certificate '$host_tls_cert' will expire on/, "Catch cert output"); | 138 | like($res->output, qr/OK - Certificate '$host_tls_cert' will expire on/, "Catch cert output"); | 
| 164 | is( $res->return_code, 0, "Catch cert output exit code" ); | 139 | is( $res->return_code, 0, "Catch cert output exit code" ); | 
| @@ -171,23 +146,18 @@ SKIP: { | |||
| 171 | my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts)); | 146 | my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts)); | 
| 172 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_http -C 1 $host_tls_http"); | 147 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_http -C 1 $host_tls_http"); | 
| 173 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' just expired/, "Output on expire date"); | 148 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' just expired/, "Output on expire date"); | 
| 174 | is( $res->return_code, 2, "Output on expire date" ); | ||
| 175 | 149 | ||
| 176 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./check_http -C 1 $host_tls_http"); | 150 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./check_http -C 1 $host_tls_http"); | 
| 177 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 0 minutes/, "cert expires in 1 second output"); | 151 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 0 minutes/, "cert expires in 1 second output"); | 
| 178 | is( $res->return_code, 2, "cert expires in 1 second exit code" ); | ||
| 179 | 152 | ||
| 180 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./check_http -C 1 $host_tls_http"); | 153 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./check_http -C 1 $host_tls_http"); | 
| 181 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 minutes/, "cert expires in 2 minutes output"); | 154 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 minutes/, "cert expires in 2 minutes output"); | 
| 182 | is( $res->return_code, 2, "cert expires in 2 minutes exit code" ); | ||
| 183 | 155 | ||
| 184 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./check_http -C 1 $host_tls_http"); | 156 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./check_http -C 1 $host_tls_http"); | 
| 185 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 hours/, "cert expires in 2 hours output"); | 157 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 hours/, "cert expires in 2 hours output"); | 
| 186 | is( $res->return_code, 2, "cert expires in 2 hours exit code" ); | ||
| 187 | 158 | ||
| 188 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_http -C 1 $host_tls_http"); | 159 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_http -C 1 $host_tls_http"); | 
| 189 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expired on/, "Certificate expired output"); | 160 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expired on/, "Certificate expired output"); | 
| 190 | is( $res->return_code, 2, "Certificate expired exit code" ); | ||
| 191 | }; | 161 | }; | 
| 192 | 162 | ||
| 193 | $res = NPTest->testCmd( "./check_http --ssl $host_tls_http -E" ); | 163 | $res = NPTest->testCmd( "./check_http --ssl $host_tls_http -E" ); | 
| diff --git a/plugins/t/check_imap.t b/plugins/t/check_imap.t index 9c6eae1f..7c74e564 100644 --- a/plugins/t/check_imap.t +++ b/plugins/t/check_imap.t | |||
| @@ -8,17 +8,10 @@ use strict; | |||
| 8 | use Test::More tests => 7; | 8 | use Test::More tests => 7; | 
| 9 | use NPTest; | 9 | use NPTest; | 
| 10 | 10 | ||
| 11 | my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost", | 11 | my $host_tcp_smtp = getTestParameter("NP_HOST_TCP_SMTP", "A host providing an STMP Service (a mail server)", "mailhost"); | 
| 12 | "A host providing an STMP Service (a mail server)"); | 12 | my $host_tcp_imap = getTestParameter("NP_HOST_TCP_IMAP", "A host providing an IMAP Service (a mail server)", $host_tcp_smtp); | 
| 13 | 13 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | |
| 14 | my $host_tcp_imap = getTestParameter( "host_tcp_imap", "NP_HOST_TCP_IMAP", $host_tcp_smtp, | 14 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | 
| 15 | "A host providing an IMAP Service (a mail server)"); | ||
| 16 | |||
| 17 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
| 18 | "The hostname of system not responsive to network requests" ); | ||
| 19 | |||
| 20 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
| 21 | "An invalid (not known to DNS) hostname" ); | ||
| 22 | 15 | ||
| 23 | my $t; | 16 | my $t; | 
| 24 | 17 | ||
| diff --git a/plugins/t/check_jabber.t b/plugins/t/check_jabber.t index 7a708d5b..fcdae179 100644 --- a/plugins/t/check_jabber.t +++ b/plugins/t/check_jabber.t | |||
| @@ -10,23 +10,9 @@ use NPTest; | |||
| 10 | 10 | ||
| 11 | plan tests => 10; | 11 | plan tests => 10; | 
| 12 | 12 | ||
| 13 | my $host_tcp_jabber = getTestParameter( | 13 | my $host_tcp_jabber = getTestParameter("NP_HOST_TCP_JABBER", "A host providing the Jabber Service", "jabber.de"); | 
| 14 | "NP_HOST_TCP_JABBER", | 14 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | 
| 15 | "A host providing the Jabber Service", | 15 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | 
| 16 | "jabber.org" | ||
| 17 | ); | ||
| 18 | |||
| 19 | my $host_nonresponsive = getTestParameter( | ||
| 20 | "NP_HOST_NONRESPONSIVE", | ||
| 21 | "The hostname of system not responsive to network requests", | ||
| 22 | "10.0.0.1", | ||
| 23 | ); | ||
| 24 | |||
| 25 | my $hostname_invalid = getTestParameter( | ||
| 26 | "NP_HOSTNAME_INVALID", | ||
| 27 | "An invalid (not known to DNS) hostname", | ||
| 28 | "nosuchhost", | ||
| 29 | ); | ||
| 30 | 16 | ||
| 31 | 17 | ||
| 32 | my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on '.$host_tcp_jabber.' port 5222/'; | 18 | my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on '.$host_tcp_jabber.' port 5222/'; | 
| diff --git a/plugins/t/check_ldap.t b/plugins/t/check_ldap.t index b8944d4b..b8a4a766 100644 --- a/plugins/t/check_ldap.t +++ b/plugins/t/check_ldap.t | |||
| @@ -9,19 +9,10 @@ use warnings; | |||
| 9 | use Test::More; | 9 | use Test::More; | 
| 10 | use NPTest; | 10 | use NPTest; | 
| 11 | 11 | ||
| 12 | my $host_tcp_ldap = getTestParameter("NP_HOST_TCP_LDAP", | 12 | my $host_tcp_ldap = getTestParameter("NP_HOST_TCP_LDAP", "A host providing the LDAP Service", "localhost"); | 
| 13 | "A host providing the LDAP Service", | 13 | my $ldap_base_dn = getTestParameter("NP_LDAP_BASE_DN", "A base dn for the LDAP Service", "cn=admin"); | 
| 14 | "localhost" ); | 14 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | 
| 15 | 15 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | |
| 16 | my $ldap_base_dn = getTestParameter("NP_LDAP_BASE_DN", | ||
| 17 | "A base dn for the LDAP Service", | ||
| 18 | "cn=admin" ); | ||
| 19 | |||
| 20 | my $host_nonresponsive = getTestParameter("host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
| 21 | "The hostname of system not responsive to network requests" ); | ||
| 22 | |||
| 23 | my $hostname_invalid = getTestParameter("hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
| 24 | "An invalid (not known to DNS) hostname" ); | ||
| 25 | 16 | ||
| 26 | my($result, $cmd); | 17 | my($result, $cmd); | 
| 27 | my $command = './check_ldap'; | 18 | my $command = './check_ldap'; | 
| diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t index 28cd4cd0..e426bf59 100644 --- a/plugins/t/check_mysql.t +++ b/plugins/t/check_mysql.t | |||
| @@ -21,30 +21,11 @@ plan skip_all => "check_mysql not compiled" unless (-x "check_mysql"); | |||
| 21 | plan tests => 15; | 21 | plan tests => 15; | 
| 22 | 22 | ||
| 23 | my $bad_login_output = '/Access denied for user /'; | 23 | my $bad_login_output = '/Access denied for user /'; | 
| 24 | my $mysqlserver = getTestParameter( | 24 | my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup"); | 
| 25 | "NP_MYSQL_SERVER", | 25 | my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup"); | 
| 26 | "A MySQL Server hostname or IP with no slaves setup" | 26 | my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privleges)", "-u test -ptest"); | 
| 27 | ); | 27 | my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup"); | 
| 28 | my $mysqlsocket = getTestParameter( | 28 | my $with_slave_login = getTestParameter("NP_MYSQL_WITH_SLAVE_LOGIN", "Login details for server with slave (requires REPLICATION CLIENT privleges)", $mysql_login_details || "-u test -ptest"); | 
| 29 | "NP_MYSQL_SOCKET", | ||
| 30 | "Full path to a MySQL Server socket with no slaves setup" | ||
| 31 | ); | ||
| 32 | my $mysql_login_details = getTestParameter( | ||
| 33 | "MYSQL_LOGIN_DETAILS", | ||
| 34 | "Command line parameters to specify login access (requires " . | ||
| 35 | "REPLICATION CLIENT privleges)", | ||
| 36 | "-u test -ptest", | ||
| 37 | ); | ||
| 38 | my $with_slave = getTestParameter( | ||
| 39 | "NP_MYSQL_WITH_SLAVE", | ||
| 40 | "MySQL server with slaves setup" | ||
| 41 | ); | ||
| 42 | my $with_slave_login = getTestParameter( | ||
| 43 | "NP_MYSQL_WITH_SLAVE_LOGIN", | ||
| 44 | "Login details for server with slave (requires REPLICATION CLIENT " . | ||
| 45 | "privleges)", | ||
| 46 | $mysql_login_details || "-u test -ptest" | ||
| 47 | ); | ||
| 48 | 29 | ||
| 49 | my $result; | 30 | my $result; | 
| 50 | 31 | ||
| diff --git a/plugins/t/check_mysql_query.t b/plugins/t/check_mysql_query.t index 407af881..96899ac6 100644 --- a/plugins/t/check_mysql_query.t +++ b/plugins/t/check_mysql_query.t | |||
| @@ -17,15 +17,8 @@ use vars qw($tests); | |||
| 17 | 17 | ||
| 18 | plan skip_all => "check_mysql_query not compiled" unless (-x "check_mysql_query"); | 18 | plan skip_all => "check_mysql_query not compiled" unless (-x "check_mysql_query"); | 
| 19 | 19 | ||
| 20 | my $mysqlserver = getTestParameter( | 20 | my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server with no slaves setup"); | 
| 21 | "NP_MYSQL_SERVER", | 21 | my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access", "-u user -ppw -d db"); | 
| 22 | "A MySQL Server with no slaves setup" | ||
| 23 | ); | ||
| 24 | my $mysql_login_details = getTestParameter( | ||
| 25 | "MYSQL_LOGIN_DETAILS", | ||
| 26 | "Command line parameters to specify login access", | ||
| 27 | "-u user -ppw -d db", | ||
| 28 | ); | ||
| 29 | my $result; | 22 | my $result; | 
| 30 | 23 | ||
| 31 | if (! $mysqlserver) { | 24 | if (! $mysqlserver) { | 
| diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t index 9a6cd2bb..f2f218fd 100644 --- a/plugins/t/check_snmp.t +++ b/plugins/t/check_snmp.t | |||
| @@ -15,18 +15,12 @@ BEGIN { | |||
| 15 | 15 | ||
| 16 | my $res; | 16 | my $res; | 
| 17 | 17 | ||
| 18 | my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost", | 18 | my $host_snmp = getTestParameter("NP_HOST_SNMP", "A host providing an SNMP Service", "localhost"); | 
| 19 | "A host providing an SNMP Service"); | 19 | my $snmp_community = getTestParameter("NP_SNMP_COMMUNITY", "The SNMP Community string for SNMP Testing (assumes snmp v1)", "public"); | 
| 20 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | ||
| 21 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | ||
| 22 | my $user_snmp = getTestParameter("NP_SNMP_USER", "An SNMP user", "auth_md5"); | ||
| 20 | 23 | ||
| 21 | my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public", | ||
| 22 | "The SNMP Community string for SNMP Testing (assumes snmp v1)" ); | ||
| 23 | |||
| 24 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
| 25 | "The hostname of system not responsive to network requests" ); | ||
| 26 | |||
| 27 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
| 28 | "An invalid (not known to DNS) hostname" ); | ||
| 29 | my $user_snmp = getTestParameter( "user_snmp", "NP_SNMP_USER", "auth_md5", "An SNMP user"); | ||
| 30 | 24 | ||
| 31 | $res = NPTest->testCmd( "./check_snmp -t 1" ); | 25 | $res = NPTest->testCmd( "./check_snmp -t 1" ); | 
| 32 | is( $res->return_code, 3, "No host name" ); | 26 | is( $res->return_code, 3, "No host name" ); | 
| diff --git a/plugins/t/check_ssh.t b/plugins/t/check_ssh.t index 80083492..a5cd23ce 100644 --- a/plugins/t/check_ssh.t +++ b/plugins/t/check_ssh.t | |||
| @@ -9,17 +9,9 @@ use Test::More; | |||
| 9 | use NPTest; | 9 | use NPTest; | 
| 10 | 10 | ||
| 11 | # Required parameters | 11 | # Required parameters | 
| 12 | my $ssh_host = getTestParameter("NP_SSH_HOST", | 12 | my $ssh_host = getTestParameter("NP_SSH_HOST", "A host providing SSH service", "localhost"); | 
| 13 | "A host providing SSH service", | 13 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1" ); | 
| 14 | "localhost"); | 14 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost" ); | 
| 15 | |||
| 16 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", | ||
| 17 | "The hostname of system not responsive to network requests", | ||
| 18 | "10.0.0.1" ); | ||
| 19 | |||
| 20 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", | ||
| 21 | "An invalid (not known to DNS) hostname", | ||
| 22 | "nosuchhost" ); | ||
| 23 | 15 | ||
| 24 | 16 | ||
| 25 | plan skip_all => "SSH_HOST must be defined" unless $ssh_host; | 17 | plan skip_all => "SSH_HOST must be defined" unless $ssh_host; | 
| diff --git a/plugins/t/check_tcp.t b/plugins/t/check_tcp.t index 121b0cb3..cb4de53d 100644 --- a/plugins/t/check_tcp.t +++ b/plugins/t/check_tcp.t | |||
| @@ -15,21 +15,11 @@ BEGIN { | |||
| 15 | } | 15 | } | 
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost", | 18 | my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost"); | 
| 19 | "A host providing the HTTP Service (a web server)" ); | 19 | my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost"); | 
| 20 | 20 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | |
| 21 | my $host_tls_http = getTestParameter( "host_tls_http", "NP_HOST_TLS_HTTP", "localhost", | 21 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | 
| 22 | "A host providing the HTTPS Service (a tls web server)" ); | 22 | my $internet_access = getTestParameter("NP_INTERNET_ACCESS", "Is this system directly connected to the internet?", "yes"); | 
| 23 | |||
| 24 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
| 25 | "The hostname of system not responsive to network requests" ); | ||
| 26 | |||
| 27 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
| 28 | "An invalid (not known to DNS) hostname" ); | ||
| 29 | |||
| 30 | my $internet_access = getTestParameter( "NP_INTERNET_ACCESS", | ||
| 31 | "Is this system directly connected to the internet?", | ||
| 32 | "yes"); | ||
| 33 | 23 | ||
| 34 | my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/'; | 24 | my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/'; | 
| 35 | 25 | ||
| diff --git a/plugins/t/check_time.t b/plugins/t/check_time.t index 961f56e6..92c2f891 100644 --- a/plugins/t/check_time.t +++ b/plugins/t/check_time.t | |||
| @@ -11,14 +11,9 @@ use NPTest; | |||
| 11 | use vars qw($tests); | 11 | use vars qw($tests); | 
| 12 | BEGIN {$tests = 8; plan tests => $tests} | 12 | BEGIN {$tests = 8; plan tests => $tests} | 
| 13 | 13 | ||
| 14 | my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost", | 14 | my $host_udp_time = getTestParameter("NP_HOST_UDP_TIME", "A host providing the UDP Time Service", "localhost"); | 
| 15 | "A host providing the UDP Time Service" ); | 15 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | 
| 16 | 16 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | |
| 17 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
| 18 | "The hostname of system not responsive to network requests" ); | ||
| 19 | |||
| 20 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
| 21 | "An invalid (not known to DNS) hostname" ); | ||
| 22 | 17 | ||
| 23 | my $successOutput = '/^TIME OK - [0-9]+ second time difference/'; | 18 | my $successOutput = '/^TIME OK - [0-9]+ second time difference/'; | 
| 24 | 19 | ||
