[Nagiosplug-devel] check_mem minor bugfix
Garrett Honeycutt
gh at 3gupload.com
Tue Jul 12 13:16:23 CEST 2005
I did a small bugfix to check_mem 1.3, so that the perf data is in the
correct format. check_mem 1.4 has been attached and the diff from 1.3 to
1.4 is below.
<diff>
--- check_mem1.3 2005-07-12 14:45:56.000000000 -0500
+++ check_mem1.4 2005-07-12 14:50:08.000000000 -0500
@@ -1,6 +1,6 @@
#! /usr/bin/perl -w
#
-# check_mem v1.3 plugin for nagios
+# check_mem v1.4 plugin for nagios
#
# uses the output of `free` to find the percentage of memory used
#
@@ -8,6 +8,9 @@
#
# History:
#
+# v1.4 Garrett Honeycutt - gh at 3gupload.com
+# + Fixed PerfData output to adhere to standards and show
crit/warn values
+#
# v1.3 Rouven Homann - rouven.homann at cimt-ag.de
# + Memory installed, used and free displayed in verbose mode
# + Bit Code Cleanup
@@ -47,7 +50,7 @@
"c=s" => \$opt_c, "critical=s" => \$opt_c);
if ($opt_V) {
- print_revision($PROGNAME,'$Revision: 1.3 $');
+ print_revision($PROGNAME,'$Revision: 1.4 $');
exit $ERRORS{'UNKNOWN'};
}
@@ -66,16 +69,16 @@
my ($mem_percent, $mem_total, $mem_used) = &sys_stats();
my $free_mem = $mem_total - $mem_used;
if ($mem_percent>$critical) {
- if ($verbose) { print "CRITICAL: $mem_percent\% Used Memory -
Total: $mem_total MB, used: $mem_used MB, free: $free_mem MB | MemUsed=
$mem_percent\%;0;0;\n";}
- else { print "CRITICAL: $mem_percent\% Used Memory | MemUsed=
$mem_percent\%;0;0;\n";};
+ if ($verbose) { print "CRITICAL: $mem_percent\% Used Memory -
Total: $mem_total MB, used: $mem_used MB, free: $free_mem MB | MemUsed=
$mem_percent\%;$warning;$critica l
\n";}
+ else { print "CRITICAL: $mem_percent\% Used Memory | MemUsed=
$mem_percent\%;$warning;$critical\n";};
exit $ERRORS{'CRITICAL'};
} elsif ($mem_percent>$warning) {
- if ($verbose) { print "WARNING: $mem_percent\% Used Memory - Total:
$mem_total MB, used: $mem_used MB, free: $free_mem MB | MemUsed=
$mem_percent\%;0;0;\n";}
- else { print "WARNING: $mem_percent\% Used Memory | MemUsed=
$mem_percent\%;0;0;\n";};
+ if ($verbose) { print "WARNING: $mem_percent\% Used Memory - Total:
$mem_total MB, used: $mem_used MB, free: $free_mem MB | MemUsed=
$mem_percent\%;$warning;$critical
\n";}
+ else { print "WARNING: $mem_percent\% Used Memory | MemUsed=
$mem_percent\%;$warning;$critical\n";};
exit $ERRORS{'WARNING'};
} else {
- if ($verbose) { print "OK: $mem_percent\% Used Memory - Total:
$mem_total MB, used: $mem_used MB, free: $free_mem MB | MemUsed=
$mem_percent\%;0;0;\n"; }
- else { print "OK: $mem_percent\% Used Memory | MemUsed=$mem_percent
\%;0;0;\n";};
+ if ($verbose) { print "OK: $mem_percent\% Used Memory - Total:
$mem_total MB, used: $mem_used MB, free: $free_mem MB | MemUsed=
$mem_percent\%;$warning;$critical
\n"; }
+ else { print "OK: $mem_percent\% Used Memory | MemUsed=$mem_percent
\%;$warning;$critical\n";};
exit $ERRORS{'OK'};
}
@@ -96,7 +99,7 @@
}
sub print_help () {
- print_revision($PROGNAME,'$Revision: 1.3 $');
+ print_revision($PROGNAME,'$Revision: 1.4 $');
print "Copyright (c) 2005 Garrett Honeycutt/Rouven Homann\n";
print "\n";
print_usage();
@@ -107,4 +110,4 @@
print "-h = This screen.\n\n";
support();
}
-
\ No newline at end of file
+
</diff>
--
// Garrett Honeycutt
// Sr. Systems Administrator
// 3GUpload.com, Inc.
// 317.472.4969 Office
-------------- next part --------------
A non-text attachment was scrubbed...
Name: check_mem
Type: application/x-perl
Size: 3821 bytes
Desc: not available
URL: <http://nagios-plugins.org/archive/devel/attachments/20050712/cf52e0fe/attachment.bin>
More information about the Devel
mailing list