目前已经完成了RabbitMQ和MySQL的监控项配置,还差对nova-api、nova-conductor、nova-scheduler和keystone进程CPU和内存 usage的监控,类似的轮子已经是有的,所以我们Google一个,然后改造一下就OK了。目前参考 http://blog.51cto.com/825536458/1783015 进行改造。
(一)zabbix-agent监控脚本
[root@f-q scripts(keystone_admin)]# pwd /etc/zabbix/scripts [root@f-q scripts(keystone_admin)]# vim processcheck.sh #!/bin/bash nova-api(){ ps aux|grep "nova-api"|grep -v "grep"|grep -v "processcheck.sh"|awk '{sum+=$6}; END{print sum}' } nova-apicpu(){ ps aux|grep "nova-api"|grep -v "grep"|grep -v "processcheck.sh"|awk '{sum+=$3}; END{print sum}' } nova-conductor(){ ps aux|grep "nova-conductor"|grep -v "grep"|grep -v "processcheck.sh"|awk '{sum+=$6}; END{print sum}' } nova-conductorcpu(){ ps aux|grep "nova-conductor"|grep -v "grep"|grep -v "processcheck.sh"|awk '{sum+=$3}; END{print sum}' } nova-scheduler(){ ps aux|grep "nova-scheduler"|grep -v "grep"|grep -v "processcheck.sh"|awk '{sum+=$6}; END{print sum}' } nova-schedulercpu(){ ps aux|grep "nova-scheduler"|grep -v "grep"|grep -v "processcheck.sh"|awk '{sum+=$3}; END{print sum}' } keystone(){ ps aux|grep "keystone"|grep -v "grep"|grep -v "processcheck.sh"|awk '{sum+=$6}; END{print sum}' } keystonecpu(){ ps aux|grep "keystone"|grep -v "grep"|grep -v "processcheck.sh"|awk '{sum+=$3}; END{print sum}' } placement(){ ps aux|grep "placement"|grep -v "grep"|grep -v "processcheck.sh"|awk '{sum+=$6}; END{print sum}' } placementcpu(){ ps aux|grep "placement"|grep -v "grep"|grep -v "processcheck.sh"|awk '{sum+=$3}; END{print sum}' } case "$1" in nova-api) nova-api ;; nova-apicpu) nova-apicpu ;; nova-conductor) nova-conductor ;; nova-conductorcpu) nova-conductorcpu ;; nova-scheduler) nova-scheduler ;; nova-schedulercpu) nova-schedulercpu ;; keystone) keystone ;; keystonecpu) keystonecpu ;; placement) placement ;; placementcpu) placementcpu ;; *) echo "Usage: $0 {nova-api|nova-apicpu|nova-scheduler|nova-schedulercpu|nova-conductor|nova-conductorcpu|keystone|keystonecpu|placement|placementcpu}" ;; esac
修改脚本执行权限:
# chmod +x processcheck.sh
(二)zabbix_agentd.conf配置文件修改
#nova process monitor UserParameter=process.nova-api.memory,/etc/zabbix/scripts/processcheck.sh nova-api UserParameter=process.nova-api.cpu,/etc/zabbix/scripts/processcheck.sh nova-apicpu UserParameter=process.nova-scheduler.memory,/etc/zabbix/scripts/processcheck.sh nova-scheduler UserParameter=process.nova-scheduler.cpu,/etc/zabbix/scripts/processcheck.sh nova-schedulercpu UserParameter=process.nova-conductor.memory,/etc/zabbix/scripts/processcheck.sh nova-conductor UserParameter=process.nova-conductor.cpu,/etc/zabbix/scripts/processcheck.sh nova-conductorcpu UserParameter=process.keystone.memory,/etc/zabbix/scripts/processcheck.sh keystone UserParameter=process.keystone.cpu,/etc/zabbix/scripts/processcheck.sh keystonecpu UserParameter=process.placement.memory,/etc/zabbix/scripts/processcheck.sh placement UserParameter=process.placement.cpu,/etc/zabbix/scripts/processcheck.sh placementcpu
重启zabbix-agent。
(三)zabbix-get测试
在8.15上安装zabbix-get,然后测试一下数据能否取到:
[root@10e131e69e15 ~]# zabbix_get -s 192.168.122.208 -p 10050 -k process.nova-api.memory 803328
(四)模板修改及导入
<?xml version="1.0" encoding="UTF-8"?> <zabbix_export> <version>3.4</version> <date>2018-07-25T11:14:53Z</date> <groups> <group> <name>Templates</name> </group> </groups> <templates> <template> <template>Template Nova Process</template> <name>Template Nova Process</name> <description/> <groups> <group> <name>Templates</name> </group> </groups> <applications> <application> <name>processcheck</name> </application> </applications> <items> <item> <name>Keystone CPU Usage</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>process.keystone.cpu</key> <delay>30</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>0</value_type> <allowed_hosts/> <units>%</units> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>processcheck</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing> <step> <type>1</type> <params>0.03125</params> </step> </preprocessing> <jmx_endpoint/> <master_item/> </item> <item> <name>Keystone Memory Usage</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>process.keystone.memory</key> <delay>30</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units>Byte</units> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>processcheck</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing> <step> <type>1</type> <params>1000</params> </step> </preprocessing> <jmx_endpoint/> <master_item/> </item> <item> <name>Nova API CPU Usage</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>process.nova-api.cpu</key> <delay>30</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>0</value_type> <allowed_hosts/> <units>%</units> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>processcheck</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing> <step> <type>1</type> <params>0.03125</params> </step> </preprocessing> <jmx_endpoint/> <master_item/> </item> <item> <name>Nova API Memory Usage</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>process.nova-api.memory</key> <delay>30</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units>Byte</units> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>processcheck</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing> <step> <type>1</type> <params>1000</params> </step> </preprocessing> <jmx_endpoint/> <master_item/> </item> <item> <name>Nova Conductor CPU Usage</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>process.nova-conductor.cpu</key> <delay>30</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>0</value_type> <allowed_hosts/> <units>%</units> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>processcheck</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing> <step> <type>1</type> <params>0.03125</params> </step> </preprocessing> <jmx_endpoint/> <master_item/> </item> <item> <name>Nova Conductor Memory Usage</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>process.nova-conductor.memory</key> <delay>30</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units>Byte</units> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>processcheck</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing> <step> <type>1</type> <params>1000</params> </step> </preprocessing> <jmx_endpoint/> <master_item/> </item> <item> <name>Nova Scheduler CPU Usage</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>process.nova-scheduler.cpu</key> <delay>30</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>0</value_type> <allowed_hosts/> <units>%</units> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>processcheck</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing> <step> <type>1</type> <params>0.03125</params> </step> </preprocessing> <jmx_endpoint/> <master_item/> </item> <item> <name>Nova Scheduler Memory Usage</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>process.nova-scheduler.memory</key> <delay>30</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units>Byte</units> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>processcheck</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing> <step> <type>1</type> <params>1000</params> </step> </preprocessing> <jmx_endpoint/> <master_item/> </item> <item> <name>Placement CPU Usage</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>process.placement.cpu</key> <delay>30</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>0</value_type> <allowed_hosts/> <units>%</units> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>processcheck</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing> <step> <type>1</type> <params>0.03125</params> </step> </preprocessing> <jmx_endpoint/> <master_item/> </item> <item> <name>Placement Memory Usage</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>process.placement.memory</key> <delay>30</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units>Byte</units> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>processcheck</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing> <step> <type>1</type> <params>1000</params> </step> </preprocessing> <jmx_endpoint/> <master_item/> </item> </items> <discovery_rules/> <httptests/> <macros/> <templates/> <screens/> </template> </templates> <graphs> <graph> <name>Process CPU Usage</name> <width>900</width> <height>200</height> <yaxismin>0.0000</yaxismin> <yaxismax>100.0000</yaxismax> <show_work_period>1</show_work_period> <show_triggers>1</show_triggers> <type>1</type> <show_legend>1</show_legend> <show_3d>0</show_3d> <percent_left>0.0000</percent_left> <percent_right>0.0000</percent_right> <ymin_type_1>0</ymin_type_1> <ymax_type_1>0</ymax_type_1> <ymin_item_1>0</ymin_item_1> <ymax_item_1>0</ymax_item_1> <graph_items> <graph_item> <sortorder>0</sortorder> <drawtype>2</drawtype> <color>FC683C</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template Nova Process</host> <key>process.nova-api.cpu</key> </item> </graph_item> <graph_item> <sortorder>1</sortorder> <drawtype>2</drawtype> <color>FDCE5A</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template Nova Process</host> <key>process.nova-conductor.cpu</key> </item> </graph_item> <graph_item> <sortorder>2</sortorder> <drawtype>2</drawtype> <color>21AAD4</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template Nova Process</host> <key>process.nova-scheduler.cpu</key> </item> </graph_item> <graph_item> <sortorder>3</sortorder> <drawtype>0</drawtype> <color>17A149</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template Nova Process</host> <key>process.keystone.cpu</key> </item> </graph_item> <graph_item> <sortorder>4</sortorder> <drawtype>0</drawtype> <color>FC6EA3</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template Nova Process</host> <key>process.placement.cpu</key> </item> </graph_item> </graph_items> </graph> <graph> <name>Process Memory Usage</name> <width>900</width> <height>200</height> <yaxismin>0.0000</yaxismin> <yaxismax>100.0000</yaxismax> <show_work_period>1</show_work_period> <show_triggers>1</show_triggers> <type>1</type> <show_legend>1</show_legend> <show_3d>0</show_3d> <percent_left>0.0000</percent_left> <percent_right>0.0000</percent_right> <ymin_type_1>0</ymin_type_1> <ymax_type_1>0</ymax_type_1> <ymin_item_1>0</ymin_item_1> <ymax_item_1>0</ymax_item_1> <graph_items> <graph_item> <sortorder>0</sortorder> <drawtype>2</drawtype> <color>FC683C</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template Nova Process</host> <key>process.nova-api.memory</key> </item> </graph_item> <graph_item> <sortorder>1</sortorder> <drawtype>2</drawtype> <color>FDCE5A</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template Nova Process</host> <key>process.nova-conductor.memory</key> </item> </graph_item> <graph_item> <sortorder>2</sortorder> <drawtype>2</drawtype> <color>21AAD4</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template Nova Process</host> <key>process.nova-scheduler.memory</key> </item> </graph_item> <graph_item> <sortorder>3</sortorder> <drawtype>0</drawtype> <color>17A149</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template Nova Process</host> <key>process.keystone.memory</key> </item> </graph_item> <graph_item> <sortorder>4</sortorder> <drawtype>0</drawtype> <color>FC6EA3</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template Nova Process</host> <key>process.placement.memory</key> </item> </graph_item> </graph_items> </graph> </graphs> </zabbix_export>
修改一下配色,然后就得到如下的效果图:
但谈何容易。