==== 第一步:为ganglia添加python支持 ==== * sudo yum install -y ganglia-gmond-python # 不然没有modpython.so这个库 新建文件 vim /etc/ganglia/conf.d/modpython.conf modules { module { name = "python_module" # 模块名 path = "/usr/local/lib64/ganglia/modpython.so" # 可能库不在这个目录,依照自己情况填写路径 params = "/usr/lib/ganglia/python_modules" # 所有python脚本存放的路径 } } include ('/etc/ganglia/conf.d/*.pyconf') # 注意避免相互包含的问题 ==== 第二步:配置redis参数文件 ==== vim /etc/ganglia/conf.c/redis.pyconf modules { module { name = "redis" # 记住这个名字,后的脚本文件必须和这个名字保持一致 language = "python" param host { value = "127.0.0.1" } # redis 的ip param port { value = 6379 } # redis的端口 } } collection_group { collect_every = 10 time_threshold = 60 metric { name = "connected_clients" } metric { name = "connected_slaves" } metric { name = "blocked_clients" } metric { name = "used_memory" } metric { name = "changes_since_last_save" } metric { name = "bgsave_in_progress" } metric { name = "bgrewriteaof_in_progress" } metric { name = "total_connections_received" } metric { name = "total_commands_processed" } metric { name = "expired_keys" } metric { name = "pubsub_channels" } metric { name = "pubsub_patterns" } metric { name = "vm_enabled" } metric { name = "master_last_io_seconds_ago" } } ==== 第三步:添加redis脚本 ==== * vim /usr/lib/ganglia/pythonmodules/redis.py,加入如下内容 * 确保脚本在/usr/lib/ganglia/python_modules(python脚本指定存放目录)下 * {{:wiki:redis.py|文件下载}}