Browse Source

process list script

master
Simon Vieille 4 years ago
parent
commit
fa537df153
1 changed files with 33 additions and 0 deletions
  1. 33
    0
      processList.sh

+ 33
- 0
processList.sh View File

@@ -0,0 +1,33 @@
#!/bin/sh

echo "{\"version\":1}"

INFO='#E9F1FF'
NORMAL='#B3FF6C'
WARNING='#FF6836'
CRITICAL='#FF474A'

echo "[[]"

while true; do
(
echo -n ",["
ps ux --sort -%cpu | head -n 30 | sed 's/\s\{2,\}/ /g' | cut -d" " -f3,11 | uniq | grep -v uniq | egrep -v '^0.0' | egrep '^[0-9.]* [a-z]' | while read cpu bin; do
if [ $(echo "if (${cpu} < 3 ) 1 else 0" | bc) -eq 1 ]; then
COLOR=$INFO
elif [ $(echo "if (${cpu} < 40.0 ) 1 else 0" | bc) -eq 1 ]; then
COLOR=$NORMAL
elif [ $(echo "if (${cpu} < 70.0 ) 1 else 0" | bc) -eq 1 ]; then
COLOR=$WARNING
else
COLOR=$CRITICAL
fi
echo -n "{\"full_text\": \" $bin ($cpu%) \", \"color\": \"$COLOR\"},"
done
echo "]"
) | sed 's/,\]/]/'
sleep 5
done

Loading…
Cancel
Save