1.首先在入口文件中添加名称
# cat top.sls base: '*': - conf.snmpd - conf.nagios
2.然后根据路径来写入配置
# cat conf/nagios.sls install_nagios: cmd.script: - source: salt://nagios/nagios.bin - user: root - shell: /bin/bash
3.最后把脚本放入到指定目录
# ll nagios/nagios.bin -rw-r--r-- 1 root root 2492186 Mar 13 07:43 nagios/nagios.bin
4.执行安装命令
# salt 'mail-15[0-6]' state.sls conf.nagios
5.更改允许监控主机IP
# salt 'mail-15[0-6]' cmd.run "sed -i 's/10\.6\.8\.200$/4\.6\.5\.15/g' /etc/xinetd.d/nrpe" #由于监控端不能通过内网来通信,所以需要替换成外网IP
6.重启nrpe依赖的xinetd服务
# salt 'mail-15[0-6]' cmd.run "/etc/init.d/xinetd restart"
7.查看安装的nrpe的端口是否监听中
8.脚本测试是否可用
# for i in $(seq 150 156) ; do /usr/local/nagios/libexec/check_nrpe -H 4.6.5.$i ;done NRPE v2.12 NRPE v2.12 NRPE v2.12 NRPE v2.12 NRPE v2.12 NRPE v2.12 NRPE v2.12
转载于:https://blog.51cto.com/charlie928/1375804