nagios实例配置1
来源:互联网 发布:淘宝助理5.4 编辑:程序博客网 时间:2024/06/03 18:51
Nagios配置文件
1.1配置文件
[root@153-201HP ~]# ls -l /usr/local/nagios/etc/总用量 144
-rw-rw-r-- 1 nagios nagios 11408 1月 2 18:24 cgi.cfg #CGI 配置文件
-rw-r--r-- 1 root root 26 1月 2 17:38 htpasswd.users #Apache 验证密码文件
-rw-r--r-- 1 root root 85679 1月 13 16:06 nagios.cfg #Nagios 主配置文件
drwxrwxr-x 2 nagios nagios 36864 1月 20 14:43 objects #监控对象定义文件目录
-rw-rw---- 1 nagios nagios 1340 1月 2 18:24 resource.cfg #Nagios资源配置文件
1.2主配置文件
在主配置文件里,我们可以指定主机、主机组、服务、服务组、命令、通知人、通知人组等配置文件的位置。[root@153-201HP ~]# vim /usr/local/nagios/etc/nagios.cfg
log_file=/usr/local/nagios/var/nagios.log
# You can specify individual object config files as shown below:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg #命令配置文件
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg #联系人配置文件
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/hostgroups.cfg #增加主机组配置文件
cfg_file=/usr/local/nagios/etc/objects/commands.cfg #命令配置文件
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg #联系人配置文件
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/hostgroups.cfg #增加主机组配置文件
#cfg_file=/usr/local/nagios/etc/objects/services.cfg
#cfg_file=/usr/local/nagios/etc/objects/servicegroups.cfg
# Definitions for monitoring the local (Linux) host
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
#cfg_file=/usr/local/nagios/etc/objects/servicegroups.cfg
# Definitions for monitoring the local (Linux) host
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cfg_file=/usr/local/nagios/etc/objects/news_172.172.172.172.cfg #增加主机配置文件
cfg_file=/usr/local/nagios/etc/objects/news_173.173.173.173.cfg #增加主机配置文件
cfg_file=/usr/local/nagios/etc/objects/news_173.173.173.173.cfg #增加主机配置文件
1.3对象定义文件
对象定义文件是管理员经常需要修改的配置文件,用于定义主机、服务、主机组、服务组、联系人、联系人组、命令等等,也就是要定义监控的对象和监控的方法。
对象定义文件有两种基本写法,例如监控一台 Linux服务器。
方法一:将该主机写入主机定义文件,将要监控的服务写到服务定义文件中,前提是在 Nagios的主配置文件里需要定义这两个配置文件。
方法二:将该主机的配置写入到一个如【主机名】.cfg 文件里,然后再 Nagios 的主配置文件里定义这个配置文件。
这两种方法的选择要根据实际情况,方法一由于主机数的增加会增加配置文件的管理难度,文件内容多,容易出现配置错误等问题。
方法二由于是每个监控主机一个配置文件,这样虽然清晰明了,但对于想结构化管理的用户不太方便。
[root@153-201HP ~]# vim /usr/local/nagios/etc/objects/news_172.172.172.172.cfg
# Define a host for the local machine
define host{
use linux-server
host_name NEWS_172.172.172.172
alias nagios_host_NEWS
address 172.172.172.172
check_period 24x7
check_interval 5
retry_interval 2
max_check_attempts 4
check_command check-host-alive
notifications_enabled 1
notification_period 24x7
notification_interval 0
notification_options d,r
contact_groups admins
}
define host{
use linux-server
host_name NEWS_172.172.172.172
alias nagios_host_NEWS
address 172.172.172.172
check_period 24x7
check_interval 5
retry_interval 2
max_check_attempts 4
check_command check-host-alive
notifications_enabled 1
notification_period 24x7
notification_interval 0
notification_options d,r
contact_groups admins
}
# Define a service to "ping" the local machine
define service{
use local-service ; Name of service template to use
host_name NEWS_172.172.172.172
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use local-service ; Name of service template to use
host_name NEWS_172.172.172.172
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use local-service ; Name of service template to use
host_name NEWS_172.172.172.172
service_description URL1
check_period 24x7
max_check_attempts 4
normal_check_interval 3
contact_groups admins
retry_check_interval 2
notification_interval 0
notification_period 24x7
notification_options c,r
notifications_enabled 1
check_command check_http_u!"news.sina.com.cn"!"/"
}
use local-service ; Name of service template to use
host_name NEWS_172.172.172.172
service_description URL1
check_period 24x7
max_check_attempts 4
normal_check_interval 3
contact_groups admins
retry_check_interval 2
notification_interval 0
notification_period 24x7
notification_options c,r
notifications_enabled 1
check_command check_http_u!"news.sina.com.cn"!"/"
}
1.4 主机组配置文件
[root@153-201HP ~]# vim /usr/local/nagios/etc/objects/hostgroups.cfg
define hostgroup{
hostgroup_name news
alias NEWS
members NEWS_172.172.172.172,NEWS_172.172.172.173
hostgroup_name news
alias NEWS
members NEWS_172.172.172.172,NEWS_172.172.172.173
}
#members成员与主机配置文件中保持一致1.5 联系人定义文件
[root@153-201HP ~]# vim /usr/local/nagios/etc/objects/contacts.cfg
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
service_notification_period 24x7
host_notification_period 24x7
service_notification_options c,r
host_notification_options d,r
service_notification_commands service-notify-by-email,service-notify-by-sms
host_notification_commands host-notify-by-email,host-notify-by-sms
email youremail@hotmail.com,youremail@163.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
pager 13738777777
}
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
service_notification_period 24x7
host_notification_period 24x7
service_notification_options c,r
host_notification_options d,r
service_notification_commands service-notify-by-email,service-notify-by-sms
host_notification_commands host-notify-by-email,host-notify-by-sms
email youremail@hotmail.com,youremail@163.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
pager 13738777777
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
1.6 启动
1> 修改配置文件所有者
[root@Nagios-Server ~]# chown -R nagios:nagios /usr/local/nagios/etc/objects/
2> 检测配置是否正确
[root@Nagios-Server ~]#
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
3> 启动 Nagios
[root@Nagios-Server ~]# /etc/init.d/httpd restart
0 0
- nagios实例配置1
- Nagios - 配置
- nagios配置
- nagios配置
- nagios实例配置2-关于nagios 的check_http 监控报警的设置
- nagios安装和配置(1)
- Nagios 监控实例部署
- nagios配置难点
- nagios安装与配置
- nagios基本配置介绍
- Nagios配置说明
- Redhat 5.2 配置nagios
- nagios安装与配置
- nagios简易安装配置
- nagios前段配置工具
- Nagios 编译配置
- nagios+nrpe安装配置
- nagios配置安装笔记
- C++等级考试第一套题遇到的问题
- 四元数姿态解算中的地磁计融合解读
- java的小程序!
- 没变强是因为你太舒服(图)
- 黑马程序员-OC语言基础学习(五)
- nagios实例配置1
- 航空售票例子之服务器端的线程设计
- linux grep
- VC++内存泄露检查
- nsinteger 和int
- Hadoop学习之MapReduce(四)
- 静态成员变量初始化问题。关于 error LNK2005 static int:已经在***.obj中定义
- UIActivtyViewController
- delphi 对象与类类型