--- a/check_mem.pl Thu Jun 30 14:44:08 2011 +0200
+++ b/check_mem.pl Thu Jun 30 15:58:49 2011 +0200
@@ -41,7 +41,7 @@
my $ME = basename $0;
my $NAME = "MEM";
-my $VERSION = "0.1";
+my $VERSION = "0.2";
my %opt = (
warning => 70,
@@ -81,23 +81,19 @@
}
sub get_meminfo() {
- my ( $total, $free, $used, $percent );
- my $file = '/proc/meminfo';
-
- open( FH, $file )
- or say "$NAME CRITICAL: $file - $!." and exit $ERRORS{CRITICAL};
+ my ( $total, $used, $free, $percent );
+ my @cmd = ( '/usr/bin/free', '-m' );
- while (<FH>) {
- /^MemTotal:\s+(?<total>[\d.]+)/
- and $total = ( sprintf( "%.0f", $+{total} / 1024 ) )
+ foreach (`/usr/bin/free -m`) {
+ /^Mem:\s+(?<total>[\d.]+)/
+ and $total = $+{total}
and next;
- /^MemFree:\s+(?<free>[\d.]+)/
- and $free = ( sprintf( "%.0f", $+{free} / 1024 ) )
+ /^.+buffers\/cache:\s+(?<used>[\d.]+)/
+ and $used = $+{used}
and last;
}
- close(FH);
- $used = ( $total - $free );
+ $free = ( $total - $used );
$percent = ( sprintf( "%.0f", ( $used / $total ) * 100 ) );
return ( $percent, $total, $used, $free );
@@ -164,7 +160,7 @@
=head1 VERSION
-This man page is current for version 0.1 of B<check_mem>.
+This man page is current for version 0.2 of B<check_mem>.
=head1 AUTHOR
--- a/debian/changelog Thu Jun 30 14:44:08 2011 +0200
+++ b/debian/changelog Thu Jun 30 15:58:49 2011 +0200
@@ -1,3 +1,9 @@
+nagios-plugin-mem (0.2) lenny squeeze; urgency=low
+
+ * now output memory usage without buffers and cached files
+
+ -- Christian Arnold <arnold@schlittermann.de> Thu, 30 Jun 2011 15:54:29 +0200
+
nagios-plugin-mem (0.1) lenny squeeze; urgency=low
* Initial Release.