我是靠谱客的博主 顺心河马,这篇文章主要介绍Ganglia 安装和使用,现在分享给大家,希望可以做个参考。

1、安装路径规划

ganglia安装路径 /usr/local/ganglia

2、安装依赖包

复制代码
1
yum -y install apr-devel  python-devel pcre-devel  pkgconfig rrdtool-devel rrdtool-python libconfuse-devel  libconfuse expat-devel zlib-devel

3、安装CK (服务端和客户端都要装)

复制代码
1
2
git clone https://github.com/concurrencykit/ck ./configure --prefix=/usr/ && make && make install

4、安装ganglia服务端

复制代码
1
2
3
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

复制代码
1
2
setuid_username  "www" rrd_rootdir "/usr/local/gmetad/rrds"

赋予权限

复制代码
1
chwnn -R www:www /usr/local/gmetad/rrds

6、部署ganalia web服务

nginx和php配置就不说了,这里主要注意到是把nginx和php用户都要修改为www启动

复制代码
1
2
git clone https://github.com/ganglia/ganglia-web.git "/var/webroot/" cd /var/webroot/ganalia

把下面选项修改

复制代码
1
2
cp conf_default.php.in conf_default.php cat conf_default.php
复制代码
1
2
$conf['gweb_confdir'] = $conf['gweb_root']; $conf['gmetad_root'] = "/usr/local/gmetad";

然后在/var/webroot/ganalia 创建compiled和cache目录

复制代码
1
2
mkdir dwoo/compiled  dwoo/cache chown -R www:www *

7、安装客户端

复制代码
1
2
3
4
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、脚本自定义

复制代码
1
cat /usr/local/gmond/lib64/ganglia/python_modules/fs_web_current.py
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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) 这个函数必须要有的,返回的必须是一个列表

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部