From 55783753ae8f2d857a7225b7a93c1d47039e5a90 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Mon, 16 Apr 2018 10:30:15 +0200 Subject: OpenShift monitoring --- scripts/emerge-status.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 scripts/emerge-status.sh (limited to 'scripts/emerge-status.sh') diff --git a/scripts/emerge-status.sh b/scripts/emerge-status.sh new file mode 100755 index 0000000..a1241ef --- /dev/null +++ b/scripts/emerge-status.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# emerge-status.sh by Hellf[i]re +# +# This script will report the current status of portage. +# +# Usage: +# .conkyrc: ${execi [time] /path/to/script/emerge-current.sh} +# +# Usage Example +# ${execi 30 /home/youruser/scripts/emerge-current.sh} +# +# Known Bugs: +# 1) If there are two emerges running at once, when the first one finishes +# running, the script will report the current status as "Completed". +# 2) If there is a emerge running and you run a search, the script will +# report the current status as "Completed", until the running emerge +# moves to the next package, or itself completes. +# The reasons for this are twofold - one, it's a feature ;) and two, there +# would be far too much parsing required to find out the current status of +# every command which is run in parallel. + +STATUS=`tail -n 15 /var/log/emerge.log |\ +grep -iE "Compiling|Cleaning|AUTOCLEAN|completed|search|terminating|rsync" |\ +cut -d ' ' -f "2-" |\ +grep -Ev 'Finished\.|Cleaning up\.\.\.' |\ +tail -n 1` + +#echo "$STATUS" + +if [ "`echo "$STATUS" | grep -i compiling`" != "" ]; then echo Compiling +elif [ "`echo "$STATUS" | grep -i cleaning`" != "" ]; then echo Cleaning +elif [ "`echo "$STATUS" | grep -i autoclean`" != "" ]; then echo Autoclean +elif [ "`echo "$STATUS" | grep -i sync`" != "" ]; then echo Syncing +elif [ "`echo "$STATUS" | grep -i search`" != "" ]; then echo Searching +elif [ "`echo "$STATUS" | grep -i completed`" != "" ]; then echo Completed +elif [ "`echo "$STATUS" | grep -i terminating`" != "" ]; then echo Completed +else echo Script Error! +fi -- cgit v1.2.3