Build precise queries to find exactly what you need
Press ESC to close
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.
We’ve completely redesigned the world’s largest repository of Nagios plugins and monitoring tools. Join thousands of users sharing monitoring solutions for servers, applications, and everything in between.
Due to our redesign, all existing accounts require a password reset to access your account again.
Ready to explore 6,100+ projects and contribute to the community?
Reset Password Create Account
Happy Monitoring!