ganglia 监控

ganglia分布式监控(监控主机的基本信息:CPU,内存,磁盘,进程,负载,网络,交换空间,缓存)
服务端:
下载ganglia-3.4.0.tar.gz   将tar变成rpm包安装
yum install rpm-build -y
rpmbuild  .        此时会在此目录下产生rpmbuild目录
rpmbuild  -tb  ganglia-3.4.0.tar.gz        会报依赖包错误
yum install libart_lgpl-devel gcc-c++ python-devel libconfuse-devel pcre-devel autoconf automake libtool expat-devel rrdtool-devel apr-devel -y
rpmbuild -tb ganglia-3.4.0.tar.gz          还会报错仍需库文件依赖包
下载libconfuse-2.6-3.el6.x86_64.rpm,libconfuse-devel-2.6-3.el6.x86_64.rpm
rpm -ivh libconfuse-2.6-3.el6.x86_64.rpm
rpm -ivh libconfuse-devel-2.6-3.el6.x86_64.rpm
rpmbuild -tb ganglia-3.4.0.tar.gz
cd  /root/rpmbuild/RPMS/x86_64/
ls 会有5个包产生
ganglia-devel-3.4.0-1.x86_64.rpm
ganglia-gmetad-3.4.0-1.x86_64.rpm
ganglia-gmond-3.4.0-1.x86_64.rpm
ganglia-gmond-modules-python-3.4.0-1.x86_64.rpm
libganglia-3.4.0-1.x86_64.rpm
下载ganglia-web-3.5.2.tar.gz
rpmbuild -tb ganglia-web-3.5.2.tar.gz
rpm -ivh libganglia-3.4.0-1.x86_64.rpm
rpm -vih ganglia-gmetad-3.4.0-1.x86_64.rpm
rpm -vih ganglia-gmond-3.4.0-1.x86_64.rpm
cd ../noarch/
rpm -vih ganglia-web-3.5.2-1.noarch.rpm
cd /etc/ganglia/
vim gmetad.conf
data_source "my cluster" localhost
vim gmond.conf  
cluster {
  name = "my cluster"      确保name的名字和gmetad.conf 中的data_source 一样
  owner = "unspecified"
  latlong = "unspecified"
  url = "unspecified"
}
/etc/init.d/gmetad start  服务端
/etc/init.d/gmond start
/etc/init.d/httpd start
浏览器  http://192.168.0.84/ganglia/     注意防火墙,selinux关掉
ganglia 的数据存放目录  /var/lib/ganglia/  
如果将上面的目录删了,则将ganglia-web-3.5.2.tar.gz强制安装

如果想要监控某主机,则需
下载:
ganglia-gmond-3.2.0-1.x86_64.rpm  
ganglia-gmond-modules-python-3.2.0-1.x86_64.rpm
libconfuse-2.6-3.el6.x86_64.rpm
libconfuse-devel-2.6-3.el6.x86_64.rpm
libganglia-3.2.0-1.x86_64.rpm

/etc/init.d/gmond start
浏览器:http://192.168.0.84/ganglia/  进去就可以选择了

实验2:
下载ganglia-3.4.0.tar.gz
tar zxf ganglia-3.4.0.tar.gz
cd ganglia-web-3.5.2/contrib/
cp check_ganglia.py   /usr/local/nagios/libexec/
cd /usr/local/nagios/libexec/
vim check_ganglia.py
if critical > warning:
  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)
else:
  if critical  >= value:
    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)
./check_ganglia.py      检测这个命令
/etc/init.d/gmetad   restart
ll /var/lib/ganglia//rrds/
./check_ganglia.py -h server98.example.com -m mem_free -w 50000 -c 30000  检测
检测时在/var/lib/ganglia/"my cluster"/必须要有server98.example.com目录,而且这个目录内要有mem_free.rrd这个数据文件

cd /usr/local/nagios/etc/objects/
vim  commands.cfg
define  command{
        command_name    check_ganglia
        command_line    $USER1$/check_ganglia.py -h $HOSTNAME$ -m $ARG1$ -w $ARG2$ -c $ARG3$
}
vim templates.cfg
define  service{
        use                             generic-service
        name                            ganglia-service
        hostgroup_name                  ganglia-servers
        service_groups                  ganglia-metrics
}
vim hosts.cfg
define hostgroup{
        hostgroup_name  ganglia-servers ; The name of the hostgroup
        alias           ganglia集群 ; Long name of the group
        members         *     ; Comma separated list of hosts that belong to this group
        }
define host{
        use                     linux-server
        host_name               server84.example.com
        alias                   nagios server
        address                 192.168.0.84
        icon_image              server.gif
        statusmap_image         server.gd2
        2d_coords               500,200
        3d_coords               500,200,100
        }
vim 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
注意将host_name改为fqdn。

你可能感兴趣的:(整合,Ganglia监控,与nagios)