首页 > 代码库 > 【监控】Nagios-NRPE脚本返回值

【监控】Nagios-NRPE脚本返回值

自定义Nagios NRPE脚本EXIT退出值和nagios状态都应关系:

状态EXIT退出值输出例子
OK0echo "OK - it‘s ok."echo "OK - it‘s ok."
exit 0
WARNING1echo "WARNING - it‘s warning."echo "WARNING - it‘s warning."
exit 1
CRITICAL2echo "CRITICAL - it‘s critical."echo "CRITICAL - it‘s critical."
exit 2
UNKNOWN3echo "UNKNOWN - it‘s unknown."echo "UNKNOWN - it‘s unknown."
exit 3


错误的例子:

shell脚本中echo和退出值:

echo "OK - it‘s ok."

exit 1

此时,Nagios会显示:

这条服务对应的状态是”WARNING“,但是输出的信息是”OK - it‘s ok."