summaryrefslogtreecommitdiffstats
path: root/web/attachments/382258-nagios-plugins-check_disk_smb.patch
blob: 31c687327f4490e914d6e485ccdc4a8627f84f3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
diff -urN nagios-plugins-1.4.15/plugins-scripts/check_disk_smb.pl nagios-plugins-1.4.15.new/plugins-scripts/check_disk_smb.pl
--- nagios-plugins-1.4.15/plugins-scripts/check_disk_smb.pl	2010-07-27 22:47:16.000000000 +0200
+++ nagios-plugins-1.4.15.new/plugins-scripts/check_disk_smb.pl	2010-08-04 14:06:46.000000000 +0200
@@ -208,7 +208,11 @@
 	my ($avail_bytes) = $avail;
 	my ($capper) = int(($3/$1)*100);
 	my ($mountpt) = "\\\\$host\\$share";
-
+	my ($mountptprint) = "//$host/$share";
+	my $warn_bytes;
+	my $crit_bytes;
+	my ($tot_bytes) = ($1*$2)/1024;
+	my ($used_bytes) = (($1-$3)*$2)/1024;
 
 	if (int($avail / 1024) > 0) {
 		$avail = int($avail / 1024);
@@ -221,19 +225,33 @@
 	} else {
 		$avail = $avail ."K";
 	}
+	
+	if ($warn_type eq "P") {
+		$warn_bytes=int($tot_bytes/100*$warn);
+	} else {
+		$warn_bytes=$warn;
+	}
+
+	if ($crit_type eq "P") {
+		$crit_bytes=int($tot_bytes/100*$crit);
+	} else {
+		$crit_bytes=$crit;
+	}
+
+	my ($perfdata) = "$mountptprint=$used_bytes;$warn_bytes;$crit_bytes;0;$tot_bytes";
 
 #print ":$warn:$warn_type:\n";
 #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";
+		$answer = "Disk ok - $avail ($capper%) free on $mountptprint|$perfdata\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";
+		$answer = "WARNING: Only $avail ($capper%) free on $mountptprint|$perfdata\n";
 	} else {
 		$state = "CRITICAL";
-		$answer = "CRITICAL: Only $avail ($capper%) free on $mountpt\n";
+		$answer = "CRITICAL: Only $avail ($capper%) free on $mountptprint|$perfdata\n";
 	}
 } else {
 	$answer = "Result from smbclient not suitable\n";
@@ -250,7 +268,7 @@
 			last;
 		}
 		if (/(You specified an invalid share name|NT_STATUS_BAD_NETWORK_NAME)/) {
-			$answer = "Invalid share name \\\\$host\\$share\n";
+			$answer = "Invalid share name //$host//$share\n";
 			$state = "CRITICAL";
 			last;
 		}