Imported Upstream version 1.4.16+git20130919

This commit is contained in:
Jan Wagner 2013-11-27 00:00:57 +01:00
parent 01ca3b324f
commit 57371046fd
50 changed files with 3885 additions and 500 deletions

View file

@ -263,11 +263,11 @@ main (int argc, char **argv)
} else if (fs_include_list && !np_find_name (fs_include_list, me->me_type)) {
continue;
}
stat_path(path);
get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
}
stat_path(path);
get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
if (fsp.fsu_blocks && strcmp ("none", me->me_mountdir)) {
get_stats (path, &fsp);

View file

@ -177,8 +177,10 @@ textscan (char *buf)
{
char *rtastr = NULL;
char *losstr = NULL;
char *xmtstr = NULL;
double loss;
double rta;
double xmt;
int status = STATE_UNKNOWN;
if (strstr (buf, "not found")) {
@ -230,7 +232,12 @@ textscan (char *buf)
}
else if(strstr (buf, "xmt/rcv/%loss") ) {
/* no min/max/avg if host was unreachable in fping v2.2.b1 */
/* in v2.4b2: 10.99.0.1 : xmt/rcv/%loss = 0/0/0% */
losstr = strstr (buf, "=");
xmtstr = 1 + losstr;
xmt = strtod (xmtstr, NULL);
if(xmt == 0)
die (STATE_CRITICAL, _("FPING CRITICAL - %s is down\n"), server_name);
losstr = 1 + strstr (losstr, "/");
losstr = 1 + strstr (losstr, "/");
loss = strtod (losstr, NULL);

View file

@ -153,7 +153,16 @@ main (int argc, char **argv)
printf (_("Could not open stderr for %s\n"), PATH_TO_UPTIME);
}
fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process);
sscanf (input_buffer, "%*[^l]load average: %lf, %lf, %lf", &la1, &la5, &la15);
if(strstr(input_buffer, "load average:")) {
sscanf (input_buffer, "%*[^l]load average: %lf, %lf, %lf", &la1, &la5, &la15);
}
else if(strstr(input_buffer, "load averages:")) {
sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15);
}
else {
printf (_("could not parse load from uptime: %s\n"), result, PATH_TO_UPTIME);
return STATE_UNKNOWN;
}
result = spclose (child_process);
if (result) {

View file

@ -258,7 +258,7 @@ main (int argc, char **argv)
if (verbose)
printf("Closing connection\n");
PQfinish (conn);
return (query_status > status) ? query_status : status;
return (pgquery && query_status > status) ? query_status : status;
}

View file

@ -39,6 +39,8 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
#include "utils.h"
#include "utils_tcp.h"
#include <sys/select.h>
#ifdef HAVE_SSL
static int check_cert = FALSE;
static int days_till_exp_warn, days_till_exp_crit;
@ -60,6 +62,7 @@ static char *SEND = NULL;
static char *QUIT = NULL;
static int PROTOCOL = IPPROTO_TCP; /* most common is default */
static int PORT = 0;
static int READ_TIMEOUT = 2;
static int server_port = 0;
static char *server_address = NULL;
@ -98,8 +101,12 @@ main (int argc, char **argv)
int i;
char *status = NULL;
struct timeval tv;
struct timeval timeout;
size_t len;
int match = -1;
fd_set rfds;
FD_ZERO(&rfds);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
@ -288,6 +295,13 @@ main (int argc, char **argv)
server_expect_count,
match_flags)) != NP_MATCH_RETRY)
break;
/* some protocols wait for further input, so make sure we don't wait forever */
FD_SET(sd, &rfds);
timeout.tv_sec = READ_TIMEOUT;
timeout.tv_usec = 0;
if(select(sd + 1, &rfds, NULL, NULL, &timeout) <= 0)
break;
}
if (match == NP_MATCH_RETRY)
match = NP_MATCH_FAILURE;

View file

@ -44,6 +44,10 @@ for (@responce) {
my $result;
# expand paths
$ssh_key = glob($ssh_key) if $ssh_key;
$ssh_conf = glob($ssh_conf) if $ssh_conf;
## Single active checks
for (my $i=0; $i<4; $i++) {

View file

@ -6,11 +6,16 @@
use strict;
use Test::More;
use NPTest;
plan skip_all => "check_dig not compiled" unless (-x "check_dig");
plan tests => 16;
use vars qw($tests $has_ipv6);
BEGIN {
plan skip_all => "check_dig not compiled" unless (-x "check_dig");
use NPTest;
$has_ipv6 = NPTest::has_ipv6();
$tests = $has_ipv6 ? 16 : 14;
plan tests => $tests;
}
my $successOutput = '/DNS OK - [\.0-9]+ seconds? response time/';
@ -73,10 +78,6 @@ SKIP: {
cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server");
like ( $res->output, $successOutput, "Output OK for IPv4" );
$res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -t 5 -6");
cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server");
like ( $res->output, $successOutput, "Output OK for IPv6" );
$res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -a $hostname_valid_ip -t 5");
cmp_ok( $res->return_code, '==', 0, "Got expected address");
@ -89,4 +90,9 @@ SKIP: {
cmp_ok( $res->return_code, '==', 0, "Got expected fqdn");
like ( $res->output, $successOutput, "Output OK");
if($has_ipv6) {
$res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -t 5 -6");
cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server");
like ( $res->output, $successOutput, "Output OK for IPv6" );
}
}

View file

@ -57,6 +57,9 @@ if ($free_on_mp1 > $free_on_mp2) {
} else {
die "Two mountpoints are the same - cannot do rest of test";
}
if($free_on_mp1 == $avg_free || $free_on_mp2 == $avg_free) {
die "One mountpoints has average space free - cannot do rest of test";
}
# Do same for inodes
@ -74,6 +77,9 @@ if ($free_inode_on_mp1 > $free_inode_on_mp2) {
} else {
die "Two mountpoints with same inodes free - cannot do rest of test";
}
if($free_inode_on_mp1 == $avg_inode_free || $free_inode_on_mp2 == $avg_inode_free) {
die "One mountpoints has average inodes free - cannot do rest of test";
}
# Verify performance data
# First check absolute thresholds...

View file

@ -30,12 +30,9 @@ my $internet_access = getTestParameter( "NP_INTERNET_ACCESS",
"Is this system directly connected to the internet?",
"yes");
my $host_tcp_http2;
if ($internet_access eq "no") {
$host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2",
my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2",
"A host providing an index page containing the string 'nagios'",
"www.nagios.com" );
}
"nagiosplugins.org" );
$res = NPTest->testCmd(
@ -65,10 +62,7 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK");
SKIP: {
skip "No internet access and no host serving nagios in index file",
7 if $internet_access eq "no" && ! $host_tcp_http2;
$host_tcp_http2 = "www.nagios.com" if (! $host_tcp_http2);
skip "No host serving nagios in index file", 7 unless $host_tcp_http2;
$res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nagios'" );
cmp_ok( $res->return_code, "==", 0, "Got a reference to 'nagios'");

View file

@ -90,7 +90,7 @@ like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet los
$res = NPTest->testCmd(
"./check_ping $host_nonresponsive -p 1 -t 1 100 100 1000 10000"
"./check_ping $host_nonresponsive -p 1 -t 15 100 100 1000 10000"
);
is( $res->return_code, 2, "Old syntax: Timeout - host nonresponsive" );
like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" );

View file

@ -34,7 +34,7 @@ $result = NPTest->testCmd( "./check_procs -w 0 -c 0" );
is( $result->return_code, 2, "Checking critical if processes > 0" );
like( $result->output, '/^PROCS CRITICAL: [0-9]+ process(es)? | procs=[0-9]+;0;0;0;$/', "Output correct" );
$result = NPTest->testCmd( "./check_procs -w 0 -c 0 -s S" );
$result = NPTest->testCmd( "./check_procs -w 0 -c 0 -s Ss" );
is( $result->return_code, 2, "Checking critical if sleeping processes" );
like( $result->output, '/^PROCS CRITICAL: [0-9]+ process(es)? with /', "Output correct" );

49
plugins/t/check_ssh.t Normal file
View file

@ -0,0 +1,49 @@
#! /usr/bin/perl -w -I ..
#
# check_ssh tests
#
#
use strict;
use Test::More;
use NPTest;
# Required parameters
my $ssh_host = getTestParameter("NP_SSH_HOST",
"A host providing SSH service",
"localhost");
my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE",
"The hostname of system not responsive to network requests",
"10.0.0.1" );
my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID",
"An invalid (not known to DNS) hostname",
"nosuchhost" );
plan skip_all => "SSH_HOST must be defined" unless $ssh_host;
plan tests => 6;
my $result = NPTest->testCmd(
"./check_ssh -H $ssh_host"
);
cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)");
like($result->output, '/^SSH OK - /', "Status text if command returned none (OK)");
$result = NPTest->testCmd(
"./check_ssh -H $host_nonresponsive -t 2"
);
cmp_ok($result->return_code, '==', 2, "Exit with return code 0 (OK)");
like($result->output, '/^CRITICAL - Socket timeout after 2 seconds/', "Status text if command returned none (OK)");
$result = NPTest->testCmd(
"./check_ssh -H $hostname_invalid -t 2"
);
cmp_ok($result->return_code, '==', 3, "Exit with return code 0 (OK)");
like($result->output, '/^check_ssh: Invalid hostname/', "Status text if command returned none (OK)");

View file

@ -6,19 +6,13 @@
use strict;
use Test;
use NPTest;
use vars qw($tests);
my $has_ipv6;
use vars qw($tests $has_ipv6);
BEGIN {
$tests = 11;
# do we have ipv6
`ping6 -c 1 2a02:2e0:3fe:100::7 2>&1`;
if($? == 0) {
$has_ipv6 = 1;
$tests += 3;
}
plan tests => $tests;
use NPTest;
$has_ipv6 = NPTest::has_ipv6();
$tests = $has_ipv6 ? 14 : 11;
plan tests => $tests;
}

View file

@ -10,6 +10,8 @@ use NPTest;
my $res;
alarm(120); # make sure tests don't hang
plan tests => 14;
$res = NPTest->testCmd( "./check_udp -H localhost -p 3333" );
@ -28,9 +30,21 @@ $res = NPTest->testCmd( "./check_udp -H localhost -p 3333 -s foo -e bar" );
cmp_ok( $res->return_code, '==', 2, "Errors correctly because no udp service running" );
like ( $res->output, '/No data received from host/', "Output OK");
my $nc;
if(system("which nc.traditional >/dev/null 2>&1") == 0) {
$nc = 'nc.traditional -w 3 -l -u -p 3333';
}
elsif(system("which netcat >/dev/null 2>&1") == 0) {
$nc = 'netcat -w 3 -l -u -p 3333';
}
elsif(system("which nc >/dev/null 2>&1") == 0) {
$nc = 'nc -w 3 -l -u -4 localhost 3333';
}
SKIP: {
skip "No netcat available", 6 unless (system("which nc > /dev/null") == 0);
open (NC, "echo 'barbar' | nc -l -p 3333 -u |");
skip "solaris netcat does not listen to udp", 6 if $^O eq 'solaris';
skip "No netcat available", 6 unless $nc;
open (NC, "echo 'barbar' | $nc |");
sleep 1;
$res = NPTest->testCmd( "./check_udp -H localhost -p 3333 -s '' -e barbar -4" );
cmp_ok( $res->return_code, '==', 0, "Got barbar response back" );
@ -39,7 +53,7 @@ SKIP: {
# Start up a udp server listening on port 3333, quit after 3 seconds
# Otherwise will hang at close
my $pid = open(NC, "nc -l -p 3333 -u -w 3 </dev/null |");
my $pid = open(NC, "$nc </dev/null |");
sleep 1; # Allow nc to startup
my $start = time;
@ -53,3 +67,5 @@ SKIP: {
cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" );
}
alarm(0); # disable alarm