Modified check_memory to support new procps free(1) output format

Created initial README
This commit is contained in:
2015-07-26 11:12:22 +02:00
parent c381946e6a
commit 2bbb913849
3 changed files with 729 additions and 3 deletions

View File

@@ -19,6 +19,8 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# patched by JFL on July 26th 2015 to work with new Linux free(1) output. Latest
# version/issue tracker at: https://gitlab.lindenaar.net/scripts/nagios-plugins
use strict;
use warnings;
@@ -107,9 +109,17 @@ warn("Output from $FREECMD:\n") if ($verbose > 1);
my ($used, $free);
while (<RESULT>) {
warn(" $_") if ($verbose > 1);
next unless (m#^\-/\+\ buffers/cache:\s*(\d+)\s+(\d+)#);
$used = $1;
$free = $2;
if (m#^\-/\+\ buffers/cache:\s*(\d+)\s+(\d+)#) {
warn(" detected legacy format free output") if ($verbose > 1);
$used = $1;
$free = $2;
last;
} elsif (m#^Mem:\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s*$#) {
warn(" detected new format free output") if ($verbose > 1);
$used = $2;
$free = $3 + $5;
last;
}
}
close(RESULT);