#!/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)); }