自定义插件可以正常工作RHEL

时间:2018-04-03 17:03:09

标签: bash nagios

我已经成功创建了一个可以从nagios用户执行的bash脚本。问题是这个脚本在Linux命令行中工作正常,但如果由nagios运行(在Web GUI中返回),它将返回未知状态。

我已将脚本放在nagios服务器中: loc:/usr/local/nagios/libexec/

脚本

#!/bin/bash
rootUsage=$(du -s /root | cut -d "/" -f1)
output=$(du -s /root | cut -d "/" -f1)
if(($rootUsage<= 204800));then
echo "OK. root storage is : $output :"
exit 0
elif((204800<$rootUsage) && ($rootUsage<211111)); then
echo "WARNING. root storage is : $output"
exit 1
elif(($rootUsage >= 211111));then
echo "CRITICAL. root storage is : $output"
exit 2
else
echo "UNKNOWN. root storage given value : $rootUsage"
exit 3
fi

创建命令:

'check_root_space'命令定义

define command{
 command_name    check_root_space
 command_line    $USER1$/check_root_space
 }

服务创建:

define service{
use                     generic-service
host_name               NagiosLinuxClient
service_description     Monitor Root Usage
check_command           check_nrpe!check_root_space
}

Ngios clinet结束:

相同的bash脚本放在/usr/local/nagios/libexe/目录

并且在nagios中配置了coomand,cfg文件

command[chech_root_space]=/usr/local/nagios/libexe/check_root_space

当我尝试使用以下命令从nagios服务器执行插件时

/usr/local/nagios/libexe/check_nrpe -H <ip addressofclient> -c check_root_space

最终输出:

NRPE: Command 'check_root_space' not defined 

0 个答案:

没有答案