From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- web/attachments/134274-check_mem | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 web/attachments/134274-check_mem (limited to 'web/attachments/134274-check_mem') diff --git a/web/attachments/134274-check_mem b/web/attachments/134274-check_mem new file mode 100644 index 0000000..ed13f25 --- /dev/null +++ b/web/attachments/134274-check_mem @@ -0,0 +1,26 @@ +#!/usr/bin/perl -w +# +# check_mem v1.0 plugin for nagios +# +# uses the output of `free` to find the percentage of memory used +# +# Copyright Notice: GPL +# +# Garrett Honeycutt - gh@3gupload.com +# + +my ($mem_percent) = &sys_stats(); +print "$mem_percent\% Memory Used | MemUsed=$mem_percent\%;0;0;\n"; +exit(0); + +sub sys_stats { + + my ($mem_total, $mem_used); + + chomp($mem_total = `free -mt | grep Mem | awk '{print \$2}'`); + chomp($mem_used = `free -mt | grep cache | tail -1 | awk '{print \$3}'`); + + my $mem_percent = ($mem_used / $mem_total) * 100; + + return (sprintf("%.0f",$mem_percent)); +} -- cgit v1.2.3-74-g34f1