nagios 服务端安装

[root@localhost ~]# yum install -y epel-release ; yum install -y httpd nagios nagios-plugins nagios-plugins-all nrpe nagios-plugins-nrpe

[root@localhost ~]# htpasswd -c /etc/nagios/passwd nagiosadmin

[root@localhost ~]# nagios -v /etc/nagios/nagios.cfg

[root@localhost ~]# /etc/init.d/httpd restart ; /etc/init.d/nagios restart


web  访问  http://192.168.10.29/nagios/


nagios客户端安装-添加服务1(不需要nrpe支持)

[root@localhost ~]# yum install -y epel-release ; yum install -y nagios-plugins nagios-plugins-all nrpe nagios-plugins-nrpe

[root@localhost ~]# vi /etc/nagios/nrpe.cfg

allowed_hosts=127.0.0.1,192.168.10.29

dont_blame_nrpe=1

以下在服务端操作

[root@localhost ~]# vi /etc/nagios/conf.d/192.168.10.39.cfg

define host {

        use     linux-server

        host_name       192.168.10.39

        alias   10.39

        address 192.168.10.39

        }


define service {

        use     generic-service

        host_name       192.168.10.39

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

        service_description     check_ssh

        check_command   check_ssh

        max_check_attempts      5

        normal_check_interval   1

        }

[root@localhost ~]# /etc/init.d/nagios restart


nagios客户端安装-添加服务2(需要nrpe支持)

以下在服务端操作

[root@localhost ~]# vi /etc/nagios/objects/commands.cfg

define command {

        command_name    check_nrpe

        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

        }

[root@localhost ~]# vi /etc/nagios/conf.d/192.168.10.39.cfg

define host {

        use     linux-server

        host_name       192.168.10.39

        alias   10.39

        address 192.168.10.39

        }


define service {

        use     generic-service

        host_name       192.168.10.39

        service_description     check_load

        check_command   check_nrpe!check_load

        max_check_attempts      5

        normal_check_interval   1

        }


define service {

        use     generic-service

        host_name       192.168.10.39

        service_description     check_disk_sda1

        check_command   check_nrpe!check_sda1

        max_check_attempts      5

        normal_check_interval   1

        }

[root@localhost ~]# /etc/init.d/nagios restart

[root@localhost ~]# /etc/init.d/nrpe restart

以下在客户端操作

[root@localhost ~]# vi /etc/nagios/nrpe.cfg

command[check_sda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1

[root@localhost ~]# /etc/init.d/nrpe restart


至此,nagios搭建完毕