[Xfce4-commits] [panel-plugins/xfce4-genmon-plugin] 01/01: Add sysstat script and fix permissions

noreply at xfce.org noreply at xfce.org
Sat Mar 4 13:50:37 CET 2017


This is an automated email from the git hooks/post-receive script.

ToZ pushed a commit to branch master
in repository panel-plugins/xfce4-genmon-plugin.

commit fc3b5f83db754bd0b6c4c25ce2474be90995d417
Author: ToZ <tony.paulic at gmail.com>
Date:   Sat Mar 4 07:50:17 2017 -0500

    Add sysstat script and fix permissions
---
 scripts/gmail   |  0
 scripts/sysstat | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/scripts/gmail b/scripts/gmail
old mode 100644
new mode 100755
diff --git a/scripts/sysstat b/scripts/sysstat
new file mode 100755
index 0000000..90bbb87
--- /dev/null
+++ b/scripts/sysstat
@@ -0,0 +1,61 @@
+#!/bin/bash
+#
+# display available system resources as padded non-decimal percentage digits
+#   CPU = current cpu usage
+#   MEM = current memory in use percentage
+#   HD = current percentage of hard drive in use
+
+
+# debug mode - to turn on, set to 1 (run script manually to see debug outputs)
+DEBUG=0
+
+# set valid icon path if you want an icon displayed before output
+#   if you don't want an icon, comment out the line
+#ICON=
+ICON=/home/toz/.icons/taskman.png
+
+# get CPU info
+CPU=$(cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS="" '{printf("%02d", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5))}')
+[ $DEBUG -eq 1 ] && echo "DEBUG: cpu -> "$CPU
+CPULOAD=$(uptime | tr -s " " | cut -d' ' -f9-)
+[ $DEBUG -eq 1 ] && echo "DEBUG: cpu load -> "$CPULOAD
+TOPCPU=$(ps aux --no-headers | awk '{print $3 " "  $11}' | sort -rn | head -n 5)
+
+# get memory info
+MEMTOT=$(cat /proc/meminfo | grep MemTotal | awk '{printf ("% 0.1f", $2/1024000)}')
+[ $DEBUG -eq 1 ] && echo "DEBUG: mem total-> "$MEMTOT
+MEMAVA=$(cat /proc/meminfo | grep MemAvailable | awk '{printf ("%0.1f", $2/1024000)}')
+[ $DEBUG -eq 1 ] && echo "DEBUG: mem availalbe-> "$MEMAVA
+MEMUSAGE=$(free | grep Mem | awk '{printf("%02d",  $3/$2 * 100.0)}')
+[ $DEBUG -eq 1 ] && echo "DEBUG: mem usage-> "$MEMUSAGE
+MEMUSAGE2=$(echo "$MEMTOT GB in use")
+[ $DEBUG -eq 1 ] && echo "DEBUG: mem usage tooltip -> "$MEMUSAGE2
+MEMUSED=$(echo "scale=2;($MEMTOT - $MEMAVA)" | bc)
+TOPMEM=$(ps aux --no-headers | awk '{print $4 " "  $11}' | sort -rn | head -n 5)
+
+# get hard drive usage info 
+HD=$(df -hl /dev/sda1 | grep sda1 | awk '{printf ("%02d", $5)}' | sed -e 's/%//')
+[ $DEBUG -eq 1 ] && echo "DEBUG: hd -> "$HD
+HDUSED=$(df -hl /dev/sda1 | grep sda1 | awk '{print $3}' | sed -e 's/G//')
+HDSIZE=$(df -hl /dev/sda1 | grep sda1 | awk '{print $2}' | sed -e 's/G//')
+[ $DEBUG -eq 1 ] && echo "DEBUG: hd size -> $HDSIZE GB drive capacity"
+TOPHD=$(df -hl /dev/sda1 | tail -1)
+
+# do the genmon
+[ $DEBUG -eq 1 ] && echo "DEBUG: genmon output"
+if [ -z $ICON ]; then
+   ICO_STR=""
+else
+   ICO_STR="<img>$ICON</img>"
+fi
+echo "$ICO_STR<txt> $CPU | $MEMUSAGE | $HD </txt><txtclick>xfce4-taskmanager</txtclick>
+<tool>-=CPU $CPULOAD=-
+$TOPCPU
+
+-=MEM: $MEMUSED of $MEMUSAGE2=-
+$TOPMEM
+
+-=HD usage: $HDUSED of $HDSIZE GB in use=-
+$TOPHD</tool>"
+
+exit 0
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list