add User parameters of monitoring process memory usage

- Total memory used by Python process? | Stack Overflow
 - http://stackoverflow.com/a/40173829/686105
This commit is contained in:
Jonny Lai 2016-10-24 13:44:58 +08:00
parent 7484a6d093
commit 62d2093b8d
No known key found for this signature in database
GPG Key ID: FBB6918B261FF774
4 changed files with 139 additions and 0 deletions

View File

@ -30,6 +30,7 @@ Please let us know if you have any questions or concerns.
* [Iptables](#template-app-iptables) * [Iptables](#template-app-iptables)
* [lm_sensors](#template-app-lm_sensors) * [lm_sensors](#template-app-lm_sensors)
* [mdadm](#template-app-mdadm) * [mdadm](#template-app-mdadm)
* [Memory Usage of Specific Process](#template-specific-process-memory-usage)
* [Monit](#template-app-monit) * [Monit](#template-app-monit)
* [MySQL](#template-app-mysqld) * [MySQL](#template-app-mysqld)
* [MySQL Slave](#template-app-mysql-slave) * [MySQL Slave](#template-app-mysql-slave)
@ -64,6 +65,7 @@ Please let us know if you have any questions or concerns.
* [Inventory](#template-inventory) * [Inventory](#template-inventory)
* [Dell OMSA](#template-omsa) * [Dell OMSA](#template-omsa)
* [SELinux](#template-selinux) * [SELinux](#template-selinux)
----- -----
## Template App Amavisd ## Template App Amavisd
@ -108,6 +110,9 @@ Monitoring CPU and MotherBoard temperatures by lm_senros module.
## Template App mdadm ## Template App mdadm
Monitoring mdadm arrays. Checking number of corrupted disk arrays. 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 ## Template App Monit
Monitoring for Monit service. Monitoring for Monit service.

16
bin/memory-check.sh Normal file
View File

@ -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 }'

View File

@ -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>

View File

@ -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"