Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
CPU Stats/Memory Used Plugin - Top 5 CPU/Memory Consuming Processes for Unix Servers
v1.0
2012-10-19
- Nagios 3.x
- Nagios XI
- Nagios Fusion
GPL
81878
File | Description |
---|---|
check_cpu_stats.sh | Returns CPU Load with Top 5 CPU consuming processes |
check_mem_hpux_custom | Returns Memory Used with Top 5 Memory consuming processes |
CPU_&_Memory_top5_Unix.JPG | Screenshot |
Meet The New Nagios Core Services Platform
Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.
Monitoring Made Magically Better
- Nagios Core on Overdrive
- Powerful Monitoring Dashboards
- Time-Saving Configuration Wizards
- Open Source Powered Monitoring On Steroids
- And So Much More!
Reviews (4)
bymicharg, May 11, 2019
Hi all, unfortunately the comment does not allow attaching scripts. I have patched the 2 provided scripts to work on Linux (they fail now). Tried with CentOS 7.x. Can you please review and update the current versions (that are since 2012)?
The patched files and more information (also for prerequisites) on https://micharg.blogspot.com/2019/05/patched-nagios-scripts-to-monitor-top-5.html
The patched files and more information (also for prerequisites) on https://micharg.blogspot.com/2019/05/patched-nagios-scripts-to-monitor-top-5.html
byDutchEagleon, May 20, 2016
I tested both of them on CentOS 7.2, the CPU check worked after dos2unix.
But the MEM check needed some more changes.
The script used "machinfo" but this isn't a command in CentOS. So I used "cat /proc/meminfo | grep Memtotal"
I also changed the total free memory, to this command:
# Total memory available
totalmem=`cat /proc/meminfo | grep -i memtotal`
totalmem=`echo $totalmem | awk '{print $2}'`
#totalmem=`echo "$totalmem * 1024" | bc`
#echo "TotalMem=$totalmem"
#Total Free Memory
freemem=`cat /proc/meminfo | grep -i memfree`
freemem=`echo $freemem | awk '{print $2}'`
I also had a problem with "bc", I constantly got a error about the decimal that was included.
But I changed the calculation so it wouldn't get the error anymore:
# Total memory used
usedmem=`echo "$totalmem - $freemem" | bc -l`
#echo "UsedMem=$usedmem"
#Percent Used Mem for Calculation.
percused=`echo $usedmem / $totalmem | bc -l`
#Percent Used Mem
percentused=`echo "scale=0;($percused * 100/1)" | bc -l`
#echo "PercentUsedMem=$percentused"
percentfree=`echo "100 - $percentused" | bc -l`
And I got an integer expression on line 123, so I changed the command a bit.
OUTPUT=";Top 5 Memory Processes(memKB,pname,pid): " ;
for word in $COMMAND; do
i=`expr $i + 1`
j=`expr $j + 1`
if [[ $i -eq 3 ]]; then
i=0;
if [ $j -eq 15 ]; then
OUTPUT="$OUTPUT `echo $word`" ;
else
OUTPUT="$OUTPUT `echo $word, `" ;
fi
else
if [ "$i%3" = "1" ]; then ## It was this: [ $i%3 -eq 1 ] ##
OUTPUT="$OUTPUT `echo $word"KB"`" ;
else
OUTPUT="$OUTPUT `echo $word `" ;
fi
fi
done
After I made this changes it worked fine.
But the MEM check needed some more changes.
The script used "machinfo" but this isn't a command in CentOS. So I used "cat /proc/meminfo | grep Memtotal"
I also changed the total free memory, to this command:
# Total memory available
totalmem=`cat /proc/meminfo | grep -i memtotal`
totalmem=`echo $totalmem | awk '{print $2}'`
#totalmem=`echo "$totalmem * 1024" | bc`
#echo "TotalMem=$totalmem"
#Total Free Memory
freemem=`cat /proc/meminfo | grep -i memfree`
freemem=`echo $freemem | awk '{print $2}'`
I also had a problem with "bc", I constantly got a error about the decimal that was included.
But I changed the calculation so it wouldn't get the error anymore:
# Total memory used
usedmem=`echo "$totalmem - $freemem" | bc -l`
#echo "UsedMem=$usedmem"
#Percent Used Mem for Calculation.
percused=`echo $usedmem / $totalmem | bc -l`
#Percent Used Mem
percentused=`echo "scale=0;($percused * 100/1)" | bc -l`
#echo "PercentUsedMem=$percentused"
percentfree=`echo "100 - $percentused" | bc -l`
And I got an integer expression on line 123, so I changed the command a bit.
OUTPUT=";Top 5 Memory Processes(memKB,pname,pid): " ;
for word in $COMMAND; do
i=`expr $i + 1`
j=`expr $j + 1`
if [[ $i -eq 3 ]]; then
i=0;
if [ $j -eq 15 ]; then
OUTPUT="$OUTPUT `echo $word`" ;
else
OUTPUT="$OUTPUT `echo $word, `" ;
fi
else
if [ "$i%3" = "1" ]; then ## It was this: [ $i%3 -eq 1 ] ##
OUTPUT="$OUTPUT `echo $word"KB"`" ;
else
OUTPUT="$OUTPUT `echo $word `" ;
fi
fi
done
After I made this changes it worked fine.
To use this plugin under linux you may need to convert it with dos2unix tool. It comes in windows format.
Hi Manish Kumar,
I left a email in your Gmail,please check it. There are some screenshots in my email. Please help me to solve the problem.Thank you very much.
I left a email in your Gmail,please check it. There are some screenshots in my email. Please help me to solve the problem.Thank you very much.