1 Install Ganglia
Ganglia installation and deployment process
2 Download the modpython.so dynamic library (you can skip this step if you have modpython.so)
yum -y install ganglia-gmond-python
3 Configure your own extended metric
The official provides some metrics that can be modified and used directly:
https://github.com/ganglia/gmond_python_modules
① Modify the configuration file and add extended modules
vim /etc/ganglia/gmond.conf
modules {
...
module {
name = "sys_module" ##注意命名要对应
path = "modsys.so"
}
/* 添加 python 主模块 */
module {
name = "python_module"
/* 动态库路径, 完整路径为 $GANGLIA_ROOT/lib64/ganglia/modpython.so */
path = "modpython.so"
/* Python 扩展模块代码存放目录,不存在则创建 */
params="/etc/ganglia/python_modules/"
}
}
include ('/etc/ganglia/conf.d/*.conf')
/* /etc/ganglia/conf.d/ 为 python 扩展模块配置文件存放目录,不存在则创建, gmond 启动时,会 load 所有的配置文件和 python 模块代码*/
include ('/etc/ganglia/conf.d/*.pyconf')
...
② Write extension module Python code and configuration files
Extension module configuration file storage location
/etc/ganglia/conf.d/xxx.pyconf
Extension module python code storage location
/usr/lib64/ganglia/python_modules/xxx.py
3 Restart the service
systemctl restart gmond.service