diff --git a/uno-stats-monitor/monitor_sender.sh b/uno-stats-monitor/monitor_sender.sh index 42e418e..c81edc5 100644 --- a/uno-stats-monitor/monitor_sender.sh +++ b/uno-stats-monitor/monitor_sender.sh @@ -1,7 +1,42 @@ #!/bin/bash # UNO Monitor Sender -# kidacro@archamedis.net +# Kidacro # +# Input Schema: +# Start char is: '#' +# End char is: '@' +# 2nd char denotes which line number/mode to use +# +# Example: +# Line 1: #1Archamedis Status@ +# Line 2: #299% free / etc.@ +# LAVG 3: #324@ +# +# Output Schema: +# Multimedia Controls use single characters to denote which button was pressed +# P power +# M mute +# m mode +# p pause/play +# b back +# f forward +# e eq +# - vol down +# + vol up +# r return +# u usb scan +# 0 number 0 +# 1 number 1 +# 2 number 2 +# 3 number 3 +# 4 number 4 +# 5 number 5 +# 6 number 6 +# 7 number 7 +# 8 number 8 +# 9 number 9 +# R repeat +# Z other button pressed # TTY Device to use TTY="/dev/ttyACM0" @@ -13,15 +48,20 @@ round() { # Stats # we are limited to 2 lines and 16 chars per line so, light stats & no labels + #CLOAD=$(mpstat | awk '$3 ~ /CPU/ { for(i=1;i<=NF;i++) { if ($i ~ /%idle/) field=i } } $3 ~ /all/ { printf("%d%%",100 - $field) }') #CLOAD=$(cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS="" '{print ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}') CLOAD=$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' <(grep 'cpu ' /proc/stat) <(sleep 0.5;grep 'cpu ' /proc/stat)) CLOAD=${CLOAD:0:-1} -CLOAD=$(round ${CLOAD} 0)% +CLOAD=$(round ${CLOAD} 0) + +#CMHZ= CTEMP=$(sensors | grep TSI0_TEMP: | tr '°+' ' ' | awk '{print $2}' | paste -sd ', ')C + MFREE=$(free -h | grep Mem | awk '{print $4}' | paste -sd ', ') + RFREE=$(df -h | grep /dev/nvme0n1p3 | awk '{print $4}' | paste -sd ', ') LFREE=$(df -h | grep /dev/sda1 | awk '{print $4}' | paste -sd ', ') SFREE=$(df -h | grep /dev/mapper/store0-lvol1 | awk '{print $4}' | paste -sd ', ') @@ -29,12 +69,17 @@ SFREE=$(df -h | grep /dev/mapper/store0-lvol1 | awk '{print $4}' | paste -sd ', # setup device stty -F $TTY ispeed 9600 ospeed 9600 -ignpar cs8 -cstopb -echo -hupcl -# Line 1 -LINE1="#1$CLOAD $CTEMP $MFREE@" -/usr/bin/echo "$LINE1" > $TTY # -ne +# line 1 +LINE1="#1$CLOAD% $CTEMP $MFREE@" +/usr/bin/echo "$LINE1" > $TTY echo Sending to $TTY: $LINE1 # line 2 LINE2="#2$RFREE $LFREE $SFREE@" /usr/bin/echo "$LINE2" > $TTY echo Sending to $TTY: $LINE2 + +# load average +LINE3="#3$CLOAD@" +/usr/bin/echo "$LINE3" > $TTY +echo Sending to $TTY: $LINE3