23rwd 发表于 2015-12-9 09:01:26

nagios安装


# yum install -y epel-release
# yum install -y httpd nagios nagios-plugins nagios-plugins-all nrpe nagios-plugins-nrpe

设置登录nagios后台的用户和密码:
# htpasswd -c /etc/nagios/passwd nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
#
然后就可以在浏览器中登录



然后在客户端(另外一台机器)安装:
# yum install -y nagios-plugins nagios-plugins-all nrpe nagios-plugins-nrpe

编辑配置文件:
# vim /etc/nagios/nrpe.cfg





然后启动客户端:
# /etc/init.d/nrpe start
Starting nrpe:                                             [确定]

然后再到服务端配置:
客户端的IP:192.168.1.130并定义子配置文件:
# cd /etc/nagios/conf.d
You have new mail in /var/spool/mail/root
# ls
# vim 192.168.1.130.cfg
define host{
use          linux-server
host_name    192.168.1.130
alias      1.130
address      192.168.1.130

}

define service{
use             generic-service
host_name       192.168.1.130
service_description    check_ping
check_command          check_ping!100.0,20%!200.0,50%
max_check_attempts 5
normal_check_interval 1
}


define service{
use             generic-service
host_name       192.168.1.130
service_description    check_ssh
check_command          check_ssh
max_check_attempts   5
normal_check_interval 1
notification_interval   60
}
define service{
use             generic-service
host_name       192.168.1.130
service_description   check_http
check_command         check_http
max_check_attempts    5
normal_check_interval 1
}





# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
#



然后继续在服务端配置:
# vim /etc/nagios/objects/commands.cfg
加入:

define command{
command_name   check_nrpe
command_line   $USE1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}



然后继续编辑:
# vim /etc/nagios/conf.d/192.168.1.130.cfg
增加:
define service{
use generic-service
host_name       192.168.1.130
service_description   check_load
check_command       check_nrpe!check_load
max_check_attempts 5
normal_check_interval 1
}

define service{
usegeneric-service
host_name      192.168.1.130
service_description   check_disk_hdal
check_command         check_nrpe!check_hdal
max_check_attempts 5
normal_check_interval 1
}

defineservice{
usegeneric-service
host_name    192.168.1.130
service_description    check_disk_hda2
check_command          check_nrpe!check_hda2
max_check_attempts 5
normal_check_interval 1
}





在客户机上配置:
# vim /etc/nagios/nrpe.cfg

# The following examples use hardcoded command arguments...

command=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1
command=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda2
command=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command=/usr/lib/nagios/plugins/check_procs -w 150 -c 200



# The following examples allow user-supplied arguments and can
检测配置文件是否有错:
#nagios -v /etc/nagios/nagios.cfg





然后客户机上:
# service nrpe restart
Shutting down nrpe:                                        [确定]
Starting nrpe:                                             [确定]
#
然后服务器上:
# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
#


页: [1]
查看完整版本: nagios安装