From 62d2093b8ded4e355437877625905b1747c7cf0b Mon Sep 17 00:00:00 2001 From: Jonny Lai Date: Mon, 24 Oct 2016 13:44:58 +0800 Subject: [PATCH] add User parameters of monitoring process memory usage - Total memory used by Python process? | Stack Overflow - http://stackoverflow.com/a/40173829/686105 --- README.md | 5 + bin/memory-check.sh | 16 +++ ...Template Specific Process Memory Usage.xml | 110 ++++++++++++++++++ zabbix_agentd.conf.d/memory_sum.conf | 8 ++ 4 files changed, 139 insertions(+) create mode 100644 bin/memory-check.sh create mode 100644 templates/Template Specific Process Memory Usage.xml create mode 100644 zabbix_agentd.conf.d/memory_sum.conf diff --git a/README.md b/README.md index 12fe5a8..fd3ecbe 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 0000000..ef02031 --- /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 0000000..6a5af11 --- /dev/null +++ b/templates/Template Specific Process Memory Usage.xml @@ -0,0 +1,110 @@ + + + 3.0 + 2016-10-24T05:01:54Z + + + Zabbix Templates + + + + + + + + Specific Memory Used + 900 + 200 + 0.0000 + 100.0000 + 1 + 1 + 0 + 1 + 0 + 0.0000 + 0.0000 + 0 + 0 + 0 + 0 + + + 0 + 0 + 1A7C11 + 0 + 2 + 0 + + Template Specific Process Memory Used + memory_sum[python] + + + + + + diff --git a/zabbix_agentd.conf.d/memory_sum.conf b/zabbix_agentd.conf.d/memory_sum.conf new file mode 100644 index 0000000..59355d9 --- /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"