From 82b365996d07252c91ba9aecf8046e02eb2023e0 Mon Sep 17 00:00:00 2001 From: Sancho Lerena Date: Tue, 30 Dec 2014 15:48:09 +0100 Subject: [PATCH] Added new module for memory plugin, availableMemory, which is the sum of free, cached and swapcached memory. Added comment on current FreeMemory module and removed thresholds for ProcessTotal module, also changed default threshold to avoid "by default" critical/warning status. --- pandora_agents/unix/Linux/pandora_agent.conf | 4 --- pandora_agents/unix/plugins/pandora_mem | 27 +++++++++++++++++--- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index aa4724958a..d5796e1037 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -220,10 +220,6 @@ module_name Number processes module_type generic_data module_exec ps aux | wc -l module_description Total processes -module_min_warning 150 -module_max_warning 249 -module_min_critical 250 -module_max_critical 300 module_unit processes module_end diff --git a/pandora_agents/unix/plugins/pandora_mem b/pandora_agents/unix/plugins/pandora_mem index 90f912efa4..1d7745a8fd 100755 --- a/pandora_agents/unix/plugins/pandora_mem +++ b/pandora_agents/unix/plugins/pandora_mem @@ -15,22 +15,41 @@ my $SFREE=($SUSED/$STOTAL)*100; $SFREE = floor($SFREE); $FREEP = floor($FREEP); +# Added 30/Dec/2014, slerena +# Available memory as FreeMemory + Cached + SwapCached. +my $freemem=`cat /proc/meminfo | grep 'MemFree' | awk '{ print \$2 } '`; +my $cached=`cat /proc/meminfo | grep '^Cached:' | awk '{ print \$2 } '`; +my $cachedswap=`cat /proc/meminfo | grep '^SwapCached:' | awk '{ print \$2 }'`; +my $available=$freemem+$cached+$cachedwap; +my $available_percent = floor(($available / $STOTAL)*100); + + print "\n"; print "FreeMemory\n"; print "generic_data\n"; -print "Free memory %\n"; +print "Free memory %. Note most linux use 99% of available memory by default, check Availablememory module for more accurate information on available physical memory on system\n"; print "%\n"; print "0\n"; -print "5\n"; +print "2\n"; print "$FREEP\n"; print "\n"; print "\n"; print "FreeSwap\n"; print "generic_data\n"; -print "Free Swapy %\n"; +print "Free Swap %\n"; +print "%\n"; +print "0\n"; +print "5\n"; +print "$SFREE\n"; +print "\n"; + +print "\n"; +print "AvailableMemory\n"; +print "generic_data\n"; +print "Available Physical Memory % (Free+Cached+CachedSwap)\n"; print "%\n"; print "0\n"; print "10\n"; -print "$SFREE\n"; +print "$available_percent\n"; print "\n";