VMware Linux下Nagios的基本配置


这次配置主要是了解nagios的工作流程,为以后更为复杂的设置打基础!

配置的环境为之前《VMware Linux下Nagios的安装》见  设置出来的

[root@localhost ~]# cd /usr/local/nagios/etc/objects/

[root@localhost objects]# ll
total 88
-rw-rw-r-- 1 nagios nagios  7716 May 11  2011 commands.cfg(全局的命令的设置档案)
-rw-rw-r-- 1 nagios nagios  2167 Feb 15 04:20 contacts.cfg(联系方式的设置档)
-rw-rw-r-- 1 nagios nagios   305 Feb 15 04:46 host.cfg(对主机的监控设置,本来不存在是自己创建的)
-rw-rw-r-- 1 nagios nagios  5403 May 11  2011 localhost.cfg(本机的监控设置)
-rw-rw-r-- 1 nagios nagios  3124 May 11  2011 printer.cfg(对打印机的监控设置)
-rw-r--r-- 1 root   root    1768 Feb 15 04:36 services.cfg(对主机的服务的监控设置,本来不存在是自己创建的)
-rw-rw-r-- 1 nagios nagios  3293 May 11  2011 switch.cfg(对路由器的监控设置)
-rw-rw-r-- 1 nagios nagios 10812 May 11  2011 templates.cfg(全局的监控模板)
-rw-rw-r-- 1 nagios nagios  3209 May 11  2011 timeperiods.cfg(全局的时间设置)
-rw-rw-r-- 1 nagios nagios  4019 May 11  2011 windows.cfg(对windows主机控制的限制)

这里的配置流程是,在全局的配置档案中设置好相应的控制命令(宏的形式),另外在设置相应的监控设置档案的时候,调用全局的配置档案的设置,来完成对主机和服务的监控!

下边是一个自己配置的小实例

[root@localhost ~]# cd /usr/local/nagios/etc/objects/
[root@localhost objects]# vi host.cfg (设置控制主机)
define host{
        use linux-server(设置监控的主机类型,调用在templates.cfg中有对这种类型的定义)
        host_name web(设置主机的名称)
        alias     nagiosadmin-web(设置别名)
        address   192.168.1.122(主机的地址)
}

define host{
        use  linux-server
        host_name   mysql
        alias       nagiosadmin-mysql
        address     192.168.1.122
}

define hostgroup{(设置主机组)
        hostgroup_name   sa-servers
        alias   sa servers
        members web,mysql
}


[root@localhost objects]# vi services.cfg (设置控制的服务)
#####################   web   ###########################
define service{
        use                    local-service    //调用templates.cfg中对local-service的定义
        host_name              web      //设置服务对应的主机名
        service_description    PING    //服务的类型
        check_command          check_ping!100.0.20%!500.0.60%   //调用,command.cfg对check_ping的定义
}

define service{
        use                     local-service
        host_name               web
        service_description     SSH
        check_command           check_ssh
}

define service{
        use                     local-service
        host_name               web
        service_description     SSHD
        check_command           check_tcp!22
}

######################   mysql  ########################
define service{
        use                     local-service
        host_name               mysql
        service_description     PING
        check_command           check_ping!100.0.20%!500.0.60%
}
define service{
        use                     local-service
        host_name               mysql
        service_description     SSH
        check_command           check_ssh
}
define service{
        use                     local-service
        host_name               mysql
        service_description     ftp
        check_command           check_ftp
}
define service{
        use                     local-service
        host_name               mysql
        service_description     mysqlport
        check_command           check_tcp!3306
}
define servicegroup{  //设置服务的工作组
        servicegroup_name       servicegroup
        alias                   service-group
        members                 web,PING,web,SSH,web,SSHD,mysql,PING,mysql,SSH,mysql,ftp,mysql,mysqlport   //格式很重要的
}

  • 1
  • 2
  • 下一页

相关内容