4 月 172013
 

确定将要使用的在templates.cfg已定义的主机模板

在主配置文件中取消注释以下内容

 #cfg_dir=/usr/local/nagios/etc/servers

创建目录

[root@monitor objects]# mkdir ../servers
 [root@monitor objects]# chown -R nagios.nagios ../servers/
 [root@monitor objects]# chmod -R 775 ../servers/

创建主机组配置文件szvs.cfg并添加主机

define hostgroup{
 hostgroup_name  v-servers
 alias           Virtualization Servers
 members         szvs-v01
 }

创建主机配置文件szvs-v01.cfg

定义主机部分,使用linux-server主机模板

define host{
 use                     linux-server
 host_name               szvs-v01
 alias                   app
 address                 192.168.1.90
 }

定义服务部分

引用的服务模板generic-service来自模板配置文件

define service{
 use                             generic-service
 host_name                       szvs-v01
 service_description             PING
 check_command                   check_ping!100.0,20%!500.0,60%
 notifications_enabled           0
 }
define service{
 use                             generic-service
 host_name                       szvs-v01
 service_description             HTTP
 check_command                   check_http
 notifications_enabled           0
 }

检测当前配置文件正确性

[root@monitor objects]# ../../bin/nagios -v ../nagios.cfg

Nagios Core 3.5.0
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 03-15-2013
License: GPL

Website: http://www.nagios.org
Reading configuration data…
Read main config file okay…
Processing object config file ‘/usr/local/nagios/etc/objects/commands.cfg’…
Processing object config file ‘/usr/local/nagios/etc/objects/contacts.cfg’…
Processing object config file ‘/usr/local/nagios/etc/objects/timeperiods.cfg’…
Processing object config file ‘/usr/local/nagios/etc/objects/templates.cfg’…
Processing object config file ‘/usr/local/nagios/etc/objects/localhost.cfg’…
Processing object config directory ‘/usr/local/nagios/etc/servers’…
Processing object config file ‘/usr/local/nagios/etc/servers/szvs.cfg’…
Processing object config file ‘/usr/local/nagios/etc/servers/szvs-v01.cfg’…
Read object config files okay…

Running pre-flight check on configuration data…

Checking services…
Checked 9 services.
Checking hosts…
Checked 2 hosts.
Checking host groups…
Checked 2 host groups.
Checking service groups…
Checked 0 service groups.
Checking contacts…
Checked 1 contacts.
Checking contact groups…
Checked 1 contact groups.
Checking service escalations…
Checked 0 service escalations.
Checking service dependencies…
Checked 0 service dependencies.
Checking host escalations…
Checked 0 host escalations.
Checking host dependencies…
Checked 0 host dependencies.
Checking commands…
Checked 24 commands.
Checking time periods…
Checked 5 time periods.
Checking for circular paths between hosts…
Checking for circular host and service dependencies…
Checking global event handlers…
Checking obsessive compulsive processor commands…
Checking misc settings…

Total Warnings: 0
Total Errors:   0

Things look okay – No serious problems were detected during the pre-flight check
[root@monitor objects]#

重启nagios服务

[root@monitor objects]# service nagios restart
 Running configuration check...done.
 Stopping nagios: .done.
 Starting nagios:This account is currently not available.
 done.
 [root@monitor objects]#

查看重启以后的nagios日志信息

nagios-config-01-01

 

查看主机地图

nagios-config-01-02

查看主机列表

nagios-config-01-03

查看服务列表

nagios-config-01-04

 

 

查看主机组列表

nagios-config-01-05

检测项目的任务队列

首次添加的任务显示为PENDING状态,等待检测

nagios-config-01-06

查看任务队列中的检测时间排列

nagios-config-01-07

成功执行新添加的HTTP服务检测nagios-config-01-08

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据