3. 监控利器nagios手把手企业级实战第二部
作者:互联网
[root@nagios etc]# cat objects/hosts.cfg
define host{
use linux-server ---object下的模板 templates.cfg 里的变量定义
host_name djw1
alias djw1
address 192.168.0.102 } define host{
use linux-server
host_name server
alias djw1
address 192.168.0.103 } define hostgroup{
hostgroup_name linux-servers ; The name of the hostgroup
alias Linux Servers ; Long name of the group
members djw1,server
}
2.检查语法:
/etc/init.d/nagios checkconfig
报错:Error: There are no services defined!
3.配置service.cfg配置文件
[root@nagios etc]# cat objects/service.cfg
define service {
use generic-service
host_name djw1
service_description Disk Partition
check_command check_nrpe!check_disk
}
3.再次检查语法:
/etc/init.d/nagios checkconfig
报错:Error: Service check command 'check_nrpe' specified in service 'Disk Partition' for host 'djw1' not defined anywhere! (表示命令check_nrpe不存在)
4. 在/usr/local/nagios/etc/objects/command.cfg 添加命令
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ (等价于/usr/local/nagios/libexec/check_nrpe -H 192.168.161.135 -c check_disk)
}
5. 重启nagios
/etc/init.d/nagios checkconfig --再次检查语法,没有报错
/etc/init.d/nagios reload --平滑重启
6.注意nagios oldboy用户访问权限
sed -i 's#nagiosadmin#oldboy#g' /usr/local/nagios/etc/cgi.cfg
7.查看结果
8.被动监控结果:
check_nrpe!check_disk的原理就是下面的命令:
[root@djw etc]# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.102 -c check_disk
DISK OK - free space: / 6065 MB (62% inode=86%);| /=3668MB;8209;9441;0;10262
标签:name,手把手,nagios,etc,nrpe,cfg,企业级,check 来源: https://www.cnblogs.com/dangjingwei/p/11954521.html