Hello,
I have created a custom sensor to monitor the CPU process. It is running fine on CentOS 6.x however on CentOS Linux release 7.4.1708 (Core) we are seeing errors like: 0 % (Idle Percent) is below the error limit of 5 % in Idle Percent
If I go and refresh it manually it is working. The code is given below:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++ #!/bin/bash cpuinfo="/usr/bin/top" xmlresult=`cat <<EOF <?xml version="1.0" encoding='UTF-8'?> <prtg> EOF ` if [ -f $cpuinfo ]; then result=`/usr/bin/top -b -n 1 | grep 'Cpu(s)'` if [[ $result == %Cpu* ]]; then user=`echo $result | awk '{print $2}'| awk '{print int($0)}'` system=`echo $result | awk '{print $4}'| awk '{print int($0)}'` nice=`echo $result | awk '{print $6}'| awk '{print int($0)}'` idle=`echo $result | awk '{print $8}'| awk '{print int($0)}'` wait=`echo $result | awk '{print $10}'| awk '{print int($0)}'` fi xmlresult=$xmlresult`cat <<EOF <result> <channel>User Percent</channel> <float>1</float> <unit>Percent</unit> <value>$user</value> </result> EOF ` xmlresult=$xmlresult`cat <<EOF <result> <channel>System Percent</channel> <float>1</float> <unit>Percent</unit> <value>$system</value> </result> EOF ` xmlresult=$xmlresult`cat <<EOF <result> <channel>Nice Percent</channel> <float>1</float> <unit>Percent</unit> <value>$nice</value> </result> EOF ` xmlresult=$xmlresult`cat <<EOF <result> <channel>Idle Percent</channel> <float>1</float> <unit>Percent</unit> <value>$idle</value> <LimitMinWarning>10</LimitMinWarning> <LimitMinError>5</LimitMinError> <LimitMode>1</LimitMode> </result> EOF ` xmlresult=$xmlresult`cat <<EOF <result> <channel>Wait Percent</channel> <float>1</float> <unit>Percent</unit> <value>$wait</value> </result> EOF ` xmlresult=$xmlresult`cat <<EOF <text>OK</text> </prtg> EOF ` else xmlresult=$xmlresult`cat <<EOF <error>1</error> <text>This sensor is not supported by your system, missing $cpuinfo</text> </prtg> EOF ` fi echo "$xmlresult" exit 0 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please let me know what is wrong??
Add comment