vbscript - 使用 NRPE 执行远程脚本

标签 vbscript nagios nrpe

如果在远程服务器上指定插件命令,则可以执行脚本。
在下面的示例中,插件命令是 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 运行命令以监控远程计算机

  1. 假设您有 2 台机器,
  2. 从你想监控的地方(将其称为 master)
  3. 您想监视谁(将其称为奴隶)
  4. 假设您在 linux 中工作,并且在主计算机 nagios 中的位置是“/usr/local/nagios”
  5. 你的slave机器也是linux,nrpe安装位置是"/usr/local/nagios"
  6. 将您的脚本/插件/可执行文件放在从机的@/usr/local/nagios/libexec 位置。

    e.g. - /usr/local/nagios/libexec/test.sh
    and give it executable permission.
    chmod +x test.sh

    1. 编辑 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 line

define 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.

  1. 添加服务

    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)

  2. 现在,在从 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/

相关文章:

linux - nagios 为 jenkins 创建自定义警报

mysql - 纳吉奥斯 : Setting alerts based in value returned

powershell - 文件不存在时,文件检查脚本不会引发严重标志

linux - 在没有网络的Linux Centos上安装开发工具

ruby - 在 Nagiosgraph 中绘制多个磁盘卷

windows - 错误 : The requested service provider could not be loaded or initialized. - 套接字 (2)

xml - vbscript选择子节点

regex - VBS 正则表达式从字符串中获取下划线

vbscript - UFT VBS 两个函数同名,怎么指定哪一个

vbscript - 可能发生哪些其他 5xx 错误以及如何查找/跟踪它们?