summaryrefslogtreecommitdiffstats
path: root/scripts/emerge-status.sh
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2018-04-16 10:30:15 +0200
committerSuren A. Chilingaryan <csa@suren.me>2018-04-16 10:30:15 +0200
commit55783753ae8f2d857a7225b7a93c1d47039e5a90 (patch)
treee077b61b0f004141712e7d16876f9c19175ac681 /scripts/emerge-status.sh
downloadconky-55783753ae8f2d857a7225b7a93c1d47039e5a90.tar.gz
conky-55783753ae8f2d857a7225b7a93c1d47039e5a90.tar.bz2
conky-55783753ae8f2d857a7225b7a93c1d47039e5a90.tar.xz
conky-55783753ae8f2d857a7225b7a93c1d47039e5a90.zip
OpenShift monitoring
Diffstat (limited to 'scripts/emerge-status.sh')
-rwxr-xr-xscripts/emerge-status.sh39
1 files changed, 39 insertions, 0 deletions
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