Skip to content
Snippets Groups Projects
Commit 9f77025f authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

check_memory: shellfixes

parent 2af97e2a
No related branches found
No related tags found
1 merge request!55Add check requirement
......@@ -24,13 +24,14 @@
# 2021-03-24 v1.5 <axel.hahn@iml.unibe.ch> increase Swap critical limit 5 --> 50
# 2022-03-09 v1.6 <axel.hahn@iml.unibe.ch> show most ram intensive processes
# 2022-03-10 v1.7 <axel.hahn@iml.unibe.ch> add cli param -p; update help
# 2023-02-13 v1.8 <axel.hahn@unibe.ch> shell fixes
# ======================================================================
. $(dirname $0)/inc_pluginfunctions
. "$(dirname $0)/inc_pluginfunctions"
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] )
self_APPVERSION=1.7
self_APPVERSION=1.8
# ----------------------------------------------------------------------
# FUNCTIONS
......@@ -97,30 +98,30 @@ ph.require bc
# ----------------------------------------------------------------------
# set default / override from command line params
typeset -i iWarnLimit=$( ph.getValueWithParam 75 w "$@")
typeset -i iCriticalLimit=$( ph.getValueWithParam 90 c "$@")
typeset -i iCriticalSwap=$( ph.getValueWithParam 50 s "$@")
typeset -i iMinRamUsageToShowProcesses=$( ph.getValueWithParam 50 p "$@")
typeset -i iWarnLimit; iWarnLimit=$( ph.getValueWithParam 75 w "$@")
typeset -i iCriticalLimit; iCriticalLimit=$( ph.getValueWithParam 90 c "$@")
typeset -i iCriticalSwap; iCriticalSwap=$( ph.getValueWithParam 50 s "$@")
typeset -i iMinRamUsageToShowProcesses; iMinRamUsageToShowProcesses=$( ph.getValueWithParam 50 p "$@")
# ----------------------------------------------------------------------
# read values
# --- RAM
typeset -i ramTotal=$( getMemvalue MemTotal)
typeset -i ramAvail=$( getMemvalue MemAvailable)
typeset -i ramUsed=$ramTotal-$ramAvail
typeset -i ramTotal; ramTotal=$( getMemvalue MemTotal)
typeset -i ramAvail; ramAvail=$( getMemvalue MemAvailable)
typeset -i ramUsed; ramUsed=$ramTotal-$ramAvail
typeset -i ramFree=$( getMemvalue MemFree)
typeset -i ramBuffers=$( getMemvalue Buffers)
typeset -i ramCached=$( getMemvalue Cached)
typeset -i ramSReclaim=$( getMemvalue SReclaimable)
typeset -i ramFree; ramFree=$( getMemvalue MemFree)
typeset -i ramBuffers; ramBuffers=$( getMemvalue Buffers)
typeset -i ramCached; ramCached=$( getMemvalue Cached)
typeset -i ramSReclaim; ramSReclaim=$( getMemvalue SReclaimable)
typeset -i ramUsage=$(echo "($ramUsed) *100 / $ramTotal " | bc)
typeset -i ramUsage; ramUsage=$(echo "($ramUsed) *100 / $ramTotal " | bc)
# --- Swap
typeset -i swapTotal=$( getMemvalue SwapTotal)
typeset -i swapFree=$( getMemvalue SwapFree)
typeset -i swapCached=$( getMemvalue SwapCached)
typeset -i swapTotal; swapTotal=$( getMemvalue SwapTotal)
typeset -i swapFree; swapFree=$( getMemvalue SwapFree)
typeset -i swapCached; swapCached=$( getMemvalue SwapCached)
typeset -i swapUsage=0
if [ $swapTotal -gt 0 ]; then
......@@ -147,7 +148,7 @@ fi
# --- show details
echo
cat /proc/meminfo | egrep "^(Mem|Cache|Buffers|Swap|Slab|SReclaimable)"
grep -E "^(Mem|Cache|Buffers|Swap|Slab|SReclaimable)" "/proc/meminfo"
# v1.6: show most consuming processes if usage is > nn %
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment