diff options
Diffstat (limited to 'web/attachments/76452-check_mem.diff')
| -rw-r--r-- | web/attachments/76452-check_mem.diff | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/web/attachments/76452-check_mem.diff b/web/attachments/76452-check_mem.diff new file mode 100644 index 0000000..01d0d97 --- /dev/null +++ b/web/attachments/76452-check_mem.diff | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | --- check_mem.pl 2002-02-28 00:42:54.000000000 -0600 | ||
| 2 | +++ /home/jason/check_mem.pl 2004-02-12 06:20:21.000000000 -0600 | ||
| 3 | @@ -27,7 +27,8 @@ | ||
| 4 | $crit_level $warn_level | ||
| 5 | %exit_codes @memlist | ||
| 6 | $percent $fmt_pct | ||
| 7 | - $verb_err $command_line); | ||
| 8 | + $verb_err $command_line | ||
| 9 | + $vmstat_version); | ||
| 10 | |||
| 11 | # Predefined exit codes for Nagios | ||
| 12 | %exit_codes = ('UNKNOWN' ,-1, | ||
| 13 | @@ -39,7 +40,14 @@ | ||
| 14 | $verb_err = 0; | ||
| 15 | |||
| 16 | # This the unix command string that brings Perl the data | ||
| 17 | -$command_line = `vmstat | tail -1 | awk '{print \$4,\$5}'`; | ||
| 18 | +my $vmstat_version = `vmstat -V`; | ||
| 19 | +if( $vmstat_version =~ /2\.\d\.\d$/ ){ | ||
| 20 | + $command_line = `vmstat | tail -1 | awk '{print \$4,\$5}'`; | ||
| 21 | +}elsif( $vmstat_version =~ /3\.\d\.\d$/ ){ | ||
| 22 | + $command_line = `vmstat | tail -1 | awk '{print \$3,\$4}'`; | ||
| 23 | +}else{ | ||
| 24 | + $command_line = `vmstat | tail -1 | awk '{print \$4,\$5}'`; | ||
| 25 | +} | ||
| 26 | |||
| 27 | chomp $command_line; | ||
| 28 | @memlist = split(/ /, $command_line); | ||
| 29 | @@ -89,6 +97,7 @@ | ||
| 30 | if ($opt_f) | ||
| 31 | { | ||
| 32 | $percent = $free_memory / $total_memory * 100; | ||
| 33 | + warn "$percent\n"; | ||
| 34 | $fmt_pct = sprintf "%.1f", $percent; | ||
| 35 | if ($percent <= $crit_level) | ||
| 36 | { | ||
