added settings support
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
#!/bin/bash
|
||||
# UNO Monitor Sender
|
||||
# UNO Monitor Sender v.0.1.0
|
||||
# Kidacro <kidacro@archamedis.net>
|
||||
#
|
||||
# https://kidacro.archamedis.net/git/kidacro/Arduino/src/branch/main/uno-stats-monitor
|
||||
# monitor_sender.sh - Bash stats sender suitable for cron
|
||||
#
|
||||
# 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@
|
||||
# LAVG -: #324@
|
||||
# LSET 0: #016:5:1:3@
|
||||
#
|
||||
# Output Schema:
|
||||
# Multimedia Controls use single characters to denote which button was pressed
|
||||
@@ -40,6 +43,12 @@
|
||||
|
||||
# TTY Device to use
|
||||
TTY="/dev/ttyACM0"
|
||||
|
||||
# Arduino Settings
|
||||
LCDLength=16
|
||||
LCDDelay=3
|
||||
LEDBrightness=1
|
||||
LEDDelay=3
|
||||
##########################################################
|
||||
|
||||
round() {
|
||||
@@ -48,7 +57,6 @@ 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)}')
|
||||
|
||||
@@ -56,19 +64,22 @@ CLOAD=$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1)
|
||||
CLOAD=${CLOAD:0:-1}
|
||||
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 ', ')
|
||||
LFREE=$(df -h | grep /dev/sdc1 | awk '{print $4}' | paste -sd ', ')
|
||||
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
|
||||
|
||||
# send settings
|
||||
LINE0="#0$LCDLength:$LCDDelay:$LEDBrightness:$LEDDelay@"
|
||||
/usr/bin/echo "$LINE0" > $TTY
|
||||
echo Sending to $TTY: $LINE0
|
||||
|
||||
# line 1
|
||||
LINE1="#1$CLOAD% $CTEMP $MFREE@"
|
||||
/usr/bin/echo "$LINE1" > $TTY
|
||||
@@ -80,6 +91,6 @@ LINE2="#2$RFREE $LFREE $SFREE@"
|
||||
echo Sending to $TTY: $LINE2
|
||||
|
||||
# load average
|
||||
LINE3="#3$CLOAD@"
|
||||
LINE3="#-$CLOAD@"
|
||||
/usr/bin/echo "$LINE3" > $TTY
|
||||
echo Sending to $TTY: $LINE3
|
||||
|
||||
Reference in New Issue
Block a user