Chinaunix首页 | 论坛 | 博客
  • 博客访问: 861757
  • 博文数量: 189
  • 博客积分: 2267
  • 博客等级: 大尉
  • 技术积分: 1917
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-01 11:17
文章分类

全部博文(189)

文章存档

2016年(16)

2015年(16)

2014年(12)

2013年(32)

2012年(45)

2011年(68)

分类: LINUX

2011-10-12 15:46:30

Nagios+fetion 搭建请参考上篇博文http://blog.chinaunix.net/space.php?uid=26118446&do=blog&id=2952984
这篇文章的环境是基于上篇的环境做的
系统环境:RHEL6.0 IPTABLES & SELINUX DISABLED


     ______                  ___
    / ____/___ _____  ____ _/ (_)___ _
   / / __/ __ `/ __ \/ __ `/ / / __ `/
  / /_/ / /_/ / / / / /_/ / / / /_/ /
  \____/\__,_/_/ /_/\__, /_/_/\__,_/
                   /____/



# yum install -y rpm-build
# rpmbuild -tb ganglia-3.2.0.tar.gz
error: Failed build dependencies:
    libart_lgpl-devel is needed by ganglia-3.2.0-1.x86_64
    gcc-c++ is needed by ganglia-3.2.0-1.x86_64
    python-devel is needed by ganglia-3.2.0-1.x86_64
    libconfuse-devel is needed by ganglia-3.2.0-1.x86_64
    pcre-devel is needed by ganglia-3.2.0-1.x86_64
    autoconf is needed by ganglia-3.2.0-1.x86_64
    automake is needed by ganglia-3.2.0-1.x86_64
    subversion is needed by ganglia-3.2.0-1.x86_64
    libtool is needed by ganglia-3.2.0-1.x86_64
    expat-devel is needed by ganglia-3.2.0-1.x86_64
    rrdtool-devel is needed by ganglia-3.2.0-1.x86_64
    apr-devel > 1 is needed by ganglia-3.2.0-1.x86_64
# rpm -ivh libconfuse-2.6-3.el6.x86_64.rpm  libconfuse-devel-2.6-3.el6.x86_64.rpm
# yum install -y libart_lgpl-devel gcc-c++ python-devel pcre-devel autoconf automake subversion libtool expat-devel rrdtool-devel apr-devel
# rpmbuild -tb ganglia-3.2.0.tar.gz
# cd ~/rpmbuild/RPMS/x86_64/
# ls
ganglia-devel-3.2.0-1.x86_64.rpm   ganglia-gmetad-python-3.2.0-1.x86_64.rpm  ganglia-gmond-modules-python-3.2.0-1.x86_64.rpm
ganglia-gmetad-3.2.0-1.x86_64.rpm  ganglia-gmond-3.2.0-1.x86_64.rpm          libganglia-3.2.0-1.x86_64.rpm
其中ganglia-gmond-3.2.0-1.x86_64.rpm是客户端的安装包,如果需要监控这台主机的话,需要安装这个
而ganglia-gmetad-3.2.0-1.x86_64.rpm 就是服务端需要安装的包了

首先我先装一下服务端[192.168.0.55]
# yum -y install rrdtool php php-gd
# rpm -ivh ganglia-gmetad-3.2.0-1.x86_64.rpm libganglia-3.2.0-1.x86_64.rpm
# rpm -ivh ganglia-gmond-3.2.0-1.x86_64.rpm (装这个只是为了监控自己)
# mkdir -p /var/www/html/ganglia
# tar -xf ganglia-3.2.0.tar.gz
# cd ganglia-3.2.0
# cp -a web/* /var/www/html/ganglia/
# cd /var/www/html/ganglia/
# cp version.php.in version.php
# cp conf.php.in conf.php

# vim /var/www/html/ganglia/conf.php
# Where gmetad stores the rrd archives.
$gmetad_root = "/var/lib/ganglia";
$rrds = "$gmetad_root/rrds";
# Where Dwoo (PHP templating engine) store compiled templates
$dwoo_compiled_dir = "/var/www/html/ganglia/dwoo";

# vim /var/www/html/ganglia/version.php
$ganglia_version = "3.2.0";

# vim /etc/ganglia/gmetad.conf
data_source "ykyx00" localhost
# vim /etc/ganglia/gmond.conf
cluster {
  name = "ykyx00"
…………
}  (这个里边的name 一定要和/etc/ganglia/gmetad.conf 里的data_source 里定义的一样)
# /etc/init.d/gmond start
# /etc/init.d/gmetad start
到这里,我们的ganglia服务器就可以访问拉
http://192.168.0.55/ganglia


客户端:【192.168.0.56】
# rpm -ivh  ganglia-gmond-3.2.0-1.x86_64.rpm
# /etc/init.d/gmond start
这里我们就已经可以看到新加入的这台机子咯,反应很快哦!


集成Nagios+Ganglia
# cp /mnt/ganglia-3.2.0/contrib/check_ganglia.py /usr/local/nagios/libexec/
# vim /usr/local/nagios/libexec/check_ganglia.py
if value >= critical:
    print "CHECKGANGLIA CRITICAL: %s is %.2f" % (metric, value)
    sys.exit(2)
  elif value >= warning:
    print "CHECKGANGLIA WARNING: %s is %.2f" % (metric, value)
    sys.exit(1)
  else:
    print "CHECKGANGLIA OK: %s is %.2f" % (metric, value)
    sys.exit(0)
                   
修改最后几行为以下这样:
 if critical >= value:
    print "CHECKGANGLIA CRITICAL: %s is %.2f" % (metric, value)
    sys.exit(2)
  elif warning >= value:
    print "CHECKGANGLIA WARNING: %s is %.2f" % (metric, value)
    sys.exit(1)
  else:
    print "CHECKGANGLIA OK: %s is %.2f" % (metric, value)
    sys.exit(0)

配置Nagios:
# vim /usr/local/nagios/etc/objects/commands.cfg
# 'check_ganglia' command definition
define command{
        command_name    check_ganglia
        command_line    $USER1$/check_ganglia.py -h $HOSTNAME$ -m $ARG1$ -w $ARG2$ -c $ARG3$
        }
# vim /usr/local/nagios/etc/objects/templates.cfg   (在最后加入一下内容)          
define service{
        use     generic-service
        name    ganglia-service
        hostgroup_name  ganglia-servers
        service_groups  ganglia-metrics
}
# vim /usr/local/nagios/etc/objects/hosts.cfg
define host {
        use linux-server
        host_name       server26.example.com
        address         192.168.0.55
}
define hostgroup {
        hostgroup_name ganglia-servers
        alias   nagios server
        members server26.example.com
}

# vim /usr/local/nagios/etc/objects/services.cfg
define servicegroup {
        servicegroup_name       ganglia-metrics
        alias           Ganglia Metrics
}
define service{
use ganglia-service
service_description load_one
check_command check_ganglia!load_one!4!5
}
define service{
use ganglia-service
service_description disk_free
check_command check_ganglia!disk_free!5!3
}


# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# /etc/init.d/nagios reload

来几张破图给你们看看


自我感觉写的很烂,希望各位帮忙优化!thank you!

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

上一篇:RHEL6.0+Nagios+fetion

下一篇:RHEL6.0+VPN

给主人留下些什么吧!~~
评论热议
请登录后评论。

登录 注册