[Nagiosplug-devel] some patches
Frans Luteijn
f.a.g.luteijn at knoware.nl
Thu May 19 15:09:04 CEST 2005
Dear Nagiosplugin developers,
I would like to propose the following changes in the attached file:
in the plugin check_disk_smb I have added the option "-a" for the
address of the checked server if it is in another network. Further, it
is legal to have spaces in windows-hostnames, so I implemented that too.
In check_mailq I have disabled the emptying of the PATH-variable,
because I got error-messages when executing the plugin.
I hope, you will find the changes an enhancement,
your sincerely,
--
Frans Luteijn
PGP PblKey fprnt=C4 87 CE AF BC B6 98 C1 EF 42 A1 9A E2 C0 42 5B
GPG PblKey fprnt=ED20 0F25 C233 DC59 3FFA 170E D0BF 15F5 0BA6 1355
-------------- next part --------------
diff -rcN /usr/lib/nagios/plugins.orig/check_disk_smb /usr/lib/nagios/plugins/check_disk_smb
*** /usr/lib/nagios/plugins.orig/check_disk_smb Mon Mar 7 05:33:28 2005
--- /usr/lib/nagios/plugins/check_disk_smb Thu May 19 00:15:44 2005
***************
*** 23,29 ****
use POSIX;
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 $verbose);
use vars qw($PROGNAME);
use lib "/usr/lib/nagios/plugins" ;
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
--- 23,29 ----
use POSIX;
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($PROGNAME);
use lib "/usr/lib/nagios/plugins" ;
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
***************
*** 49,55 ****
"u=s" => \$opt_u, "username=s" => \$opt_u,
"s=s" => \$opt_s, "share=s" => \$opt_s,
"W=s" => \$opt_W, "workgroup=s" => \$opt_W,
! "H=s" => \$opt_H, "hostname=s" => \$opt_H);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.10 $'); #'
--- 49,56 ----
"u=s" => \$opt_u, "username=s" => \$opt_u,
"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);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.10 $'); #'
***************
*** 65,71 ****
# Options checking
($opt_H) || ($opt_H = shift) || usage("Host name not specified\n");
! my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9]+\$?)$/);
($host) || usage("Invalid host: $opt_H\n");
($opt_s) || ($opt_s = shift) || usage("Share volume not specified\n");
--- 66,72 ----
# Options checking
($opt_H) || ($opt_H = shift) || usage("Host name not specified\n");
! my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9 ]+\$?)$/);
($host) || usage("Invalid host: $opt_H\n");
($opt_s) || ($opt_s = shift) || usage("Share volume not specified\n");
***************
*** 105,110 ****
--- 106,113 ----
my $workgroup = $1 if (defined($opt_W) && $opt_W =~ /(.*)/);
+ my $address = $1 if (defined($opt_a) && $opt_a =~ /(.*)/);
+
# end of options checking
***************
*** 123,132 ****
# Execute an "ls" on the share using smbclient program
# get the results into $res
if (defined($workgroup)) {
! $res = qx/$smbclient \/\/$host\/$share $pass -W $workgroup -U $user $smbclientoptions -c ls/;
} else {
! print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -c ls\n" if ($verbose);
! $res = qx/$smbclient \/\/$host\/$share $pass -U $user $smbclientoptions -c ls/;
}
#Turn off alarm
alarm(0);
--- 126,146 ----
# Execute an "ls" on the share using smbclient program
# get the results into $res
if (defined($workgroup)) {
! if (defined($address)) {
! print "$smbclient " . "\/\/$host\/$share" ." $pass -W $workgroup -U $user $smbclientoptions -I $address -c ls\n" if ($verbose);
! $res = qx/$smbclient "\/\/$host\/$share" $pass -W $workgroup -U $user $smbclientoptions -I $address -c ls/;
! } else {
! print "$smbclient " . "\/\/$host\/$share" ." $pass -W $workgroup -U $user $smbclientoptions -c ls\n" if ($verbose);
! $res = qx/$smbclient "\/\/$host\/$share" $pass -W $workgroup -U $user $smbclientoptions -c ls/;
! }
} else {
! if (defined($address)) {
! print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -I $address -c ls\n" if ($verbose);
! $res = qx/$smbclient "\/\/$host\/$share" $pass -U $user $smbclientoptions -I $address -c ls/;
! } else {
! print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -c ls\n" if ($verbose);
! $res = qx/$smbclient "\/\/$host\/$share" $pass -U $user $smbclientoptions -c ls/;
! }
}
#Turn off alarm
alarm(0);
***************
*** 231,237 ****
sub print_usage () {
print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password>
! -w <warn> -c <crit> [-W <workgroup>] [-P <port>]\n";
}
sub print_help () {
--- 245,251 ----
sub print_usage () {
print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password>
! -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>]\n";
}
sub print_help () {
***************
*** 249,254 ****
--- 263,270 ----
Share name to be tested
-W, --workgroup=STRING
Workgroup or Domain used (Defaults to \"WORKGROUP\")
+ -a, --address=IP
+ IP-address of HOST (only necessary if HOST is in another network)
-u, --user=STRING
Username to log in to server. (Defaults to \"guest\")
-p, --password=STRING
diff -rcN /usr/lib/nagios/plugins.orig/check_mailq /usr/lib/nagios/plugins/check_mailq
*** /usr/lib/nagios/plugins.orig/check_mailq Mon Mar 7 05:33:29 2005
--- /usr/lib/nagios/plugins/check_mailq Wed May 18 23:52:33 2005
***************
*** 40,46 ****
sub print_usage ();
sub process_arguments ();
! $ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
$PROGNAME = "check_mailq";
--- 40,46 ----
sub print_usage ();
sub process_arguments ();
! #$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
$PROGNAME = "check_mailq";
More information about the Devel
mailing list