Last active
November 10, 2016 05:03
-
-
Save chusiang/012c40e423c13b02e5296cac3caab4ec to your computer and use it in GitHub Desktop.
Monitoring specific process memory usage with Shell Script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ============================================================ | |
# Author: Chu-Siang Lai / chusiang (at) drx.tw | |
# Filename: memory-check.sh | |
# Modified: 2016-10-24 15:47 | |
# Description: Monitoring process memory usage. | |
# | |
# `ps aux` 結果中的 RSS (resident set size) 的單位是 KB,而 zabbix- | |
# server 用的單位是 B,所以得多乘以 1024 才符合真實情況。 | |
# | |
# Reference: | |
# | |
# 1. 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 }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment