Merge pull request #9 from chusiang/master

Add Memory Usage of Specific Process
This commit is contained in:
Kamil Porembiński 2016-11-05 08:55:36 +01:00 committed by GitHub
commit 05fd5c0303
4 changed files with 145 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)
* [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.

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

@ -0,0 +1,22 @@
#!/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.
#
# The RSS (resident set size) is mean memory used in KB, not B,
# so we need to `* 1024` for mapping zabbix-server.
#
# Reference:
#
# 1. Total memory used by Python process? | Stack Overflow
# - http://stackoverflow.com/a/40173829/686105
# 2. linux - ps aux output meaning | Super User
# - http://superuser.com/a/117921/205255
#
# ===========================================================
PROCESS_NAME="$1"
ps aux | grep $PROCESS_NAME | awk '{ sum=sum+$6 }; END { print sum*1024 }'

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"