<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Young for you]]></title> 
<link>179401.cn/index.php</link> 
<description><![CDATA[吃好喝好！喝好吃好]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Young for you]]></copyright>
<item>
<link>179401.cn/read.php?10</link>
<title><![CDATA[linux下ganglia监控系统搭建]]></title> 
<author> &lt;&gt;</author>
<category><![CDATA[监控]]></category>
<pubDate>Mon, 25 May 2009 11:26:44 +0000</pubDate> 
<guid>179401.cn/read.php?10</guid> 
<description>
<![CDATA[ 
	Ganglia监控软件主要是用来监控系统性能的软件，如：cpu 、mem、硬盘利用率， I/O负载、网络流量情况等，通过曲线很容易见到每个节点的工作状态，对合理调整、分配系统资源，提高系统整体性能起到重要作用。支持浏览器方式访问，但不能监控节点硬件技术指标，ganglia 是分布式的监控系统，有两个Daemon, 分别是：客户端Ganglia Monitoring Daemon (gmond)和服务端Ganglia Meta Daemon (gmetad)，还有Ganglia PHP Web Frontend（基于web的动态访问方式）组成。是一个Linux下图形化监控系统运行性能的软件，界面美观、丰富，功能强大。RRDtool是系统存放和显示time-series (即网络带宽、温度、人数、服务器负载等) 。并且它提出有用的图表由处理数据强制执行有些数据密度。<br/>Ganglia 是 UC Berkeley 发起的一个开源监视项目，设计用于测量数以千计的节点。每台计算机都运行一个收集和发送度量数据（如处理器速度、内存使用量等）的名为 gmond 的守护进程。它将从操作系统和指定主机中收集。接收所有度量数据的主机可以显示这些数据并且可以将这些数据的精简表单传递到层次结构中。正因为有这种层次结构模式，才使得 Ganglia 可以实现良好的扩展。gmond 带来的系统负载非常少，这使得它成为在集群中各台计算机上运行的一段代码，而不会影响用户性能。<br/><hr/>1、lap（linux+apache+php）（略）<br/>2、需要的软件包<br/>通过yum源安装，系统光盘就有：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">yum -y install apr-devel apr-util check-devel cairo-devel pango-devel libxml2-devel rpmbuild glib2-devel dbus-devel freetype-devel fontconfig-devel gcc-c++ expat-devel python-devel libXrender-devel</div></div><br/>3、安装libconfuse<br/>32位os下载：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">wget http://download.fedora.redhat.com/pub/epel/5/i386/libconfuse-2.5-4.el5.i386.rpm<br/>wget http://download.fedora.redhat.com/pub/epel/5/i386/libconfuse-devel-2.5-4.el5.i386.rpm</div></div><br/>64位os下载：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">wget http://download.fedora.redhat.com/pub/epel/5/x86_64/libconfuse-2.5-4.el5.x86_64.rpm<br/>wget http://download.fedora.redhat.com/pub/epel/5/x86_64/libconfuse-devel-2.5-4.el5.x86_64.rpm</div></div><br/>安装<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">rpm –ivh libconfuse-2.5-4.el5.i386.rpm libconfuse-devel-2.5-4.el5.i386.rpm</div></div><br/>4、安装RRDTool<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">wget http://oss.oetiker.ch/rrdtool/pub/rrdtool.tar.gz<br/>tar zxvf rrdtool*<br/>cd rrdtool-*<br/>./configure --prefix=/usr<br/>make<br/>make install</div></div><br/>5、安装ganglia<br/>到http://ganglia.info网站下载最新版的ganglia，这里以3.1.2版为例<br/>这里编译安装的时候需要注意：<br/>安装之前用以下命令检查有没有rrd.h和librrd.a文件：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">ll /usr/include/rrd.h<br/>ll /usr/lib/librrd.a</div></div><br/>如果存在以上两个文件，则继续安装否则使用find命令查找这两个文件，并创建指向这两个文件的软链接<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">find / -name rrd.h<br/>find / -name librrd.a</div></div><br/>比如说你找到的文件在/usr/local/下，则：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">ln -s /usr/local/rrd.h /usr/include/rrd.h<br/>ln -s /usr/local/librrd.a /usr/lib/librrd.a</div></div><br/>安装：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">tar –zxvf ganglia-3.1.2.tar.gz<br/>cd ganglia-3.1.2.tar.gz<br/>./configure --with-gmetad<br/>make<br/>make install</div></div><br/>如果安装过程中出现读取相关lib文件读取错误，请在/usr/lib(32os)或/usr/lib64下查找是否存在该lib文件，如果不存在，查找该文件并在/usr/lib(32os)或/usr/lib64创建指向该lib文件的软链接。<br/>6、配置ganglia<br/>step 1、处理命令行文件<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">cd /tmp/ganglia-3.1.2/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //假设你的ganglia在此目录<br/>mkdir -p /var/www/html/ganglia/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //创建网站主目录下ganglia文件夹，用来访问ganglia<br/>cp -a web/* /var/www/html/ganglia/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //拷贝ganglia网站代码到该目录<br/>cp gmetad/gmetad.init /etc/rc.d/init.d/gmetad&nbsp;&nbsp;&nbsp;&nbsp; //拷贝gmetad服务启动脚本<br/>cp gmond/gmond.init /etc/rc.d/init.d/gmond&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//拷贝gmond服务启动脚本<br/>mkdir /etc/ganglia&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //创建配置文件主目录<br/>gmond -t &#124; tee /etc/ganglia/gmond.conf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//生成gmond服务配置文件<br/>cp gmetad/gmetad.conf /etc/ganglia/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//拷贝gmetad服务配置文件<br/>mkdir -p /var/lib/ganglia/rrds&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//创建rrd文件存放目录<br/>chown nobody:nobody /var/lib/ganglia/rrds&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //属主和属组都为nobody<br/>chkconfig --add gmetad&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //将服务交给chkconfig管理<br/>chkconfig --add gmond&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//同上</div></div><br/>step 2、修改 /etc/ganglia/gmond.conf<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">vi /etc/ganglia/gmond.conf //修改以下字段<br/>cluster &#123;<br/>name = "cluster name" //你要监控的集群名，一般我们只改这一项，可以是任意值<br/>owner = " unspecified " <br/>latlong = "unspecified" <br/>url = "unspecified"<br/>&#125;</div></div><br/>step3、关于两块网卡服务器的设置<br/>如果你的服务器有两块网卡，eth0使用公网地址，eth1使用局域网地址，而你的监控服务器和被监控服务器之间的通信你希望通过局域网地址实现以减少公网网卡的负载，那么可以使用以下命令：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">ip route add 239.2.11.71 dev eth1</div></div><br/>因为239.2.11.71是ganglia默认的多点传输通道，所以要加一条路由使它通过eth1,也就是内网网卡，239.2.11.71这个地址你可以在/etc/ganglia/gmond.conf中修改<br/>step4、启动服务<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">service gmond start<br/>service gmetad start<br/>service httpd restart</div></div><br/>这时服务端的配置已经结束，通过网页http://You_IP/ganglia已经可以访问，并且可以监控到监控服务器的信息。<br/>7、客户端的配置<br/>在监控服务器编写一个脚本文件，执行它可以将服务快速的发布到被监控主机上<br/>step1、首先编写一个主机地址文件：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">vi mynodes</div></div><br/>添加你的主机名或服务器ip到该文件，我这里只写了5台主机<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">192.168.10.1<br/>192.168.10.2<br/>192.168.10.3<br/>192.168.10.4<br/>192.168.10.5</div></div><br/>step2、编写脚本实现服务的发布<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">vi ganglia.sh</div></div><br/>使用以下内容，这里使用的是64位OS，如果是32位OS，将下面的lib64改为lib<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">for i in `cat mynodes`; do <br/>scp /usr/bin/gmetric $i:/usr/bin<br/>scp /usr/sbin/gmond $i:/usr/sbin/gmond<br/>ssh $i mkdir -p /etc/ganglia/<br/>scp /etc/ganglia/gmond.conf $i:/etc/ganglia/<br/>scp /etc/init.d/gmond $i:/etc/init.d/<br/>scp /usr/lib64/libganglia-3.1.2.so.0 $i:/usr/lib64/<br/>scp /lib64/libexpat.so.0 $i:/lib64/<br/>scp /usr/lib64/libconfuse.so.0 $i:/usr/lib64/<br/>scp /usr/lib64/libapr-1.so.0 $i:/usr/lib64/<br/>scp -r /usr/lib64/ganglia $i:/usr/lib64/<br/>ssh $i service gmond start<br/>done</div></div><br/>step3、赋予脚本可执行权限并执行<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">chmod 755 ganglia.sh<br/>./ganglia.sh</div></div><br/>至此ganglia客户端和服务器端的配置完成，可以通过web访问来监控你的群集了<br/>8、使用gmetric定制你自己要监控的信息<br/>step1、在使用gmetric前要确定自己被监控服务器有gmetric<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">ll /usr/bin/gmetric</div></div><br/>如果没有，通过scp从监控服务器拷贝<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">scp root@192.168.10.100:/usr/bin/gmetric /usr/bin/ //假设你的监控服务器为192.168.10.100</div></div><br/>step2、定制你自己的脚本，执行，并且将结果返回监控服务器<br/>你可以在http://ganglia.info/gmetric/找到很多别人共享的脚本，以下是一个监控memcache服务的脚本：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">vi /root/mcd_gmetric.sh //以下内容<br/> <br/><br/>#!/bin/bash<br/><br/>### $Id: mcd_gmetric.sh 16661 2006-11-07 00:56:33Z ben $<br/><br/>### This script queries a memcached server running<br/>### on localhost and reports a few statistics to <br/>### ganglia. <br/>### It reports<br/>### *mcd_curr_items - the number of objects stored<br/>### *mcd_curr_bytes - current bytes used<br/>### *mcd_curr_conns - current number of connections<br/>### *mcd_hit_perc - hits / gets for current time duration<br/>### (current hit percentage)<br/>### For more description on any of these metrics,<br/>### see the protocols.txt file in the MCD docs.<br/><br/>### Copyright Simply Hired, Inc. 2006<br/>### License to use, modify, and distribute under the GPL<br/>### http://www.gnu.org/licenses/gpl.txt<br/><br/>VERSION=1.0<br/><br/>GMETRIC="/usr/bin/gmetric"<br/>GMETRIC_ARGS="-c /etc/ganglia/gmond.conf"<br/>STATEFILE="/var/lib/ganglia/metrics/mcd.stats"<br/>ERROR_NOTROOT="/tmp/mcd_gmetric_notroot"<br/>ERROR_CANT_CONNECT="/tmp/mcd_gmetric_cant_connect"<br/>ERROR_CREATE="/tmp/mcd_gmetric_create_statefile_failed"<br/>ERROR_GETS_EMPTY="/tmp/mcd_gets_empty"<br/><br/>MCD_CONF="/etc/sysconfig/memcached"<br/><br/># get system configuration<br/>if [ -e $&#123;MCD_CONF&#125; ]<br/>then<br/>source $&#123;MCD_CONF&#125;<br/>MCD_PORT=$&#123;PORT&#125;<br/>fi<br/>MCD_PORT=$&#123;MCD_PORT:-11211&#125;<br/><br/>date=`date +%s`<br/><br/>if [ $UID -ne 0 ]<br/>then<br/>if [ -e $ERROR_NOTROOT ] ; then exit 1; fi<br/>echo "Error: this script must be run as root."<br/>touch $ERROR_NOTROOT<br/>exit 1<br/>fi<br/>rm -f $ERROR_NOTROOT<br/><br/>if [ "x$1" == "x-h" ]<br/>then<br/>echo "Usage: mcd_gmetric.sh [--clean]"<br/>echo " --clean delete all tmp files"<br/>exit 0<br/>fi<br/><br/>if [ "x$1" == "x--clean" ]<br/>then<br/>rm -f $STATEFILE $ERROR_NOTROOT $ERROR_CANT_CONNECT $ERROR_CREATE<br/>retval=$?<br/>if [ $retval -ne 0 ]<br/>then<br/>echo "failed to clean up."<br/>exit 1<br/>else<br/>echo "All cleaned up."<br/>exit 0<br/>fi<br/>fi<br/><br/># if the GMETRIC program isn't installed, compain<br/>if [ ! -e $GMETRIC ]<br/>then<br/>if [ -e $ERROR_GMETRIC ] ; then exit 1; fi<br/>echo ""<br/>echo "Error: GMETRIC doesn't seem to be installed."<br/>echo "$GMETRIC doesn't exist."<br/>echo ""<br/>touch $ERROR_GMETRIC<br/>exit 1<br/>fi<br/><br/># get current statistics<br/>exec 3>&2 #turn off STDERR<br/>exec 2>/dev/null<br/>stats_array=(`echo "stats" &#124; nc localhost $MCD_PORT`)<br/>retval=$?<br/>exec 2>&1 #turn on STDERR<br/>exec 3>&-<br/><br/>if [ $retval -ne 0 ]<br/>then<br/>if [ -e $ERROR_CANT_CONNECT ] ; then exit 1 ; fi<br/>echo "I can't connect to mcd."<br/>echo "Bummer. "<br/>touch $ERROR_CANT_CONNECT <br/>exit 1<br/>fi<br/><br/>mcd_curr_items=`echo $&#123;stats_array[23]&#125;&#124;tr -c -d [0-9]` #this tr thing is because there's a trailing ^M on the string from netcat that breaks bc.<br/>mcd_curr_bytes=`echo $&#123;stats_array[29]&#125;&#124;tr -c -d [0-9]`<br/>mcd_curr_conns=`echo $&#123;stats_array[32]&#125;&#124;tr -c -d [0-9]`<br/>mcd_total_gets=`echo $&#123;stats_array[41]&#125;&#124;tr -c -d [0-9]`<br/>mcd_total_sets=`echo $&#123;stats_array[44]&#125;&#124;tr -c -d [0-9]`<br/>mcd_total_hits=`echo $&#123;stats_array[47]&#125;&#124;tr -c -d [0-9]`<br/><br/>if [ -z "$mcd_total_gets" ]<br/>then<br/># this actually happens rather often for some reason, so I'm just going to fail silently.<br/># if [ -e $ERROR_GETS_EMPTY ] ; then exit 1 ; fi<br/># echo ""<br/># echo "ERROR: mcd_total_gets empty."<br/># echo ""<br/>exit 1<br/>fi<br/>rm -f $ERROR_GETS_EMPTY<br/><br/><br/># save and turn off /STDERR for the statefile tests<br/>exec 3>&2<br/>exec 2>/dev/null<br/><br/># if the statefile doesn't exist, we either havn't<br/># run yet or there's something bigger wrong.<br/>if [ ! -e $STATEFILE ]<br/>then<br/>if [ ! -d `dirname $STATEFILE` ]<br/>then<br/>mkdir -p `dirname $STATEFILE`<br/>fi<br/>echo "$date $mcd_curr_items $mcd_curr_bytes $mcd_curr_conns $mcd_total_gets $mcd_total_sets $mcd_total_hits" > $STATEFILE<br/>if [ ! -e $STATEFILE ]<br/>then<br/># if it didn't exist and we couldn't create<br/># it, we should just scream bloody murder and die.<br/># only scream once though...<br/>if [ -e $ERROR_CREATE ]<br/>then<br/>exit 1<br/>fi<br/>echo ""<br/>echo "ERROR: couldn't create $STATEFILE"<br/>echo ""<br/>touch $ERROR_CREATE<br/>exit 1<br/>fi<br/>echo "Created statefile. Exitting."<br/>exit 0<br/>fi<br/><br/># restore stderr<br/>exec 2>&3<br/>exec 3>&-<br/><br/>old_stats_array=(`cat $STATEFILE`)<br/>old_date=$&#123;old_stats_array[0]&#125;<br/>old_mcd_curr_items=$&#123;old_stats_array[1]&#125;<br/>old_mcd_curr_bytes=$&#123;old_stats_array[2]&#125;<br/>old_mcd_curr_conns=$&#123;old_stats_array[3]&#125;<br/>old_mcd_total_gets=$&#123;old_stats_array[4]&#125;<br/>old_mcd_total_sets=$&#123;old_stats_array[5]&#125;<br/>old_mcd_total_hits=$&#123;old_stats_array[6]&#125;<br/><br/>echo "$date $mcd_curr_items $mcd_curr_bytes $mcd_curr_conns $mcd_total_gets $mcd_total_sets $mcd_total_hits" > $STATEFILE<br/><br/>time_diff=$(($date - $old_date))<br/>mcd_total_gets_diff=$(($mcd_total_gets - $old_mcd_total_gets))<br/>mcd_total_sets_diff=$(($mcd_total_sets - $old_mcd_total_sets))<br/>mcd_total_hits_diff=$(($mcd_total_hits - $old_mcd_total_hits))<br/><br/>if [ $time_diff -eq 0 ]<br/>then<br/>if [ -e $ERROR_TIMEDIFF ] ; then exit 1 ; fi<br/>echo "something is broken."<br/>echo "time_diff is 0."<br/>touch $ERROR_TIMEDIFF<br/>exit 1<br/>fi<br/><br/># none of these numbers should be less than 1, but if they are, just send back 1.<br/>if [ $mcd_total_gets_diff -le 1 ] ; then mcd_total_gets_diff=1 ; fi<br/>if [ $mcd_total_sets_diff -le 1 ] ; then mcd_total_sets_diff=1 ; fi<br/>if [ $mcd_total_hits_diff -le 1 ] ; then mcd_total_hits_diff=1 ; fi<br/><br/>mcd_gets_per_sec=`echo "scale=3;$&#123;mcd_total_gets_diff&#125;/$&#123;time_diff&#125;"&#124;bc`<br/>mcd_sets_per_sec=`echo "scale=3;$&#123;mcd_total_sets_diff&#125;/$&#123;time_diff&#125;"&#124;bc`<br/>mcd_hits_per_sec=`echo "scale=3;$&#123;mcd_total_hits_diff&#125;/$&#123;time_diff&#125;"&#124;bc`<br/>mcd_hit_perc=`echo "scale=3; $&#123;mcd_total_hits_diff&#125; * 100 / $&#123;mcd_total_gets_diff&#125;" &#124; bc`<br/><br/><br/>$GMETRIC $GMETRIC_ARGS --name="mcd_seconds_measured" --value=$&#123;time_diff&#125; --type=uint32 --units="secs"<br/>$GMETRIC $GMETRIC_ARGS --name="mcd_items_cached" --value=$&#123;mcd_curr_items&#125; --type=uint32 --units="items"<br/>$GMETRIC $GMETRIC_ARGS --name="mcd_bytes_used" --value=$&#123;mcd_curr_bytes&#125; --type=uint32 --units="bytes"<br/>$GMETRIC $GMETRIC_ARGS --name="mcd_conns" --value=$&#123;mcd_curr_conns&#125; --type=uint32 --units="connections"<br/>$GMETRIC $GMETRIC_ARGS --name="mcd_gets" --value=$&#123;mcd_gets_per_sec&#125; --type=float --units="gps"<br/>$GMETRIC $GMETRIC_ARGS --name="mcd_sets" --value=$&#123;mcd_sets_per_sec&#125; --type=float --units="sps"<br/>$GMETRIC $GMETRIC_ARGS --name="mcd_cache_hits" --value=$&#123;mcd_hits_per_sec&#125; --type=float --units="hps"<br/>$GMETRIC $GMETRIC_ARGS --name="mcd_cache_hit%" --value=$&#123;mcd_hit_perc&#125; --type=float --units="%"<br/></div></div><br/>赋予脚本可执行权限并执行：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">chmod 755 mcd_gmetric.sh<br/>./mcd_gmetric.sh</div></div><br/>这时已经将结果通过gmetric返回到监控服务器，在服务器该主机的信息中已经可以看到memcached服务的相关信息了<br/>将这个服务添加到crontab<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">crontab -e<br/>/1 * * * * /root/mcd_gmetric.sh //设置每分钟将结果返回监控服务器</div></div><br/>参考文档：<br/>http://www.ibm.com/developerworks/cn/linux/l-ganglia-nagios-1/<br/>http://idcnews.net/html/edu/20070101/288092.html<br/>http://blog.csdn.net/Tobeabetterman_He/archive/2006/12/13/1441516.aspx<br/><br/><br/>Tags - <a href="179401.cn/tag.php?tag=ganglia" rel="tag">ganglia</a> , <a href="179401.cn/tag.php?tag=linux" rel="tag">linux</a> , <a href="179401.cn/tag.php?tag=%25E7%259B%2591%25E6%258E%25A7" rel="tag">监控</a>
]]>
</description>
</item>
</channel>
</rss>