Imported Upstream version 2.1
This commit is contained in:
parent
0841b5c7c7
commit
060ec72678
47 changed files with 1718 additions and 1420 deletions
|
@ -34,7 +34,7 @@ sub print_help ();
|
|||
sub print_usage ();
|
||||
|
||||
my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V, $opt_i);
|
||||
my ($result, $message, $age, $size, $st);
|
||||
my ($result, $message, $age, $size, $st, $perfdata);
|
||||
|
||||
$PROGNAME="check_file_age";
|
||||
|
||||
|
@ -92,6 +92,7 @@ unless (-e $opt_f) {
|
|||
$st = File::stat::stat($opt_f);
|
||||
$age = time - $st->mtime;
|
||||
$size = $st->size;
|
||||
$perfdata = "age=${age}s;${opt_w};${opt_c} size=${size}B;${opt_W};${opt_C};0";
|
||||
|
||||
|
||||
$result = 'OK';
|
||||
|
@ -103,7 +104,7 @@ elsif (($opt_w and $age > $opt_w) or ($opt_W and $size < $opt_W)) {
|
|||
$result = 'WARNING';
|
||||
}
|
||||
|
||||
print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes\n";
|
||||
print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes | $perfdata\n";
|
||||
exit $ERRORS{$result};
|
||||
|
||||
sub print_usage () {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
# Added -u option (4/2003)
|
||||
# Added -M option (10/2003)
|
||||
# Added SNMPv3 support (10/2003)
|
||||
# Added -n option (07/2014)
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -95,8 +96,10 @@ my $ifXTable;
|
|||
my $opt_h ;
|
||||
my $opt_V ;
|
||||
my $opt_u;
|
||||
my $opt_n;
|
||||
my $opt_x ;
|
||||
my %excluded ;
|
||||
my %unused_names ;
|
||||
my @unused_ports ;
|
||||
my %session_opts;
|
||||
|
||||
|
@ -171,27 +174,30 @@ alarm(0);
|
|||
foreach $key (keys %ifStatus) {
|
||||
|
||||
# skip unused interfaces
|
||||
if (!defined($ifStatus{$key}{'notInUse'})) {
|
||||
my $ifName = $ifStatus{$key}{$snmpIfDescr};
|
||||
|
||||
if (!defined($ifStatus{$key}{'notInUse'}) && !grep(/^${ifName}/, @unused_ports )) {
|
||||
# check only if interface is administratively up
|
||||
if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) {
|
||||
|
||||
# check only if interface type is not listed in %excluded
|
||||
if (!defined $excluded{$ifStatus{$key}{$snmpIfType}} ) {
|
||||
if ($ifStatus{$key}{$snmpIfOperStatus} == 1 ) { $ifup++ ;}
|
||||
if ($ifStatus{$key}{$snmpIfOperStatus} == 2 ) {
|
||||
$ifdown++ ;
|
||||
if (defined $ifXTable) {
|
||||
$ifmessage .= sprintf("%s: down -> %s<BR>",
|
||||
$ifStatus{$key}{$snmpIfName},
|
||||
$ifStatus{$key}{$snmpIfAlias});
|
||||
}else{
|
||||
$ifmessage .= sprintf("%s: down <BR>",
|
||||
$ifStatus{$key}{$snmpIfDescr});
|
||||
}
|
||||
if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) {
|
||||
#check only if interface is not excluded
|
||||
if (!defined $unused_names{$ifStatus{$key}{$snmpIfDescr}} ) {
|
||||
# check only if interface type is not listed in %excluded
|
||||
if (!defined $excluded{$ifStatus{$key}{$snmpIfType}} ) {
|
||||
if ($ifStatus{$key}{$snmpIfOperStatus} == 1 ) { $ifup++ ; }
|
||||
if ($ifStatus{$key}{$snmpIfOperStatus} == 2 ) {
|
||||
$ifdown++ ;
|
||||
if (defined $ifXTable) {
|
||||
$ifmessage .= sprintf("%s: down -> %s<BR>\n", $ifStatus{$key}{$snmpIfName}, $ifStatus{$key}{$snmpIfAlias});
|
||||
}else{
|
||||
$ifmessage .= sprintf("%s: down <BR>\n",$ifStatus{$key}{$snmpIfDescr});
|
||||
}
|
||||
}
|
||||
if ($ifStatus{$key}{$snmpIfOperStatus} == 5 ) { $ifdormant++ ;}
|
||||
} else {
|
||||
$ifexclude++;
|
||||
}
|
||||
if ($ifStatus{$key}{$snmpIfOperStatus} == 5 ) { $ifdormant++ ;}
|
||||
}else{
|
||||
$ifexclude++;
|
||||
} else {
|
||||
$ifunused++;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -221,7 +227,7 @@ foreach $key (keys %ifStatus) {
|
|||
$ifexclude,
|
||||
$ifunused);
|
||||
}
|
||||
my $perfdata = sprintf("up=%d,down=%d,dormant=%d,excluded=%d,unused=%d",$ifup,$ifdown,$ifdormant,$ifexclude,$ifunused);
|
||||
my $perfdata = sprintf("up=%d down=%d dormant=%d excluded=%d unused=%d",$ifup,$ifdown,$ifdormant,$ifexclude,$ifunused);
|
||||
print ("$state: $answer |$perfdata\n");
|
||||
exit $ERRORS{$state};
|
||||
|
||||
|
@ -259,6 +265,8 @@ sub print_help() {
|
|||
printf " the descriptive name. Do not use if you don't know what this is. \n";
|
||||
printf " -x (--exclude) A comma separated list of ifType values that should be excluded \n";
|
||||
printf " from the report (default for an empty list is PPP(23).\n";
|
||||
printf " -n (--unused_ports_by_name) A comma separated list of ifDescr values that should be excluded \n";
|
||||
printf " from the report (default is an empty exclusion list).\n";
|
||||
printf " -u (--unused_ports) A comma separated list of ifIndex values that should be excluded \n";
|
||||
printf " from the report (default is an empty exclusion list).\n";
|
||||
printf " See the IANAifType-MIB for a list of interface types.\n";
|
||||
|
@ -299,6 +307,7 @@ sub process_arguments() {
|
|||
"I" => \$ifXTable, "ifmib" => \$ifXTable,
|
||||
"x:s" => \$opt_x, "exclude:s" => \$opt_x,
|
||||
"u=s" => \$opt_u, "unused_ports=s" => \$opt_u,
|
||||
"n=s" => \$opt_n, "unused_ports_by_name=s" => \$opt_n,
|
||||
"M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize,
|
||||
"t=i" => \$timeout, "timeout=i" => \$timeout,
|
||||
);
|
||||
|
@ -406,6 +415,16 @@ sub process_arguments() {
|
|||
}
|
||||
}
|
||||
|
||||
# Excluded interface descriptors
|
||||
if (defined $opt_n) {
|
||||
my @unused = split(/,/,$opt_n);
|
||||
if ( @unused ) {
|
||||
foreach $key (@unused) {
|
||||
$unused_names{$key} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Excluded interface ports (ifIndex) - management reasons
|
||||
if ($opt_u) {
|
||||
@unused_ports = split(/,/,$opt_u);
|
||||
|
|
|
@ -58,12 +58,11 @@
|
|||
# Paths to commands used in this script. These
|
||||
# may have to be modified to match your system setup.
|
||||
|
||||
PROGNAME=`/bin/basename $0`
|
||||
PATH="@TRUSTED_PATH@"
|
||||
export PATH
|
||||
PROGNAME=`basename $0`
|
||||
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
|
||||
REVISION="@NP_VERSION@"
|
||||
PATH="@TRUSTED_PATH@"
|
||||
|
||||
export PATH
|
||||
|
||||
. $PROGPATH/utils.sh
|
||||
|
||||
|
|
|
@ -332,7 +332,7 @@ elsif ( $mailq eq "postfix" ) {
|
|||
}elsif ($lines[0]=~/Mail queue is empty/) {
|
||||
$msg_q = 0;
|
||||
}else{
|
||||
print "Couldn't match $utils::PATH_TO_QMAIL_QSTAT output\n";
|
||||
print "Couldn't match $utils::PATH_TO_MAILQ output\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
|
@ -340,7 +340,7 @@ elsif ( $mailq eq "postfix" ) {
|
|||
#if ($lines[1]=~/^messages in queue but not yet preprocessed: (\d+)/) {
|
||||
# my $msg_p = $1;
|
||||
#}else{
|
||||
# print "Couldn't match $utils::PATH_TO_QMAIL_QSTAT output\n";
|
||||
# print "Couldn't match $utils::PATH_TO_MAILQ output\n";
|
||||
# exit $ERRORS{'UNKNOWN'};
|
||||
#}
|
||||
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
# This Monitoring plugin was created to check Oracle status
|
||||
#
|
||||
|
||||
PATH="@TRUSTED_PATH@"
|
||||
export PATH
|
||||
PROGNAME=`basename $0`
|
||||
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
|
||||
REVISION="@NP_VERSION@"
|
||||
PATH="@TRUSTED_PATH@"
|
||||
|
||||
. $PROGPATH/utils.sh
|
||||
|
||||
|
@ -137,7 +138,7 @@ case "$cmd" in
|
|||
tnschk=` tnsping $2`
|
||||
tnschk2=` echo $tnschk | grep -c OK`
|
||||
if [ ${tnschk2} -eq 1 ] ; then
|
||||
tnschk3=` echo $tnschk | sed -e 's/.*(//' -e 's/).*//'`
|
||||
tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*}
|
||||
echo "OK - reply time ${tnschk3} from $2"
|
||||
exit $STATE_OK
|
||||
else
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
PATH="@TRUSTED_PATH@"
|
||||
export PATH
|
||||
PROGNAME=`basename $0`
|
||||
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
|
||||
REVISION="@NP_VERSION@"
|
||||
PATH="@TRUSTED_PATH@"
|
||||
|
||||
export PATH
|
||||
|
||||
. $PROGPATH/utils.sh
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ SKIP: {
|
|||
SKIP: {
|
||||
skip "no non responsive host defined", 1 if ( ! $host_nonresponsive );
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_nonresponsive -s np_foobar ");
|
||||
cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" );
|
||||
cmp_ok( $res->return_code, '>=', 2, "Exit CRITICAL/UNKNOWN with non responsive host" );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,13 +5,14 @@
|
|||
#
|
||||
|
||||
use strict;
|
||||
use Test::More tests => 16;
|
||||
use Test::More tests => 17;
|
||||
use NPTest;
|
||||
|
||||
my $successOutput = '/^FILE_AGE OK: /';
|
||||
my $warningOutput = '/^FILE_AGE WARNING: /';
|
||||
my $criticalOutput = '/^FILE_AGE CRITICAL: /';
|
||||
my $unknownOutput = '/^FILE_AGE UNKNOWN: /';
|
||||
my $performanceOutput = '/ \| age=[0-9]+s;[0-9]+;[0-9]+ size=[0-9]+B;[0-9]+;[0-9]+;0$/';
|
||||
|
||||
my $result;
|
||||
my $temp_file = "/tmp/check_file_age.tmp";
|
||||
|
@ -57,6 +58,11 @@ $result = NPTest->testCmd(
|
|||
);
|
||||
cmp_ok( $result->return_code, '==', 0, "Checking file size" );
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_file_age -f $temp_file -c 1000 -W 100"
|
||||
);
|
||||
like( $result->output, $performanceOutput, "Checking for performance Output" );
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_file_age -f /non/existent --ignore-missing"
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue