diff --git a/README.md b/README.md index 12fe5a845e7b2bc3ce8a39b80ea5b0c7dde4172a..fd3ecbea01ad1890dcff7a7c45eae4a22da157fd 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Please let us know if you have any questions or concerns. * [Iptables](#template-app-iptables) * [lm_sensors](#template-app-lm_sensors) * [mdadm](#template-app-mdadm) + * [Memory Usage of Specific Process](#template-specific-process-memory-usage) * [Monit](#template-app-monit) * [MySQL](#template-app-mysqld) * [MySQL Slave](#template-app-mysql-slave) @@ -64,6 +65,7 @@ Please let us know if you have any questions or concerns. * [Inventory](#template-inventory) * [Dell OMSA](#template-omsa) * [SELinux](#template-selinux) + ----- ## Template App Amavisd @@ -108,6 +110,9 @@ Monitoring CPU and MotherBoard temperatures by lm_senros module. ## Template App mdadm Monitoring mdadm arrays. Checking number of corrupted disk arrays. +## Template Specific Process Memory Usage +Monitoring memory usag of Specific Process, like Python, unicorn-rails and Nginx. + ## Template App Monit Monitoring for Monit service. diff --git a/bin/memory-check.sh b/bin/memory-check.sh new file mode 100644 index 0000000000000000000000000000000000000000..ef02031b828b6014beb72a1af40dd78ab8c0f57d --- /dev/null +++ b/bin/memory-check.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# ============================================================ +# Author: chusiang / chusiang (at) drx.tw +# Blog: http://note.drx.tw +# Filename: memory-check.sh +# Modified: 2016-10-24 13:05 +# Description: Monitoring memory usage of specific process. +# Reference: +# +# 1. Total memory used by Python process? | Stack Overflow +# - http://stackoverflow.com/a/40173829/686105 +# +# =========================================================== + +PROCESS_NAME="$1" +ps aux | grep $PROCESS_NAME | awk '{ sum=sum+$6 }; END { print sum }' diff --git a/templates/Template Specific Process Memory Usage.xml b/templates/Template Specific Process Memory Usage.xml new file mode 100644 index 0000000000000000000000000000000000000000..6a5af1151f28bb2153d7a954f07f5a7ba780bfaa --- /dev/null +++ b/templates/Template Specific Process Memory Usage.xml @@ -0,0 +1,110 @@ +<?xml version="1.0" encoding="UTF-8"?> +<zabbix_export> + <version>3.0</version> + <date>2016-10-24T05:01:54Z</date> + <groups> + <group> + <name>Zabbix Templates</name> + </group> + </groups> + <templates> + <template> + <template>Template Specific Process Memory Used</template> + <name>Template Specific Process Memory Used</name> + <description>custom monitoring for specific process.</description> + <groups> + <group> + <name>Zabbix Templates</name> + </group> + </groups> + <applications> + <application> + <name>Memory</name> + </application> + </applications> + <items> + <item> + <name>Used memory of $1</name> + <type>0</type> + <snmp_community/> + <multiplier>0</multiplier> + <snmp_oid/> + <key>memory_sum[python]</key> + <delay>60</delay> + <history>7</history> + <trends>365</trends> + <status>0</status> + <value_type>3</value_type> + <allowed_hosts/> + <units>B</units> + <delta>0</delta> + <snmpv3_contextname/> + <snmpv3_securityname/> + <snmpv3_securitylevel>0</snmpv3_securitylevel> + <snmpv3_authprotocol>0</snmpv3_authprotocol> + <snmpv3_authpassphrase/> + <snmpv3_privprotocol>0</snmpv3_privprotocol> + <snmpv3_privpassphrase/> + <formula>1</formula> + <delay_flex/> + <params/> + <ipmi_sensor/> + <data_type>0</data_type> + <authtype>0</authtype> + <username/> + <password/> + <publickey/> + <privatekey/> + <port/> + <description>Sum the used memory of python process.</description> + <inventory_link>0</inventory_link> + <applications> + <application> + <name>Memory</name> + </application> + </applications> + <valuemap/> + <logtimefmt/> + </item> + </items> + <discovery_rules/> + <macros/> + <templates/> + <screens/> + </template> + </templates> + <graphs> + <graph> + <name>Specific Memory Used</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>0</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>0</drawtype> + <color>1A7C11</color> + <yaxisside>0</yaxisside> + <calc_fnc>2</calc_fnc> + <type>0</type> + <item> + <host>Template Specific Process Memory Used</host> + <key>memory_sum[python]</key> + </item> + </graph_item> + </graph_items> + </graph> + </graphs> +</zabbix_export> diff --git a/zabbix_agentd.conf.d/memory_sum.conf b/zabbix_agentd.conf.d/memory_sum.conf new file mode 100644 index 0000000000000000000000000000000000000000..59355d9b3812e964ba72cd9ae686d1d5287efdb5 --- /dev/null +++ b/zabbix_agentd.conf.d/memory_sum.conf @@ -0,0 +1,8 @@ +# ============================================================ +# Author: chusiang / chusiang (at) drx.tw +# Filename: memory_sum.conf +# Modified: 2016-10-24 13:05 +# Description: Custom UserParameter for monitoring specific process memory used. +# =========================================================== + +UserParameter=memory_sum[*],/etc/zabbix/bin/memory-check.sh "$1"