summaryrefslogtreecommitdiffstats
path: root/web/attachments/76452-check_mem.diff
blob: 01d0d97ff169c5ec4e037e0c5d895fcab8507e5d (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
--- check_mem.pl	2002-02-28 00:42:54.000000000 -0600
+++ /home/jason/check_mem.pl	2004-02-12 06:20:21.000000000 -0600
@@ -27,7 +27,8 @@
 	    $crit_level $warn_level
             %exit_codes @memlist
             $percent $fmt_pct 
-            $verb_err $command_line);
+            $verb_err $command_line
+			$vmstat_version);
 
 # Predefined exit codes for Nagios
 %exit_codes   = ('UNKNOWN' ,-1,
@@ -39,7 +40,14 @@
 $verb_err     = 0;
 
 # This the unix command string that brings Perl the data
-$command_line = `vmstat | tail -1 | awk '{print \$4,\$5}'`;
+my $vmstat_version = `vmstat -V`;
+if( $vmstat_version =~ /2\.\d\.\d$/ ){
+	$command_line = `vmstat | tail -1 | awk '{print \$4,\$5}'`;
+}elsif( $vmstat_version =~ /3\.\d\.\d$/ ){
+	$command_line = `vmstat | tail -1 | awk '{print \$3,\$4}'`;
+}else{
+	$command_line = `vmstat | tail -1 | awk '{print \$4,\$5}'`;
+}
 
 chomp $command_line;
 @memlist      = split(/ /, $command_line);
@@ -89,6 +97,7 @@
 if ($opt_f)
 {
   $percent    = $free_memory / $total_memory * 100;
+  warn "$percent\n";
   $fmt_pct    = sprintf "%.1f", $percent;
   if ($percent <= $crit_level)
   {