设为首页 收藏本站
云服务器等爆品抢先购,低至4.2元/月
查看: 1032|回复: 0

[经验分享] 运维监控平台之ganglia

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-8-23 09:04:50 | 显示全部楼层 |阅读模式
1、ganglia简介
Ganglia 是一款为 HPC(高性能计算)集群而设计的可扩展的分布式监控系统,它可以
监视和显示集群中的节点的各种状态信息,它由运行在各个节点上的 gmond 守护进程来采
集 CPU 、内存、硬盘利用率、 I/O 负载、网络流量情况等方面的数据,然后汇总到 gmetad
守护进程下,使用 rrdtool 存储数据,最后将历史数据以曲线方式通过 PHP 页面呈现。
Ganglia 的特点如下:
    良好的扩展性,分层架构设计能够适应大规模服务器集群的需要
   负载开销低,支持高并发
    广泛支持各种操作系统( UNIX 等)和 cpu 架构,支持虚拟
2、ganglia组成

Ganglia 监控系统有三部分组成,分别是 gmond、 gmetad、 webfrontend,作用如下。
gmond: 即为 ganglia monitoring daemon,是一个守护进程,运行在每一个需要监测
的节点上,用于收集本节点的信息并发送到其他节点,同时也接收其他节点发过了
的数据,默认的监听端口为 8649。
gmetad: 即为 ganglia meta daemon,是一个守护进程,运行在一个数据汇聚节点上,
定期检查每个监测节点的 gmond 进程并从那里获取数据,然后将数据指标存储在
本地 RRD 存储引擎中。
webfrontend: 是一个基于 web 的图形化监控界面,需要和 Gmetad 安装在同一个节
点上,它从 gmetad 取数据,并且读取 RRD 数据库,通过 rrdtool 生成图表,用于
前台展示,界面美观、丰富,功能强大。下图是其结构
wKiom1e6kSGhJFy-AAE5HmmnynE120.jpg


环境规划(centos6.7)
服务器端  172.16.80.117      
客户端    172.16.80.117 172.16.80.116

3、ganglia的安装

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
[iyunv@centos02 tools]# wget wget
[iyunv@centos02 tools]# rpm -ivh epel-release-6-8.noarch.rpm  
[iyunv@centos02 tools]# yum install ganglia-gmetad.x86_64  ganglia-gmond.x86_64 ganglia-gmond-python.x86_64  -y

修改服务端配置文件
[iyunv@centos02 tools]# vim /etc/ganglia/gmetad.conf
data_source "my cluster"  172.16.80.117 172.16.80.116
gridname "MyGrid"


ganglia web的安装(基于LNMP环境)
[iyunv@centos02 tools]# tar xf ganglia-web-3.7.2.tar.gz
[iyunv@centos02 tools]# mv ganglia-web-3.7.2 /application/nginx/html/ganglia

修改ganglia web的php配置文件
[iyunv@centos02 tools]# vim /application/nginx/html/ganglia/conf_default.php
$conf['gweb_confdir'] = "/application/nginx/html/ganglia";

nginx配置
[iyunv@centos02 ganglia]# cat /application/nginx/conf/nginx.conf
worker_processes  2;
events {
    worker_connections  1024;
}
http {


log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';



    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  www.martin.com martin.com;

        location / {
            root   html/zabbix;
            index  index.php index.html index.htm;
        }


        location ~ .*\.(php|php5)?$ {
            root  html/zabbix;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
               }

         access_log  logs/access_zabbix.log  main;        
   }

    server {
        listen       80;
        server_name  ganglia.martin.com;

        location / {
            root   html/ganglia;
            index  index.php index.html index.htm;
        }


        location ~ .*\.(php|php5)?$ {
            root   html/ganglia;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
               }

         access_log  logs/access_bbs.log  main;      

    }

###status
   server{
      listen 80;
      server_name status.martin.org;
      location / {
      stub_status on;
      access_log off;
        }
   }

}

访问测试,报错如下
Fatal error:Errors were detected in your configuration.
DWOO compiled templates directory '/application/nginx/html/ganglia/dwoo/compiled' is not writeable.
Please adjust $conf['dwoo_compiled_dir'].
DWOO cache directory '/application/nginx/html/ganglia/dwoo/cache' is not writeable.
Please adjust $conf['dwoo_cache_dir'].
in /application/nginx-1.6.3/html/ganglia/eval_conf.php on line 126

解决办法:
[iyunv@centos02 tools]# mkdir /application/nginx/html/ganglia/dwoo/compiled
[iyunv@centos02 tools]# mkdir /application/nginx/html/ganglia/dwoo/cache

[iyunv@centos02 tools]# chmod 777 /application/nginx/html/ganglia/dwoo/compiled
[iyunv@centos02 tools]# chmod 777 /application/nginx/html/ganglia/dwoo/cache
[iyunv@centos02 html]# chmod -R 777 /var/lib/ganglia/rrds


修改客户端配置文件(所有的客户端都需要做)
[iyunv@centos02 tools]# vim /etc/ganglia/gmond.conf
cluster {
  name = "my cluster"    #这个名字要和服务器端定义的data_source后面的名字一样
  owner = "unspecified"
  latlong = "unspecified"
  url = "unspecified"
}

udp_send_channel {
  #bind_hostname = yes # Highly recommended, soon to be default.
                       # This option tells gmond to use a source address
                       # that resolves to the machine's hostname.  Without
                       # this, the metrics may appear to come from any
                       # interface and the DNS names associated with
                       # those IPs will be used to create the RRDs.
#  mcast_join = 239.2.11.71
  host = 172.16.80.117      #这里我们采用单播方式,默认是组播
  port = 8649
#  ttl = 1
}

udp_recv_channel {
#  mcast_join = 239.2.11.71
  port = 8649
#  bind = 239.2.11.71
  retry_bind = true
  # Size of the UDP buffer. If you are handling lots of metrics you really
  # should bump it up to e.g. 10MB or even higher.
  # buffer = 10485760
}



4、再次访问测试
wKioL1e6wAXB1fl1AAIDhE_zm6U167.jpg

这里是整个集群的一个总的汇总图,而不是单台服务器的图,下面我们打开单台服务器的图看看
wKioL1e6wRGiE1uGAAGQKOfS9EE696.jpg
再来看看对同一指标,每台服务器一起显示的图
wKiom1e64UTDTxRbAAD4QHpvi9k830.jpg

5、扩展 Ganglia 监控功能的方法
默认安装完成的 Ganglia 仅向我们提供基础的系统监控信息,通过 Ganglia 插件可以实
现两种扩展 Ganglia 监控功能的方法。
1) 添加带内( in-band)插件,主要是通过 gmetric 命令来实现。
这是通常使用的一种方法,主要是通过 crontab 方法并调用 Ganglia 的 gmetric 命令来向
gmond 输入数据,进而实现统一监控。这种方法简单,对于少量的监控可以采用,但是对
于大规模自定义监控时,监控数据难以统一管理。
2) 添加一些其他来源的带外( out-of-band)插件,主要是通过 C 或者 Python 接口来
实现。
在 Ganglia3.1.x 版本以后,增加了 C 或 Python 接口,通过这个接口可以自定义数据收集
模块,并且可以将这些模块直接插入到 gmond 中以监控用户自定义的应用。

这里我们举例通过带外扩展的方式 来监控nginx的运行状态
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
配置 ganglia 客户端,收集 nginx_status 数据
[iyunv@centos02 nginx_status]# pwd
/tools/gmond_python_modules-master/nginx_status
[iyunv@centos02 nginx_status]# cp conf.d/nginx_status.pyconf /etc/ganglia/conf.d/
[iyunv@centos02 nginx_status]# cp python_modules/nginx_status.py  /usr/lib64/ganglia/python_modules/
[iyunv@centos02 nginx_status]# cp graph.d/nginx_* /application/nginx/html/ganglia/graph.d/

[iyunv@centos02 mysql]# cat /etc/ganglia/conf.d/nginx_status.pyconf
#

modules {
  module {
    name = 'nginx_status'
    language = 'python'

    param status_url {
      value = 'http://status.martin.org/'
    }
    param nginx_bin {
      value = '/application/nginx/sbin/nginx'
    }
    param refresh_rate {
      value = '15'
    }
  }
}

collection_group {
  collect_once = yes
  time_threshold = 20

  metric {
    name = 'nginx_server_version'
    title = "Nginx Version"
  }
}

collection_group {
  collect_every = 10
  time_threshold = 20

  metric {
    name = "nginx_active_connections"
    title = "Total Active Connections"
    value_threshold = 1.0
  }

  metric {
    name = "nginx_accepts"
    title = "Total Connections Accepted"
    value_threshold = 1.0
  }

  metric {
    name = "nginx_handled"
    title = "Total Connections Handled"
    value_threshold = 1.0
  }

  metric {
    name = "nginx_requests"
    title = "Total Requests"
    value_threshold = 1.0
  }

  metric {
    name = "nginx_reading"
    title = "Connections Reading"
    value_threshold = 1.0
  }

  metric {
    name = "nginx_writing"
    title = "Connections Writing"
    value_threshold = 1.0
  }

  metric {
    name = "nginx_waiting"
    title = "Connections Waiting"
    value_threshold = 1.0
  }
}



完成上面的所有步骤后,重启 Ganglia 客户端 gmond 服务,在客户端通过“ gmond–m”
命令可以查看支持的模板,最后就可以在 Ganglia web 界面查看 Nginx 的运行状态

wKiom1e64ETy0i4bAABCkcT-BZU408.jpg

wKiom1e64LKB03gLAAHlpu6rWg4509.jpg



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-261682-1-1.html 上篇帖子: varnish的搭建 下篇帖子: Linux下的分区表fstab 监控
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表