ganglia扩展 时间纬度高 日照时间长的时间可以自己设置吗?

Ubuntu&Ganglia安装配置
1、sudo apt-get install ganglia-monitor
ganglia-webfrontend
安装完成之后,启动apache2服务器,gmetad和gmond两个服务会运行起来,使用下面的命令可以启动这两个服务。
view sourceprint?
service gmetad start
启动成功:Starting
Ganglia Monitor Meta-Daemon: gmetad.
sysv-rc-conf gmetad on& (ubuntu 下sysv-rc-conf
命令等同redhat 下的chkconfig 命令)
sysv-rc-conf --list gmetad
GMETAD 0:off 1:off 2:on 3:on 4:on 5:on 6:off
验证gmetad 正常工作:telnet localhost
8651就可以得到监控的各个主机的状态。
service ganglia-monitor start
启动成功 Starting
Ganglia Monitor Daemon: gmond
sysv-rc-conf gmond on& (ubuntu
下sysv-rc-conf命令等同redhat下chkconfig命令)
sysv-rc-conf —list gmond gmond 0:off 1:off 2:on 3:on 4:on 5:on
service gmond start Starting GANGLIA gmond: [ OK
]& 验证gmond正常工作:telnet localhost 8649
就可以获取机群内运行gmond的主机的信息
/etc/init.d/apache2 restar
*Restartingwebserver
apache2&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
apache2: Could not reliably determine the server's fully qualified
domain name, using 172.16.205.55 for ServerName
&... waiting apache2: Could not reliably determine
the server's fully qualified domain name, using 172.16.205.55 for
ServerName
因为ganglia-webfront这个包默认将Web相关的代码安装在”/usr/share/ganglia-webfrontend/”路径下,这样apache访问不到。可以使用软链接,或者直接将目录移到”/var/www/”目录下。
view sourceprint
sudo&ln&-s&/usr/share/ganglia-webfrontend/&/var/www/ganglia&
sudo&mv&/usr/share/ganglia-webfrontend/&/var/www/ganglia
接着在浏览器输入”http://localhost/ganglia”就可以看到Web
UI了。使用Chrome时,总是会将index.php主页下载下来,不知道为何。使用Firefox一切都很正常。Web
这里只有一个Grid,并且这个Grid只有一个节点。往Grid里面添加节点是很简单的,只需要在该节点的/etc/ganglia/gmond.conf指明加入cluster的名字和该cluster多播地址就可以了。
服务器端配置
/etc/gmetad.conf文件:
data_source "cluster node1"&
192.168.1.1//节点ip
data_source "cluster node2"&
192.168.1.2//节点ip
修改客户端配置
"Cluster1"&&&&
#本节点属于哪个cluster
"chifeng"&&&&
#谁是该节点的所有者
& latlong =
"unspecified"&&
#在地球上的坐标,经度、纬度?
& url = "unspecified"
& daemonize =
yes&&&&&&&
#以后台的方式运行
& setuid = yes
nobody&&&&&&&&&
#运行gmond的用户
& debug_level =
& max_udp_msg_len = 1472
no&&&&&&&&&&&&&
#哑巴,本节点将不会再广播任何自己收集到的数据到网络上
no&&&&&&&&&&&&&
#聋子,本节点将不再接收任何其他节点广播的数据包
& allow_extra_data = yes
& host_dmax = 0
& cleanup_threshold = 300
no&&&&&&&&&&&&
#是否使用gexec
& send_metadata_interval = 0
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。fedora下ganglia安装、配置及python模块扩展_最火下载站
您的位置: >
> fedora下ganglia安装、配置及python模块扩展
fedora下ganglia安装、配置及python模块扩展
1 安装ganglia
1.1安装环境
CentOS, fedora
1.2单机版安装步骤
假设机器的IP地址是192.168.1.253, 首先安装好所需要的软件
Copy to Clipboard引用的内容:[]
rpm -Uvh http://download./pub/epel/5/i386/epel-release-5-3.noarch.rpmyum install rrdtool ganglia ganglia-gmetad ganglia-gmond ganglia-web httpd php apr apr-util
1 gmond的设置文件位置是/etc/gmond.conf,打开其进行编辑,只需修改下面的内容:
name = &cluster1&
owner = &owner1&
latlong = &unspecified&
url = &unspecified&
udp_send_channel {
host = 192.168.1.253
port = 8649
udp_recv_channel {
port = 8649
2 gmetad的设置文件位置是/etc/gmetad.conf,打开其进行编辑,只需修改下面的内容:
Copy to Clipboard引用的内容:[]
data_source &my cluster& 192.168.1.253:8649
1.4 启动服务
1 启动gmond
chkconfig gmond on
service gmond start
2 启动gmetad
chkconfig gmetad on
service gmetad start
3启动httpd
chkconfig httpd on
service httpd start
1.5 观察结果
打开localhost/ganglia就可以看到结果了。
2 模块扩展
2.1 安装python模块进行功能扩展
yum install ganglia-gmond-python
2.2 检查是否安装成功
gmond.conf 有这一行代码include (&/etc/ganglia/conf.d/*.conf&).这个目录是放模块的配置文件的,python模块的配置文件的后缀名应该是.pyconf
在/etc/ganglia/conf.d下有modpython.conf。这个文件的内容是:
/*params - path to the directory where mod_pythonshould look for python metric modules the &pyconf& files in the include directory belowwill be scanned for configurations for those modules*/modules {module {name = &python_module&path = &modpython.so&params = &/usr/lib/ganglia/python_modules&}} include ('/etc/ganglia/conf.d/*.pyconf')
params指明了python模块存放的目录。
include ('/etc/ganglia/conf.d/*.pyconf') 指明了python模块配置文件的目录。
在 /usr/lib/ganglia下有modpython.so。该文件是 Ganglia Python 扩展的动态库文件。
/usr/lib/ganglia/python_modules文件夹存在。所有的python模块存放在这个位置,后缀名是.py&
2.3 定制一个pyphton模块
定制一个python模块很简单,只需按照一定的模板编写.py文件,然后将这个模块(.py)放在 /usr/lib/ganglia/python_modules 目录下。对应的配置文件(.pyconf)放在/etc/ganglia/conf.d/目录下。
python模块可能要访问服务器的多个文件,由于运行python模块的用户和运行gmond的用户是一致的,所以必须保证运行gmond的用户有访问这些文件的权限。
在安装好ganglia-gmond-python后,已经自带了一个例子/usr/lib/ganglia/python_modules/example.py。下面将针对example.py解释python模块的格式,以及它的配置文件。
2.4 python模块模板
以example为例(安装完ganglia-gmond-python 后已经自带)
import randomdescriptors = list()Random_Max = 50Constant_Value = 50def Random_Numbers(name):
'''Return a random number.'''
global Random_Max
return int(random.uniform(0,Random_Max))def Constant_Number(name):
'''Return a constant number.'''
global Constant_Value
return int(Constant_Value)def metric_init(params):
'''Initialize the random number generator and create the
metric definition dictionary object for each metric.'''
global descriptors
global Random_Max
global Constant_Value
random.seed()
print '[pyexample] Received the following parameters'
print params
if 'RandomMax' in params:
Random_Max = int(params['RandomMax'])
if 'ConstantValue' in params:
Constant_Value = int(params['ConstantValue'])
d1 = {'name': 'PyRandom_Numbers',
'call_back': Random_Numbers,
'time_max': 90,
'value_type': 'uint',
'units': 'N',
'slope': 'both',
'format': '%u',
'description': 'Example module metric (random numbers)',
'groups': 'example,random'}
d2 = {'name': 'PyConstant_Number',
'call_back': Constant_Number,
'time_max': 90,
'value_type': 'uint',
'units': 'N',
'slope': 'zero',
'format': '%hu',
'description': 'Example module constant (constant number)'}
descriptors = [d1,d2]
return descriptorsdef metric_cleanup():
'''Clean up the metric module.'''
pass#This code is for debugging and unit testing
if __name__ == '__main__':
params = {'RandomMax': '500',
'ConstantValue': '322'}
metric_init(params)
for d in descriptors:
v = d['call_back'](d['name'])
print 'value for %s is %u' % (d['name'],
模块中必须包含的三个方法是:
def metric_init(params):
def metric_cleanup():
def metric_handler(name):
前面两个方法的名字必须是一定的,而最后一个 metric_handler可以任意命名。
__main__是便于debug用,可以单独调试该模块,以检测是否有错。
下面将对每个方法的功能做解释。
def metric_init(params):
对模块的初始化,在gmond服务被启动的时候,运行一次。
该方法必须返回一个词典列表,每个词典表示了一个metric的信息。每个词典的格式如下:
d1 = {'name': 'PyRandom_Numbers',
#metric的名字
'call_back': Random_Numbers,
#收集到数据后调用的方法
'time_max': 90,
#没有什么用。。。
'value_type': 'uint',
#string | uint | float | double
'units': 'N',
# metric的单位
'slope': 'both',
#zero | positive | negative | both
'format': '%u',
#必须和value_type对应 (reference: http://docs.python.org/library/stdtypes.html#string-formatting)
'description': 'Example module metric (random numbers)',
#对metric的描述,在前端可以看到
'groups': 'example,random'}
#这个metric属于的组,如果没有定义,会分到no_group metric中
slope的选项 zero | positive | negative | both
This value maps to the data source types defined for RRDTool
If 'positive',表示数据的变化率(calculating the rate of change)
If 'negative', ????
'both' 直接显示值
If 'zero', 将显示在 &Time and String Metrics& 或者 &Constant Metrics&中(根据metric的value_type)
在example这个例子中,d2的slope是zero,最后显示在Constant Metrics中,而不显示在下面的面板里。
def metric_cleanup():
gmond关掉的时候执行,不能返回值。
def metric_handler(name):
可以取任何的名字,要在call_back中调用,参数name在是metric字典里定义的name。
2.4 pyconf模板
pyconf是python模块的配置文件,位置是/etc/ganglia/conf.d/example.pyconf(没有自带,需自己创建example.pyconf), 代码如下
name = &example&
language = &python&
# The following params are examples only
They are not actually used by the temp module
param RandomMax {
value = 600
param ConstantValue {
value = 112
}}collection_group {
collect_every = 10
time_threshold = 50
name = &PyRandom_Numbers&
#要显示的metric,与example.py中的d1名字对应
title = &Random&
#metric在网页上显示的标题
value_threshold = 70
name = &PyConstant_Number&
#要显示的metric,与example.py中的d2名字对应
title = &Constant&
#metric在网页上显示的标题
value_threshold = 70
pyconf的文件名最好和你建立的python文件名对应。包含两个模块, modules 和collection_group。
Modules:对每个模块进行配置
name:模块名,同时必须与创建的python文件名一致
language: 语言
param:参数列表,所有的参数作为一个dict(即map)传给python脚本的metric_init(params)函数。
本例中,metric_init调用时,&params={&RandomMax&:&600&,&ConstantValue&:&112&}
collection_group:需要收集的metric列表,一个模块中可以扩展任意个metric
collect_every: 汇报周期,以秒为单位。
metric:可以有多个,定义每个metric的信息。
上一篇: 下一篇:分布式监控系统ganglia配置文档 - 突袭新闻
当前位置&:&&&&分布式监控系统ganglia配置文档
热门标签:
分布式监控系统ganglia配置文档
来源:本网整理
编辑:从小叶评论:
一、Ganglia的组件Ganglia包括如下程序,他们之间通过XML& 26684;式传递监控数据,达到监控效果。 Gmetad 这个程序负责收集各个cluster的数据,并更新到rrd数据库中。Gmond 收集本机的监控数据,发送到
一、Ganglia的组件
Ganglia包括如下程序,他们之间通过XML格式传递监控数据,达到监控效果。
Gmetad 这个程序负责收集各个cluster的数据,并更新到rrd数据库中。
Gmond 收集本机的监控数据,发送到其他机器上。收集其他机器的监控数据,供Gmetad读取。默认监听端口8649
web front-end 一个基于web的监控界面,需要和Gmetad安装在同一个节点上,从Gmetad取数据,并且读取rrd数据库,生成图片,显示出来。
二、Ganglia的工作模式
Ganglia的收集数据工作可以工作在单播(unicast)或多播(multicast)模式下,默认为多播模式。
单播:发送自己收集到的监控数据到特定的一台或几台机器上,可以跨网段
多播:发送自己收集到的监控数据到同一网段内所有的机器上,同时收集同一网段内的所有机器发送过来的监控数据。因为是以广播包的形式发送,因此需要同一网段内。但同一网段内,又可以定义不同的发送通道。
三、Ganglia的安装
Ganglia的安装非常简单,分为监控管理端(Gmetad)和客户端(Gmond)安装两部分,已经写成安装脚本,这里不在描述。
推荐安装版本是ganglia-3.4.0,可以在http://sourceforge.net/projects/ganglia/files/下载安装。
四、Ganglia的配置
这里介绍一个简单的Ganglia配置构架,即一个监控管理端和多个客户端,我们假定gmond工作在多播模式,并且有一个Cluster1的集群,里面有10台服务器(从host1到host10),在同一个网段内。
1、监控管理端配置
监控管理端的配置文件是gmetad.conf,在安装Ganglia的etc目录下可以找到,这个文件配置非常简单,介绍如下:
data_source &Cluster1& host1 host2
xml_port 8651
interactive_port 8652
rrd_rootdir &/var/lib/ganglia/rrds&
data_source参数定义了集群名字,以及集群中的节点。由于采用multicast模式,每台gmond节点都有本Cluster1内节点机器的所有监控数据,因此不需要把所有节点写入data_source中。建议写入不低于2个,在host1节点死机的时候,会自动找host2节点取数据。
xml_port定义了一个收集数据汇总的交互端口,如果不指定,默认是8651,可以通过telnet这个端口得到监控管理端收集到的客户端的所有数据。
interactive_port 定义了Web端获取数据的端口,这个端口在配置Ganglia的web监控界面时需要指定。
rrd_rootdir参数定义了rrd数据库的存放路径,gmetad收集到监控数据后,会更新到该目录下的对应的rrd数据库中。
上面通过data_source参数定义了一个监控集群,如果要监控多个应用系统,可以通过如下方式定义:
data_source &my cluster& 10 localhost my.machine.edu:.3.5:8655
data_source &my grid& 50 1.3.4.7:8655 grid.org:8651 grid-backup.org:8651
data_source &another source& 1.3.4.7:.4.8
在定义集群节点的时候,可以采用主机名、IP地址等形式,也可以加端口,如果不加端口的话,默认是8649端口,同时可以设定采集数据的频率,如上面的“10 localhost、50 1.3.4.7:8655”等,分别表示每隔10秒钟、50秒钟采集一次数据。
2、客户端配置
客户端监控安装完成后,配置文件位于安装Ganglia的etc目录下,名称为gmond.conf,这个配置文件稍微复杂,介绍如下:
daemonize = yes #以后台的方式运行
setuid = yes
user = nobody #运行gmond的用户
debug_level = 0 #调试级别
max_udp_msg_len = 1472
mute = no #哑巴,本节点将不会再广播任何自己收集到的数据到网络上
deaf = no #聋子,本节点将不再接收任何其他节点广播的数据包
allow_extra_data = yes
host_dmax = 0 /*secs */
cleanup_threshold = 300 /*secs */
gexec = no #是否使用gexec
send_metadata_interval = 0
name = &Cluster1& #本节点属于哪个cluster
owner = &junfeng& #谁是该节点的所有者
latlong = &unspecified& #在地球上的坐标,经度、纬度?
url = &unspecified&
location = &unspecified&
udp_send_channel { #udp包的发送通道
mcast_join = 239.2.11.71 #多播,工作在239.2.11.71通道下。如果使用单播模式,则要写host = host1,单播模式下也可以配置多个udp_send_channel
port = 8649 #监听端口
udp_recv_channel { #接收udp包配置
mcast_join = 239.2.11.71 #同样工作在239.2.11.71通道下
port = 8649 #监听端口
bind = 239.2.11.71 #绑定
tcp_accept_channel {
port = 8649 #通过tcp协议监听的端口,远端可以通过链接8649端口得到监控数据
3、Ganglia之Web端配置
Ganglia的web监控界面是基于PHP的,因此需要安装PHP环境,PHP环境的安装不在介绍,可以在http://sourceforge.net/projects/ganglia/files/下载ganglia-web,然后放到web根目录即可,推荐下载ganglia-web-3.5.7版本。
配置ganglia的web界面比较简单,只需要修改几个php文件即可,首先第一个是conf_default.php,可以将conf_default.php重命名为conf.php,也可以保持不变,ganglia的web默认先找conf.php,找不到会继续找conf_default.php,需要修改的内容如下:
$conf['gmetad_root'] = &/var/lib/ganglia&;# ganglia web根目录
$conf['rrds'] = &${conf['gmetad_root']}/rrds&;#ganglia web读取rrds数据库的路径
$conf['dwoo_compiled_dir'] = &${conf['gmetad_root']}/dwoo/compiled&;#需要777权限
$conf['dwoo_cache_dir'] = &${conf['gmetad_root']}/dwoo/cache&;#需要777权限
$conf['rrdtool'] = &/opt/rrdtool/bin/rrdtool&;#指定rrdtool的路径
$conf['graphdir']= $conf['gweb_root'] . '/graph.d';#生成图形模板目录
$conf['ganglia_ip'] = &127.0.0.1&;#gmetad服务器的地址
$conf['ganglia_port'] = 8652;#gmetad服务器的交互式提供监控数据端口发布
五、管理ganglia
所有配置操作完成后,即可启动ganglia服务了,首先在监控管理端启动gmetad服务:
/etc/init.d/gmetad start
接着启动apache的web服务:
/usr/local/apache2/bin/apachectl start
最后在每个客户端启动gmond服务:
/etc/init.d/gmond start 相关阅读:
二线互联网公司投资图谱:O2O成热点
申请创业加速器前,先考虑这五件事情
Win10将改变一切?微软得先扩大硬件生态
本网最新文章

我要回帖

更多关于 经纬度时间 的文章

 

随机推荐