概述
1、安装路径规划
ganglia安装路径 /usr/local/ganglia
2、安装依赖包
yum -y install apr-devel python-devel pcre-devel pkgconfig rrdtool-devel rrdtool-python libconfuse-devel libconfuse expat-devel zlib-devel
3、安装CK (服务端和客户端都要装)
git clone https://github.com/concurrencykit/ck ./configure --prefix=/usr/ && make && make install
4、安装ganglia服务端
git clone https://github.com/ganglia/monitor-core.git ./bootstrap CK_LIBS=-L/usr/lib/ CK_CFLAGS=-I/usr/include/ ./configure --prefix=/usr/local/gmetad --with-gmetad&&make&&make install
5、修改配置文件gmetad.conf
setuid_username "www" rrd_rootdir "/usr/local/gmetad/rrds"
赋予权限
chwnn -R www:www /usr/local/gmetad/rrds
6、部署ganalia web服务
nginx和php配置就不说了,这里主要注意到是把nginx和php用户都要修改为www启动
git clone https://github.com/ganglia/ganglia-web.git "/var/webroot/" cd /var/webroot/ganalia
把下面选项修改
cp conf_default.php.in conf_default.php cat conf_default.php
$conf['gweb_confdir'] = $conf['gweb_root'];
$conf['gmetad_root'] = "/usr/local/gmetad";
然后在/var/webroot/ganalia 创建compiled和cache目录
mkdir dwoo/compiled dwoo/cache chown -R www:www *
7、安装客户端
git clone https://github.com/ganglia/monitor-core.git ./bootstrap CK_LIBS=-L/usr/lib/ CK_CFLAGS=-I/usr/include/ ./configure --prefix=/usr/local/gmond&&make&&make install ./sbin/gmond -t > etc/gmond.conf
8、日志调试
编辑etc/gmond.conf 打开debug_level =1
9、脚本自定义
cat /usr/local/gmond/lib64/ganglia/python_modules/fs_web_current.py
#!/usr/bin/python
#coding:utf-8
__author__ = 'Slevin'
import commands
from IPy import IP
fsIp1="11.8.0.0/16"
fsIp2="11.1.0.0/16"
def web_current_handle(name):
count=0
# global count,fsIp1,fsIp2
ip1=IP(fsIp1)
ip2=IP(fsIp2)
cmd="netstat -tn | grep :17553 | grep ESTABLISHED | awk '{print $5}' | awk -F : '{print $1}'"
output=commands.getoutput(cmd)
#print output
for line in str(output).split('n'):
if line in ip1 or line in ip2:
# print line
count=count+1
return int(count)
def metric_init(params):
#global fsIp1,fsIp2
global descriptors
if params:
if params.has_key("fsIp1"):
fsIp1 = str(params["fsIp1"])
print fsIp1
if params.has_key("fsIp2"):
fsIp2 = str(params["fsIp2"])
tmpDict = {
'name':'fs_web_current',
'call_back':web_current_handle,
'value_type':'uint',
'units':'req/s',
'slope':'both',
'format':'%u',
'description':'fo shan video current',
'groups':'web_current'
}
descriptors = [tmpDict]
return descriptors
def metric_cleanup():
pass
if __name__=='__main__':
metric_init(None)
for d in descriptors:
v = d['call_back'](d['name'])
print "value for %s is %d" % (d['name'],v)
metric_init(params) 这个函数必须要有的,返回的必须是一个列表
cat /usr/local/gmond/etc/conf.d/fs_web_current.pyconf [root@96956_video-01 conf.d]# cat fs_web_current.pyconf modules { module { name = "fs_web_current" language = "python" param fsIp1{ value = "11.8.0.0/16" } param fsIp2{ value = "11.1.0.0/16" } } } collection_group { collect_every = 10 time_threshold = 50 metric { name = "fs_web_current" title = "fs_web_current" value_threshold = 50 } }
启动之后 观察日志有无报错,如果有报错,打开gmond调试模式进行调试
转载于:https://blog.51cto.com/slevin/1574053
最后
以上就是顺心河马为你收集整理的Ganglia 安装和使用的全部内容,希望文章能够帮你解决Ganglia 安装和使用所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复