Chinaunix首页 | 论坛 | 博客
  • 博客访问: 196851
  • 博文数量: 37
  • 博客积分: 510
  • 博客等级: 入伍新兵
  • 技术积分: 230
  • 用 户 组: 普通用户
  • 注册时间: 2011-10-02 19:49
文章分类

全部博文(37)

文章存档

2011年(37)

分类:

2011-10-09 22:17:40

原文地址:Nagios 作者:ykyx00

系统环境 RHEL6.0  IPTABLES & SELINUX disabled
软件环境  nagios-cn-3.2.3 nagios-plugins-1.4.15
# yum -y install httpd gcc make gd-devel perl-ExtUtils-Embed mysql-devel openssl-devel
# useradd nagios  //运行nagios服务时候需要的用户
# usermod -G nagios apache   //把apache用户加到nagios 组,使apache 用户对nagios 目录具有访问权限
# tar xf nagios-cn-3.2.3.tar.bz2
# cd nagios-cn-3.2.3
# ./configure --enable-embedded-perl
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# make install-webconf

#tar xf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-extra-opts --enable-libtap --enable-perl-modules && make && make install
# /etc/init.d/nagios start
# 我们查看 /etc/httpd/conf.d/nagios.conf 可以看到密码文件存在 /usr/local/nagios/etc/htpasswd.users ,由于不知道默认密码,我重新改一下
# htpasswd -m /usr/local/nagios/etc/htpasswd.users nagiosadmin
# cat /usr/local/nagios/etc/htpasswd.users
nagiosadmin:$apr1$TJKw1i5d$JjkMqegG/vU4VRbey/0Re.
可以访问一下我们的Nagios 服务器的界面了,

这个只能算以前的模板了,我们需要修改成自己的网络环境,我这里演示一个比较简单的
# vim /usr/local/nagios/etc/nagios.cfg
注释掉这行,添加下边两行#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg

# vim /usr/local/nagios/etc/objects/hosts.cfg
define host{
        use                     linux-server
        host_name               server26
        alias                   nagios server
        address                 192.168.0.73
        icon_image              switch.gif
        statusmap_image         switch.gd2
        2d_coords               100,200
        3d_coords               100,200,100
        }
define host{
        use                     linux-server
        host_name               localhost
        alias                   nagios server
        address                 192.168.0.73
        icon_image              switch.gif
        statusmap_image         switch.gd2
        2d_coords               200,400
        3d_coords               200,400,200
        }
define hostgroup{
        hostgroup_name  linux-servers
        alias           Linux Servers
        members         *
        }
# vim /usr/local/nagios/etc/objects/services.cfg
define service{
        use                             local-service
        host_name                       *
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }
define service{
        use                             local-service
        host_name                       server26
        service_description             根分区
        check_command                   check_local_disk!20%!10%!/
        }
define service{
        use                             local-service
        host_name                       server26
        service_description             登录用户数
        check_command                   check_local_users!20!50
        }
define service{
        use                             local-service
        host_name                       server26
        service_description             进程总数
        check_command                   check_local_procs!250!400!RSZDT
        }

define service{
        use                             local-service
        host_name                       server26
        service_description             系统负荷
        check_command                   check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
        }
define servicegroup{
        servicegroup_name 全部联通性检查
        alias 联通性检查
        }
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors:   0
看到这两个0,恭喜你配置没有问题

阅读(997) | 评论(0) | 转发(0) |
0

上一篇:RHCE~我来了

下一篇:Cacti 监控

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