[Nagiosplug-checkins] CVS: nagiosplug/plugins-scripts check_disk_smb.pl,1.3,1.4
Subhendu Ghosh
sghosh at users.sourceforge.net
Wed Jun 19 21:28:02 CEST 2002
- Previous message: [Nagiosplug-checkins] CVS: nagiosplug/plugins check_fping.c,1.1.1.1,1.2 check_ping.c,1.4,1.5 check_dns.c,1.1.1.1,1.2 check_hpjd.c,1.2,1.3 check_dig.c,1.1.1.1,1.2 urlize.c,1.1.1.1,1.2 check_snmp.c,1.1.1.1,1.2 check_nagios.c,1.1.1.1,1.2 check_vsz.c,1.1.1.1,1.2 utils.c,1.1.1.1,1.2 utils.h.in,1.1.1.1,1.2
- Next message: [Nagiosplug-checkins] CVS: nagiosplug/plugins check_snmp.c,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/nagiosplug/nagiosplug/plugins-scripts
In directory usw-pr-cvs1:/tmp/cvs-serv18160
Modified Files:
check_disk_smb.pl
Log Message:
logic fix for disk space thresholds
Index: check_disk_smb.pl
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins-scripts/check_disk_smb.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** check_disk_smb.pl 27 May 2002 01:55:41 -0000 1.3
--- check_disk_smb.pl 20 Jun 2002 04:27:38 -0000 1.4
***************
*** 62,65 ****
--- 62,67 ----
+ # Options checking
+
($opt_H) || ($opt_H = shift) || usage("Host name not specified\n");
my $host = $1 if ($opt_H =~ /([-_.A-Za-z0-9]+)/);
***************
*** 78,90 ****
($opt_w) || ($opt_w = shift) || ($opt_w = 85);
! my $warn = $1 if ($opt_w =~ /([0-9]{1,2}\%?|100\%?|[0-9]+[kmKM])+/);
($warn) || usage("Invalid warning threshold: $opt_w\n");
($opt_c) || ($opt_c = shift) || ($opt_c = 95);
! my $crit = $1 if ($opt_c =~ /([0-9]{1,2}\%?|100\%?|[0-9]+[kmKM])/);
($crit) || usage("Invalid critical threshold: $opt_c\n");
my $workgroup = $1 if (defined($opt_W) && $opt_W =~ /(.*)/);
my $state = "OK";
my $answer = undef;
--- 80,111 ----
($opt_w) || ($opt_w = shift) || ($opt_w = 85);
! my $warn = $1 if ($opt_w =~ /([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])/);
($warn) || usage("Invalid warning threshold: $opt_w\n");
($opt_c) || ($opt_c = shift) || ($opt_c = 95);
! my $crit = $1 if ($opt_c =~ /([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])/);
($crit) || usage("Invalid critical threshold: $opt_c\n");
+ # check if both warning and critical are percentage or size
+ unless( ( ($opt_w =~ /([0-9]){1,2}$/ ) && ($opt_c =~ /([0-9]){1,2}$/ ) )|| (( $opt_w =~ /[kMG]/ ) && ($opt_c =~ /[kMG]/) ) ){
+ usage("Both warning and critical should be same type- warning: $opt_w critical: $opt_c \n");
+ }
+
+ # verify warning is less than critical
+ if ( $opt_w =~ /[kMG]/) {
+ unless ( $warn > $crit) {
+ usage("Disk size: warning ($opt_w) should be greater than critical ($opt_c) \n");
+ }
+ }else{
+ unless ( $warn < $crit) {
+ usage("Percentage: warning ($opt_w) should be less than critical ($opt_c) \n");
+ }
+ }
+
my $workgroup = $1 if (defined($opt_W) && $opt_W =~ /(.*)/);
+ # end of options checking
+
+
my $state = "OK";
my $answer = undef;
***************
*** 130,154 ****
my $warn_type;
my $crit_type;
! if ($warn =~ /^([0-9]+$)/) {
$warn_type = "P";
! } elsif ($warn =~ /^([0-9]+)k$/) {
! my ($warn_type) = "K";
$warn = $1;
! } elsif ($warn =~ /^([0-9]+)M$/) {
$warn_type = "K";
$warn = $1 * 1024;
! } elsif ($warn =~ /^([0-9]+)G$/) {
$warn_type = "K";
$warn = $1 * 1048576;
}
! if ($crit =~ /^([0-9]+$)/) {
$crit_type = "P";
! } elsif ($crit =~ /^([0-9]+)k$/) {
$crit_type = "K";
$crit = $1;
! } elsif ($crit =~ /^([0-9]+)M$/) {
$crit_type = "K";
$crit = $1 * 1024;
! } elsif ($crit =~ /^([0-9]+)G$/) {
$crit_type = "K";
$crit = $1 * 1048576;
--- 151,176 ----
my $warn_type;
my $crit_type;
!
! if ($opt_w =~ /^([0-9]+$)/) {
$warn_type = "P";
! } elsif ($opt_w =~ /^([0-9]+)k$/) {
! $warn_type = "K";
$warn = $1;
! } elsif ($opt_w =~ /^([0-9]+)M$/) {
$warn_type = "K";
$warn = $1 * 1024;
! } elsif ($opt_w =~ /^([0-9]+)G$/) {
$warn_type = "K";
$warn = $1 * 1048576;
}
! if ($opt_c =~ /^([0-9]+$)/) {
$crit_type = "P";
! } elsif ($opt_c =~ /^([0-9]+)k$/) {
$crit_type = "K";
$crit = $1;
! } elsif ($opt_c =~ /^([0-9]+)M$/) {
$crit_type = "K";
$crit = $1 * 1024;
! } elsif ($opt_c =~ /^([0-9]+)G$/) {
$crit_type = "K";
$crit = $1 * 1048576;
***************
*** 159,168 ****
if (int($avail /1024) > 0) {
$avail = (int(($avail / 1024)*100))/100;
! $avail = $avail."G";
} else {
! $avail = $avail."M";
}
} else {
! $avail = $avail."K";
}
--- 181,190 ----
if (int($avail /1024) > 0) {
$avail = (int(($avail / 1024)*100))/100;
! $avail = $avail ."G";
} else {
! $avail = $avail ."M";
}
} else {
! $avail = $avail ."K";
}
***************
*** 170,181 ****
#print ":$crit:$crit_type:\n";
#print ":$avail:$avail_bytes:$capper:$mountpt:\n";
if ((($warn_type eq "P") && (100 - $capper) < $warn) || (($warn_type eq "K") && ($avail_bytes > $warn))) {
$answer = "Disk ok - $avail ($capper%) free on $mountpt\n";
} elsif ((($crit_type eq "P") && (100 - $capper) < $crit) || (($crit_type eq "K") && ($avail_bytes > $crit))) {
$state = "WARNING";
! $answer = "Only $avail ($capper%) free on $mountpt\n";
} else {
$state = "CRITICAL";
! $answer = "Only $avail ($capper%) free on $mountpt\n";
}
} else {
--- 192,204 ----
#print ":$crit:$crit_type:\n";
#print ":$avail:$avail_bytes:$capper:$mountpt:\n";
+
if ((($warn_type eq "P") && (100 - $capper) < $warn) || (($warn_type eq "K") && ($avail_bytes > $warn))) {
$answer = "Disk ok - $avail ($capper%) free on $mountpt\n";
} elsif ((($crit_type eq "P") && (100 - $capper) < $crit) || (($crit_type eq "K") && ($avail_bytes > $crit))) {
$state = "WARNING";
! $answer = "WARNING: Only $avail ($capper%) free on $mountpt\n";
} else {
$state = "CRITICAL";
! $answer = "CRITICAL: Only $avail ($capper%) free on $mountpt\n";
}
} else {
***************
*** 189,193 ****
}
if (/(Unknown host \w*)/) {
! $answer = "$1\n";
$state = "CRITICAL";
last;
--- 212,217 ----
}
if (/(Unknown host \w*)/) {
! $answer = "$1\n";_
!
$state = "CRITICAL";
last;
***************
*** 230,239 ****
-p, --password=STRING
Password to log in to server. (Defaults to \"guest\")
! -w, --warning=INTEGER
Percent of used space at which a warning will be generated (Default: 85%)
!
! -c, --critical=INTEGER
Percent of used space at which a critical will be generated (Defaults: 95%)
";
--- 254,268 ----
-p, --password=STRING
Password to log in to server. (Defaults to \"guest\")
! -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%)
+ 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)
+
+ Warning percentage should be less than critical
+ Warning (remaining) disk space should be greater than critical.
";
- Previous message: [Nagiosplug-checkins] CVS: nagiosplug/plugins check_fping.c,1.1.1.1,1.2 check_ping.c,1.4,1.5 check_dns.c,1.1.1.1,1.2 check_hpjd.c,1.2,1.3 check_dig.c,1.1.1.1,1.2 urlize.c,1.1.1.1,1.2 check_snmp.c,1.1.1.1,1.2 check_nagios.c,1.1.1.1,1.2 check_vsz.c,1.1.1.1,1.2 utils.c,1.1.1.1,1.2 utils.h.in,1.1.1.1,1.2
- Next message: [Nagiosplug-checkins] CVS: nagiosplug/plugins check_snmp.c,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Commits
mailing list