diff --git a/mesh_bot.py b/mesh_bot.py index 52d9c52..911b69a 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -770,7 +770,7 @@ def sysinfo(message, message_from_id, deviceID): return "sysinfo command returns system information." else: if enable_runShellCmd and file_monitor_enabled: - shellData = call_external_script(message) + shellData = call_external_script(message).rstrip() return get_sysinfo(message_from_id, deviceID) + "\n" + shellData else: return get_sysinfo(message_from_id, deviceID) diff --git a/runShell.sh b/runShell.sh index c626bde..c993750 100644 --- a/runShell.sh +++ b/runShell.sh @@ -9,7 +9,7 @@ free_space=$(df -h | grep ' /$' | awk '{print $4}') cpu_usage=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}') ram_usage=$(free | grep Mem | awk '{print $3/$2 * 100.0}') -# if command vcgencmd is found +# if command vcgencmd is found, part of raspberrypi tools, use it to get temperature if command -v vcgencmd &> /dev/null then # get temperature @@ -17,11 +17,11 @@ then # temp in fahrenheit tempf=$(echo "scale=2; $temp * 9 / 5 + 32" | bc) else + # get temperature from thermal zone temp=$(paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | grep "temp" | awk '{print $2/1000}' | awk '{s+=$1} END {print s/NR}') tempf=$(echo "scale=2; $temp * 9 / 5 + 32" | bc) fi - # print telemetry data printf "Free Space: %s\n" "$free_space" printf "CPU Usage: %.1f%%\n" "$cpu_usage"