From cf21ec99acfc6c1760e9e092acc6382175bc86ce Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@freedombone.net> Date: Tue, 14 Aug 2018 12:20:32 +0100 Subject: [PATCH] Add cpu temperature to system monitor screen --- src/freedombone-installer | 5 +++++ src/freedombone-utils-webadmin | 5 +++++ webadmin/EN/system_monitor_template.html | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/freedombone-installer b/src/freedombone-installer index 25f7712b8..850743546 100755 --- a/src/freedombone-installer +++ b/src/freedombone-installer @@ -1400,6 +1400,9 @@ function update_system_monitor { total_memory=$(free -m | grep "Mem:" | awk -F ' ' '{print $2}') used_memory_percent=$((used_memory * 100 / total_memory)) + cpu_temp=$(cat /sys/class/thermal/thermal_zone*/temp | head -n 1) + cpu_temperature=$((cpu_temp / 1000)) + local_hostname=$(grep 'host-name' /etc/avahi/avahi-daemon.conf | awk -F '=' '{print $2}').local webadmin_install_dir="/var/www/${local_hostname}/htdocs/admin" if [ -f "$webadmin_install_dir/system_monitor_template.html" ]; then @@ -1411,6 +1414,8 @@ function update_system_monitor { sed -i "s|<div name=\"memory\" class=\"w3-container.*|<div name=\"memory\" class=\"w3-container w3-blue w3-round-xlarge\" style=\"width:${used_memory_percent}%\">${used_memory_percent}%</div>|g" "$webadmin_install_dir/system_monitor.html" + sed -i "s|<div name=\"cputemp\" class=\"w3-container.*|<div name=\"cputemp\" class=\"w3-container w3-blue w3-round-xlarge\" style=\"width:${cpu_temperature}%\">${cpu_temperature}°C</div>|g" "$webadmin_install_dir/system_monitor.html" + chown www-data:www-data "$webadmin_install_dir/system_monitor.html" fi fi diff --git a/src/freedombone-utils-webadmin b/src/freedombone-utils-webadmin index 7159dc335..7b40cd85f 100755 --- a/src/freedombone-utils-webadmin +++ b/src/freedombone-utils-webadmin @@ -705,6 +705,9 @@ function webadmin_update_system_monitor { total_memory=$(free -m | grep "Mem:" | awk -F ' ' '{print $2}') used_memory_percent=$((used_memory * 100 / total_memory)) + cpu_temp=$(cat /sys/class/thermal/thermal_zone*/temp | head -n 1) + cpu_temperature=$((cpu_temp / 1000)) + local_hostname=$(grep 'host-name' /etc/avahi/avahi-daemon.conf | awk -F '=' '{print $2}').local webadmin_install_dir="/var/www/${local_hostname}/htdocs/admin" if [ -f "$webadmin_install_dir/system_monitor_template.html" ]; then @@ -716,6 +719,8 @@ function webadmin_update_system_monitor { sed -i "s|<div name=\"memory\" class=\"w3-container.*|<div name=\"memory\" class=\"w3-container w3-blue w3-round-xlarge\" style=\"width:${used_memory_percent}%\">${used_memory_percent}%</div>|g" "$webadmin_install_dir/system_monitor.html" + sed -i "s|<div name=\"cputemp\" class=\"w3-container.*|<div name=\"cputemp\" class=\"w3-container w3-blue w3-round-xlarge\" style=\"width:${cpu_temperature}%\">${cpu_temperature}°C</div>|g" "$webadmin_install_dir/system_monitor.html" + chown www-data:www-data "$webadmin_install_dir/system_monitor.html" fi } diff --git a/webadmin/EN/system_monitor_template.html b/webadmin/EN/system_monitor_template.html index c5a5d3134..6f8b8fe35 100644 --- a/webadmin/EN/system_monitor_template.html +++ b/webadmin/EN/system_monitor_template.html @@ -91,6 +91,11 @@ <div name="memory" class="w3-container w3-blue w3-round-xlarge" style="width:80%">80%</div> </div> + <p class="titletext">CPU temperature</p> + <div class="w3-light-grey w3-round-xlarge"> + <div name="cputemp" class="w3-container w3-blue w3-round-xlarge" style="width:40%">40°C</div> + </div> + <br><br> <form action="systemmonitor.php" method="post"> -- GitLab