Chinaunix首页 | 论坛 | 博客
  • 博客访问: 599192
  • 博文数量: 248
  • 博客积分: 52
  • 博客等级: 民兵
  • 技术积分: 1028
  • 用 户 组: 普通用户
  • 注册时间: 2012-12-23 12:05
文章分类

全部博文(248)

文章存档

2016年(7)

2013年(241)

分类:

2013-01-08 15:25:40

原文地址:nagios 作者:sswqzx

系统:redhat linux as 4 2.6.9
:nagios 监控安装配置
准备软件:nagios-2.6.tar.gz  nagios-plugins-1.4.9.tar.gz
Linux 安装完系统后默认是可以发送邮件的。(我在安装系统的时候开启了mail服务,以及安装了开发环境软件)
(1):添加nagios用户及组
[root@linux etc]# groupadd nagios
[root@linux etc]# useradd -g nagios -d /usr/local/nagios -s /bin/false nagios
(2):解压,安装nagios
[root@linux nagios]# tar zxvf nagios-2.6.tar.gz
[root@linux nagios-2.6]# ./configure --prefix=/usr/local/nagios
[root@linux nagios-2.6]# make all
[root@linux nagios-2.6]# make install
[root@linux nagios-2.6]# make install-init
[root@linux nagios-2.6]# make install-commandmode
[root@linux nagios-2.6]# make install-config
安装nagios的插件
[root@linux nagios]# tar zxvf nagios-plugins-1.4.9.tar.gz
[root@linux nagios-plugins-1.4.9]# ./configure --prefix=/usr/local/nagios/
(在redhat系统上面安装可能出现configure时,到这里checking for redhat spopen problem...就不动了,所以需要在configure时再加上这个 --enable-redhat-pthread-workaround )
[root@linux nagios-plugins-1.4.9]# make
[root@linux nagios-plugins-1.4.9]# make install
(3):配置apache
配置apache的匿名访问:
[root@linux conf.d]# touch nagios.conf  | vi nagios
  [root@linux apache]# ./bin/htpasswd -c /usr/local/apache/conf.d/htpasswd nagiosadmin
启动apache测试,访问  [url][/url]
入禁止访问:将apache的用户和组改为nagios。。
如果认证无法通过的话,就查看apache的错误日志,如果出现MySQL ERROR: Table 'test.user_info' doesn't exist: /nagios的提示,就把 http 下的auth_mysql.conf 配置文件该了。不让apache进行mysql认证。
(4):配置nagios
[root@linux etc]# cp cgi.cfg-sample cgi.cfg
[root@linux etc]# cp commands.cfg-sample commands.cfg
[root@linux etc]# cp nagios.cfg-sample nagios.cfg
[root@linux etc]# cp resource.cfg-sample resource.cfg
[root@linux etc]# vi nagios.cfg
#cfg_file=/usr/local/nagios/etc/localhost.cfg 关闭
开启
cfg_file=/usr/local/nagios/etc/contactgroups.cfg
cfg_file=/usr/local/nagios/etc/contacts.cfg
cfg_file=/usr/local/nagios/etc/dependencies.cfg 此配置文件可以提供先前条件,比如当sina通的情况下,测试业务服务器状态。
cfg_file=/usr/local/nagios/etc/hostgroups.cfg
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
cfg_file=/usr/local/nagios/etc/timeperiods.cfg
command_check_interval=10s
[root@linux etc]# touch contactgroups.cfg
[root@linux etc]# touch contacts.cfg
[root@linux etc]# touch hostgroups.cfg
[root@linux etc]# touch hosts.cfg
[root@linux etc]# touch services.cfg
[root@linux etc]# touch timeperiods.cfg
[root@linux etc]# vi cgi.cfg
开启且编辑
authorized_for_system_information=nagiosadmin,bard
authorized_for_configuration_information=nagiosadmin,bard
authorized_for_system_commands=nagiosadmin,bard
authorized_for_all_services=nagiosadmin,bard
authorized_for_all_hosts=nagiosadmin,bard
authorized_for_all_service_commands=nagiosadmin,bard
authorized_for_all_host_commands=nagiosadmin,bard
[root@linux etc]# vi timeperiods.cfg
# 'workhours' timeperiod definition
define timeperiod{
        timeperiod_name workhours
        alias           "Normal" Working Hours
        monday          09:00-18:00
        tuesday         09:00-18:00
        wednesday       09:00-18:00
        thursday        09:00-18:00
        friday          09:00-18:00
        }
 
 
# 'nonworkhours' timeperiod definition
define timeperiod{
        timeperiod_name nonworkhours
        alias           Non-Work Hours
        sunday          00:00-24:00
        monday          00:00-09:00,18:00-24:00
        tuesday         00:00-09:00,18:00-24:00
        wednesday       00:00-09:00,18:00-24:00
        thursday        00:00-09:00,18:00-24:00
        friday          00:00-09:00,18:00-24:00
        saturday        00:00-24:00
        }
[root@linux etc]# vi contacts.cfg
# 'nagios' contact definition
 
define contact{
        contact_name                    bard
        alias                           Admin
        service_notification_period     workhours
        host_notification_period        workhours
        service_notification_options    w,u,c,r
        host_notification_options       d,u,r
        service_notification_commands   notify-by-email
        host_notification_commands      host-notify-by-email
        email                          

        }
[root@linux etc]# vi contactgroups.cfg
define contactgroup{
        contactgroup_name       inner-admins
        alias                   Administrators
        members                 bard
        }
[root@linux etc]# vi hosts.cfg
define host{
        name                            generic-host    ; The name of this host template - referenced in other host definitio
ns, used for template recursion/resolution
        notifications_enabled           1       ; Host notifications are enabled
        event_handler_enabled           0       ; Host event handler is disabled
        flap_detection_enabled          0       ; Flap detection is disabled
        process_perf_data               1       ; Process performance data
        retain_status_information       1       ; Retain status information across program restarts
        retain_nonstatus_information    1       ; Retain non-status information across program restarts
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        max_check_attempts      10
        notification_interval   30
        notification_period     24x7
        notification_options    d,u,r
        check_command           check-host-alive
        }
 
 
define host{
        use                     generic-host
        host_name               192.168.1.226
        alias                   gate way
              contact_groups                   inner-admins
        address                 192.168.1.226
        }
[root@linux etc]# vi hostgroups.cfg
define hostgroup{
        hostgroup_name  inner
        alias           inner server
        members         192.168.1.226
        }
[root@linux etc]# vi services.cfg
define service{
        name                            ping
        active_checks_enabled           1       ; Active service checks are enabled
        passive_checks_enabled          0       ; Passive service checks are enabled/disabled
        parallelize_check               1       ; Active service checks should be parallelized
                                                ; (disabling this can lead to major performance problems)
        obsess_over_service             1       ; We should obsess over this service (if necessary)
        check_freshness                 0       ; Default is to NOT check service 'freshness'
        notifications_enabled           1       ; Service notifications are disabled
        event_handler_enabled           0       ; Service event handler is disabled
        flap_detection_enabled          0       ; Flap detection is disabled
        process_perf_data               1       ; Process performance data
        retain_status_information       1       ; Retain status information across program restarts
        retain_nonstatus_information    1       ; Retain non-status information across program restarts
 
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        notification_interval           30
        notification_period             workhours
        notification_options            w,u,c,r
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              5
        normal_check_interval           5
        retry_check_interval            1
        service_description             PING
        check_command                   check_ping!10000.0,100%!50000.0,100%
        }
define service{
        use ping
        host_name 192.168.1.226
        contact_groups inner-admins
        }
配置完后测试配置是否成功:
服务器的配置文件已复制出来备份。随本文档查看。
[root@linux etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
出现:Total Warnings: 0
Total Errors:   0
 
Things look okay - No serious problems were detected during the pre-flight check
如果配置有错误,可以参考localhost.cfg
表示成功。然后启动:
[root@linux etc]# /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
阅读(605) | 评论(0) | 转发(0) |
0

上一篇:linux 下查看硬件信息

下一篇:linux Samba

给主人留下些什么吧!~~