From d5657eb1f809b4f46df53407e747c819ab3c51a1 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Sun, 7 Jul 2019 09:41:39 +0200 Subject: [PATCH] added process print --- bot.sh | 6 ++++-- cpu.sh | 4 ++++ mem.sh | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bot.sh b/bot.sh index e6fbbf2..ac1df7a 100755 --- a/bot.sh +++ b/bot.sh @@ -29,7 +29,8 @@ fi cpu=$(cpuUsage) if [ "$cpu" -gt "$cpulimit" ]; then echo "cpu limit!" - send "warnung%20CPU%20Usage%20is%20high%20$cpu" + proc=$(cpuHighest) + send "warnung%20CPU%20Usage%20is%20high%20$cpu%25%0A$proc" fi #mem usage @@ -37,7 +38,8 @@ fi mem=$(memUsage) if [ "$mem" -gt "$memlimit" ]; then echo "mem limit!" - send "warnung%20Memory%20Usage%20is%20high%20$mem%25" + proc=$(memHighest) + send "warnung%20Memory%20Usage%20is%20high%20$mem%25%0A$proc" fi #CheckCerts diff --git a/cpu.sh b/cpu.sh index 11732e1..093d8fa 100755 --- a/cpu.sh +++ b/cpu.sh @@ -3,3 +3,7 @@ function cpuUsage { ps -A -o pcpu | tail -n+2 | paste -sd+ | bc | awk '{print int($1)}' } + +function cpuHighest { + ps -eo pid,cmd,%cpu --sort=-%cpu | head -2 | tail -n 1 +} diff --git a/mem.sh b/mem.sh index 5cb0ad9..29702f6 100755 --- a/mem.sh +++ b/mem.sh @@ -2,3 +2,7 @@ function memUsage { top -bn1 | sed -n 4p | awk '{ print int( $6 / $4 * 100) }' } + +function memHighest { + ps -eo pid,cmd,%mem --sort=-%mem | head -2 | tail -n 1 +}