如果在远程服务器上指定插件命令,则可以执行脚本。
在下面的示例中,插件命令是 get_disk
:
command[get_disk]=csript.exe c:\nagios\checks\check_disks_percentage_spave_used.vbs
不过,我希望远程服务器上的 NRPE 在客户端服务器上执行脚本,而无需插件命令。
在远程服务器上是这样的:
check_nrpe -H 196.35.132.9 -t 60 -c 'csript.exe c:\\nagios\\checks\\check_disks_percentage_space_used.vbs'
最佳答案
您可以按照以下步骤从 nagios 运行命令以监控远程计算机
- 假设您有 2 台机器,
- 从你想监控的地方(将其称为 master)
- 您想监视谁(将其称为奴隶)
- 假设您在 linux 中工作,并且在主计算机 nagios 中的位置是“/usr/local/nagios”
- 你的slave机器也是linux,nrpe安装位置是"/usr/local/nagios"
将您的脚本/插件/可执行文件放在从机的@/usr/local/nagios/libexec 位置。
e.g. - /usr/local/nagios/libexec/test.sh
and give it executable permission.
chmod +x test.sh- 编辑 nrpe.cfg 并在其中添加命令
vi /usr/local/nagios/etc/nrpe.cfg
add following line
command[testScript]=/usr/local/nagios/libexec/test.sh
telling nrpe to run test.sh when it receives testScript command
8.重启nrpe
9. 转到主机
10.编辑commands.cfg
vi /usr/local/nagios/etc/objects/commands.cfg
and add following linedefine command{
command_name check_nrpe
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
by adding this, now master machine is aware what is check_nrpe command.
添加服务
define service{
use generic-service
host_name web-node01
service_description count number of cmd in remote mc
check_command check_nrpe!testScript
}
now nagios know that it has to call testScript command in slave machine,
and in slave machine we have defined when received testScript command run 'test.sh'
from thi s'/usr/local/nagios/libexec' location (point no. 7)现在,在从 nagios 尝试之前,您可以直接调用 nrpe 命令,按照以下命令检查是否一切正常
/usr/local/nagios/libexec/check_nrpe -H slave_IP_Address -c testScript
P.S. this is exactly same command that nagios will run behind the scene
关于vbscript - 使用 NRPE 执行远程脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27313780/