From c255656a4c80514dc649e0521dfd64ca923329ce Mon Sep 17 00:00:00 2001 From: Lorenz <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 21 Jan 2022 15:12:35 +0100 Subject: Rebase to master (#1731) --- plugins-scripts/check_mailq.pl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl index 3914f4a7..8cc3d0f6 100755 --- a/plugins-scripts/check_mailq.pl +++ b/plugins-scripts/check_mailq.pl @@ -567,12 +567,14 @@ exit $state; sub process_arguments(){ GetOptions - ("V" => \$opt_V, "version" => \$opt_V, - "v" => \$opt_v, "verbose" => \$opt_v, - "h" => \$opt_h, "help" => \$opt_h, + ("V" => \$opt_V, "version" => \$opt_V, + "v" => \$opt_v, "verbose" => \$opt_v, + "h" => \$opt_h, "help" => \$opt_h, "M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail) "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number - "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number + "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number + "W=i" => \$opt_W, "warning-domain=i" => \$opt_W, # Warning if above this number + "C=i" => \$opt_C, "critical-domain=i" => \$opt_C, # Critical if above this number "t=i" => \$opt_t, "timeout=i" => \$opt_t, "s" => \$opt_s, "sudo" => \$opt_s, "d:s" => \$opt_d, "configdir:s" => \$opt_d, @@ -671,15 +673,15 @@ sub print_help () { print " Feedback/patches to support non-sendmail mailqueue welcome\n\n"; print "-w (--warning) = Min. number of messages in queue to generate warning\n"; print "-c (--critical) = Min. number of messages in queue to generate critical alert ( w < c )\n"; - print "-W = Min. number of messages for same domain in queue to generate warning\n"; - print "-C = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; + print "-W (--warning-domain) = Min. number of messages for same domain in queue to generate warning\n"; + print "-C (--critical-domain) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n"; print "-s (--sudo) = Use sudo to call the mailq command\n"; print "-d (--configdir) = Config file or directory\n"; print "-h (--help)\n"; print "-V (--version)\n"; - print "-v (--verbose) = debugging output\n"; + print "-v (--verbose) = debugging output\n"; print "\n\n"; print "Note: -w and -c are required arguments. -W and -C are optional.\n"; print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n"; -- cgit v1.2.3-74-g34f1 From c99a166a43fb9da42ba68073224921124a435aab Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Sat, 12 Feb 2022 14:41:54 +0100 Subject: check_uptime: Add option to report uptime in days instead of seconds Currently, the plugin output is: CRITICAL: Uptime is 38829029 seconds. When using the proposed `--days|-d` option, it will be: CRITICAL: Uptime is 449 days. --- plugins-scripts/check_uptime.pl | 17 +++++++++++++++-- plugins-scripts/t/check_uptime.t | 8 +++++++- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_uptime.pl b/plugins-scripts/check_uptime.pl index 4c9f22da..04324b2e 100755 --- a/plugins-scripts/check_uptime.pl +++ b/plugins-scripts/check_uptime.pl @@ -25,7 +25,7 @@ use POSIX; use strict; use Getopt::Long; use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c - $opt_f $opt_s + $opt_f $opt_s $opt_d $lower_warn_threshold $upper_warn_threshold $lower_crit_threshold $upper_crit_threshold $status $state $msg); @@ -137,9 +137,20 @@ if ( $uptime_seconds > $upper_crit_threshold ) { $state_str = "OK"; } +# Prepare uptime value (seconds or days) +my $uptime_text = ""; +my $uptime_unit = ""; +if ( $opt_d ) { + $uptime_text = floor($uptime_seconds / 60 / 60 / 24); + $uptime_unit = "days"; +} else { + $uptime_text = $uptime_seconds; + $uptime_unit = "seconds"; +} + $msg = "$state_str: "; -$msg .= "uptime is $uptime_seconds seconds. "; +$msg .= "uptime is $uptime_text $uptime_unit. "; $msg .= "Exceeds $out_of_bounds_text threshold. " if $out_of_bounds_text; $msg .= "Running for $pretty_uptime. " if $opt_f; if ( $opt_s ) { @@ -167,6 +178,7 @@ sub process_arguments(){ "c=s" => \$opt_c, "critical=s" => \$opt_c, # critical if above this number "f" => \$opt_f, "for" => \$opt_f, # show "running for ..." "s" => \$opt_s, "since" => \$opt_s, # show "running since ..." + "d" => \$opt_d, "days" => \$opt_d, # report uptime in days ); if ($opt_V) { @@ -262,6 +274,7 @@ sub print_help () { print "-c (--critical) = Min. number of uptime to generate critical alert ( w < c )\n"; print "-f (--for) = Show uptime in a pretty format (Running for x weeks, x days, ...)\n"; print "-s (--since) = Show last boot in yyyy-mm-dd HH:MM:SS format (output from 'uptime -s')\n"; + print "-d (--days) = Show uptime in days\n"; print "-h (--help)\n"; print "-V (--version)\n"; print "-v (--verbose) = debugging output\n"; diff --git a/plugins-scripts/t/check_uptime.t b/plugins-scripts/t/check_uptime.t index c395307c..b31d0c6c 100644 --- a/plugins-scripts/t/check_uptime.t +++ b/plugins-scripts/t/check_uptime.t @@ -5,7 +5,7 @@ # use strict; -use Test::More tests => 40; +use Test::More tests => 42; use NPTest; my $result; @@ -45,6 +45,12 @@ $result = NPTest->testCmd( cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" ); like ( $result->output, '/Running since \d+/', "Output for the s parameter correct" ); +$result = NPTest->testCmd( + "./check_uptime -d -w 1 -c 2" + ); +cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" ); +like ( $result->output, '/CRITICAL: uptime is \d+ days/', "Output for the d parameter correct" ); + $result = NPTest->testCmd( "./check_uptime -w 1 -c 2" ); -- cgit v1.2.3-74-g34f1 From 6c8b45a1691f4ce98f1c559a1e9cd1fef68c0fe2 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Tue, 15 Feb 2022 01:39:21 +0100 Subject: check_uptime: Fix lowercase typo in plugin output --- plugins-scripts/check_uptime.pl | 2 +- plugins-scripts/t/check_uptime.t | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_uptime.pl b/plugins-scripts/check_uptime.pl index 04324b2e..f9542872 100755 --- a/plugins-scripts/check_uptime.pl +++ b/plugins-scripts/check_uptime.pl @@ -150,7 +150,7 @@ if ( $opt_d ) { $msg = "$state_str: "; -$msg .= "uptime is $uptime_text $uptime_unit. "; +$msg .= "Uptime is $uptime_text $uptime_unit. "; $msg .= "Exceeds $out_of_bounds_text threshold. " if $out_of_bounds_text; $msg .= "Running for $pretty_uptime. " if $opt_f; if ( $opt_s ) { diff --git a/plugins-scripts/t/check_uptime.t b/plugins-scripts/t/check_uptime.t index b31d0c6c..6e81db3c 100644 --- a/plugins-scripts/t/check_uptime.t +++ b/plugins-scripts/t/check_uptime.t @@ -49,32 +49,32 @@ $result = NPTest->testCmd( "./check_uptime -d -w 1 -c 2" ); cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" ); -like ( $result->output, '/CRITICAL: uptime is \d+ days/', "Output for the d parameter correct" ); +like ( $result->output, '/CRITICAL: Uptime is \d+ days/', "Output for the d parameter correct" ); $result = NPTest->testCmd( "./check_uptime -w 1 -c 2" ); cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" ); -like ( $result->output, '/^CRITICAL: uptime is \d+ seconds/', "Output for uptime higher than 2 seconds correct" ); +like ( $result->output, '/^CRITICAL: Uptime is \d+ seconds/', "Output for uptime higher than 2 seconds correct" ); $result = NPTest->testCmd( "./check_uptime -w 1 -c 9999w" ); cmp_ok( $result->return_code, '==', 1, "Uptime lower than 9999 weeks" ); -like ( $result->output, '/^WARNING: uptime is \d+ seconds/', "Output for uptime lower than 9999 weeks correct" ); +like ( $result->output, '/^WARNING: Uptime is \d+ seconds/', "Output for uptime lower than 9999 weeks correct" ); $result = NPTest->testCmd( "./check_uptime -w 9998w -c 9999w" ); cmp_ok( $result->return_code, '==', 0, "Uptime lower than 9998 weeks" ); -like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 9998 weeks correct" ); +like ( $result->output, '/^OK: Uptime is \d+ seconds/', "Output for uptime lower than 9998 weeks correct" ); like ( $result->output, '/\|uptime=[0-9]+s;6046790400;6047395200;/', "Checking for performance output" ); $result = NPTest->testCmd( "./check_uptime -w 111222d -c 222333d" ); cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days" ); -like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 111222 days correct" ); +like ( $result->output, '/^OK: Uptime is \d+ seconds/', "Output for uptime lower than 111222 days correct" ); like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); # Same as before, hopefully uptime is higher than 2 seconds so no warning @@ -82,7 +82,7 @@ $result = NPTest->testCmd( "./check_uptime -w 2:111222d -c 1:222333d" ); cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days, and higher 2 seconds" ); -like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 111222 days, and higher 2 seconds correct" ); +like ( $result->output, '/^OK: Uptime is \d+ seconds/', "Output for uptime lower than 111222 days, and higher 2 seconds correct" ); like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); # Same as before, now the low warning should trigger @@ -90,7 +90,7 @@ $result = NPTest->testCmd( "./check_uptime -w 111221d:111222d -c 1:222333d" ); cmp_ok( $result->return_code, '==', 1, "Uptime lower than 111221 days raises warning" ); -like ( $result->output, '/^WARNING: uptime is \d+ seconds/', "Output for uptime lower than 111221 days correct" ); +like ( $result->output, '/^WARNING: Uptime is \d+ seconds/', "Output for uptime lower than 111221 days correct" ); like ( $result->output, '/Exceeds lower warn threshold/', "Exceeds text correct" ); like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); @@ -99,7 +99,7 @@ $result = NPTest->testCmd( "./check_uptime -w 111221d:111222d -c 111220d:222333d" ); cmp_ok( $result->return_code, '==', 2, "Uptime lower than 111220 days raises critical" ); -like ( $result->output, '/^CRITICAL: uptime is \d+ seconds/', "Output for uptime lower than 111220 days correct" ); +like ( $result->output, '/^CRITICAL: Uptime is \d+ seconds/', "Output for uptime lower than 111220 days correct" ); like ( $result->output, '/Exceeds lower crit threshold/', "Exceeds text correct" ); like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); -- cgit v1.2.3-74-g34f1 From 9a659f46ffb5b183f91879b08bad7822548ae662 Mon Sep 17 00:00:00 2001 From: Claudio Kuenzler Date: Thu, 17 Mar 2022 10:01:50 +0100 Subject: Add configfile feature to check_disk_smb (#1402) --- plugins-scripts/check_disk_smb.pl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl index 28c49e84..ad71e6a2 100755 --- a/plugins-scripts/check_disk_smb.pl +++ b/plugins-scripts/check_disk_smb.pl @@ -22,7 +22,7 @@ require 5.004; use POSIX qw(setsid); use strict; use Getopt::Long; -use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $verbose); +use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $opt_C $verbose); use vars qw($PROGNAME); use FindBin; use lib "$FindBin::Bin"; @@ -53,7 +53,8 @@ GetOptions "s=s" => \$opt_s, "share=s" => \$opt_s, "W=s" => \$opt_W, "workgroup=s" => \$opt_W, "H=s" => \$opt_H, "hostname=s" => \$opt_H, - "a=s" => \$opt_a, "address=s" => \$opt_a); + "a=s" => \$opt_a, "address=s" => \$opt_a, + "C=s" => \$opt_C, "configfile=s" => \$opt_C); if ($opt_V) { print_revision($PROGNAME,'@NP_VERSION@'); #' @@ -91,6 +92,10 @@ my $warn = $1 if ($opt_w =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); ($crit) || usage("Invalid critical threshold: $opt_c\n"); +($opt_C) || ($opt_C = shift @ARGV) || ($opt_C = ""); +my $configfile = $opt_C if ($opt_C); +usage("Unable to read config file $configfile\n") if ($configfile) && (! -r $configfile); + # Execute the given command line and return anything it writes to STDOUT and/or # STDERR. (This might be useful for other plugins, too, so it should possibly # be moved to utils.pm.) @@ -193,6 +198,7 @@ my @cmd = ( defined($workgroup) ? ("-W", $workgroup) : (), defined($address) ? ("-I", $address) : (), defined($opt_P) ? ("-p", $opt_P) : (), + defined($configfile) ? ("-s", $configfile) : (), "-c", "du" ); @@ -292,7 +298,7 @@ exit $ERRORS{$state}; sub print_usage () { print "Usage: $PROGNAME -H -s -u -p - -w -c [-W ] [-P ] [-a ]\n"; + -w -c [-W ] [-P ] [-a ] [-C ]\n"; } sub print_help () { @@ -318,11 +324,12 @@ Perl Check SMB Disk plugin for monitoring Password to log in to server. (Defaults to an empty password) -w, --warning=INTEGER or INTEGER[kMG] Percent of used space at which a warning will be generated (Default: 85%) - -c, --critical=INTEGER or INTEGER[kMG] Percent of used space at which a critical will be generated (Defaults: 95%) -P, --port=INTEGER Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default) +-C, --configfile=STRING + Path to configfile which should be used by smbclient (Defaults to smb.conf of your smb installation) If thresholds are followed by either a k, M, or G then check to see if that much disk space is available (kilobytes, Megabytes, Gigabytes) -- cgit v1.2.3-74-g34f1 From 066b6e68242b5e7a6f1eb665df9b227d896aec66 Mon Sep 17 00:00:00 2001 From: Tobias Fiebig Date: Sat, 26 Mar 2022 12:55:23 +0100 Subject: remove duplicate W=i/C=i args (#1755) Co-authored-by: Tobias Fiebig --- plugins-scripts/check_mailq.pl | 2 -- 1 file changed, 2 deletions(-) (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl index 8cc3d0f6..4c72332a 100755 --- a/plugins-scripts/check_mailq.pl +++ b/plugins-scripts/check_mailq.pl @@ -578,8 +578,6 @@ sub process_arguments(){ "t=i" => \$opt_t, "timeout=i" => \$opt_t, "s" => \$opt_s, "sudo" => \$opt_s, "d:s" => \$opt_d, "configdir:s" => \$opt_d, - "W=i" => \$opt_W, # warning if above this number - "C=i" => \$opt_C, # critical if above this number ); if ($opt_V) { -- cgit v1.2.3-74-g34f1 From d63bb62e5d47d02e9cfd7bcfc25ef5a700fbe6d2 Mon Sep 17 00:00:00 2001 From: CDMIUB Date: Sat, 18 Jun 2022 09:15:58 +0200 Subject: Cdmiub (#1770) * added timout option to check_disk_smb --- plugins-scripts/check_disk_smb.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) mode change 100755 => 100644 plugins-scripts/check_disk_smb.pl (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl old mode 100755 new mode 100644 index ad71e6a2..15d16340 --- a/plugins-scripts/check_disk_smb.pl +++ b/plugins-scripts/check_disk_smb.pl @@ -22,7 +22,7 @@ require 5.004; use POSIX qw(setsid); use strict; use Getopt::Long; -use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $opt_C $verbose); +use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $opt_C $opt_t $verbose); use vars qw($PROGNAME); use FindBin; use lib "$FindBin::Bin"; @@ -43,6 +43,7 @@ $ENV{'ENV'}=''; Getopt::Long::Configure('bundling'); GetOptions ("v" => \$verbose, "verbose" => \$verbose, + "t=i" => \$opt_t, "timeout=i" => \$opt_t, "P=s" => \$opt_P, "port=s" => \$opt_P, "V" => \$opt_V, "version" => \$opt_V, "h" => \$opt_h, "help" => \$opt_h, @@ -96,6 +97,8 @@ my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); my $configfile = $opt_C if ($opt_C); usage("Unable to read config file $configfile\n") if ($configfile) && (! -r $configfile); +if ($opt_t && $opt_t =~ /^([0-9]+)$/) { $TIMEOUT = $1; } + # Execute the given command line and return anything it writes to STDOUT and/or # STDERR. (This might be useful for other plugins, too, so it should possibly # be moved to utils.pm.) @@ -298,7 +301,8 @@ exit $ERRORS{$state}; sub print_usage () { print "Usage: $PROGNAME -H -s -u -p - -w -c [-W ] [-P ] [-a ] [-C ]\n"; + -w -c [-W ] [-P ] [-a ] [-t timeout] + [-C ]\n"; } sub print_help () { @@ -326,6 +330,8 @@ Perl Check SMB Disk plugin for monitoring Percent of used space at which a warning will be generated (Default: 85%) -c, --critical=INTEGER or INTEGER[kMG] Percent of used space at which a critical will be generated (Defaults: 95%) +-t, --timeout=INTEGER + Seconds before connection times out (Default: 15) -P, --port=INTEGER Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default) -C, --configfile=STRING -- cgit v1.2.3-74-g34f1