歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> VMware Linux下Nagios的安裝

VMware Linux下Nagios的安裝

日期:2017/3/1 11:45:37   编辑:關於Linux

這次配置主要是了解nagios的工作流程,為以後更為復雜的設置打基礎!
配置的環境為之前《VMware Linux下Nagios的安裝》見 http://www.linuxidc.com/Linux/2011-11/47908.htm 設置出來的
[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 //格式很重要的
}

Copyright © Linux教程網 All Rights Reserved