Skip to content
Snippets Groups Projects
Commit fc02d058 authored by Bob Mottram's avatar Bob Mottram
Browse files

Include disk i/o speed in system monitor

parent b56785e2
No related branches found
No related tags found
No related merge requests found
......@@ -1509,6 +1509,25 @@ function update_system_monitor {
cpu_temperature=$((cpu_temp / 1000))
fi
test_drive=/dev/sda1
if ! ls $test_drive; then
if ls /dev/mmcblk0p2; then
test_drive=/dev/mmcblk0p2
else
test_drive=
fi
fi
if [ "$test_drive" ]; then
disk_io_speed_percent=0
disk_io_speed=$(hdparm -t $test_drive | awk -F '= ' '{print $2}' | awk -F ' ' '{print $1}')
if [ "$disk_io_speed" ]; then
disk_io_speed_percent=$((disk_io_speed * 100 / 500))
if [ $disk_io_speed_percent -gt 100 ]; then
disk_io_speed_percent=100
fi
fi
fi
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
......@@ -1522,6 +1541,8 @@ function update_system_monitor {
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"
sed -i "s|<div name=\"diskio\" class=\"w3-container.*|<div name=\"diskio\" class=\"w3-container w3-blue w3-round-xlarge\" style=\"width:${disk_io_speed_percent}%\">${disk_io_speed} MB/s</div>|g" "$webadmin_install_dir/system_monitor.html"
chown www-data:www-data "$webadmin_install_dir/system_monitor.html"
fi
fi
......
......@@ -758,6 +758,25 @@ function webadmin_update_system_monitor {
cpu_temperature=$((cpu_temp / 1000))
fi
test_drive=/dev/sda1
if ! ls $test_drive; then
if ls /dev/mmcblk0p2; then
test_drive=/dev/mmcblk0p2
else
test_drive=
fi
fi
if [ "$test_drive" ]; then
disk_io_speed_percent=0
disk_io_speed=$(hdparm -t $test_drive | awk -F '= ' '{print $2}' | awk -F ' ' '{print $1}')
if [ "$disk_io_speed" ]; then
disk_io_speed_percent=$((disk_io_speed * 100 / 500))
if [ $disk_io_speed_percent -gt 100 ]; then
disk_io_speed_percent=100
fi
fi
fi
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
......@@ -771,6 +790,8 @@ function webadmin_update_system_monitor {
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"
sed -i "s|<div name=\"diskio\" class=\"w3-container.*|<div name=\"diskio\" class=\"w3-container w3-blue w3-round-xlarge\" style=\"width:${disk_io_speed_percent}%\">${disk_io_speed} MB/s</div>|g" "$webadmin_install_dir/system_monitor.html"
chown www-data:www-data "$webadmin_install_dir/system_monitor.html"
fi
}
......
......@@ -96,6 +96,11 @@
<div name="cputemp" class="w3-container w3-blue w3-round-xlarge" style="width:40%">40°C</div>
</div>
<p class="titletext">Disk I/O Speed</p>
<div class="w3-light-grey w3-round-xlarge">
<div name="diskio" class="w3-container w3-blue w3-round-xlarge" style="width:10%">20 MB/s</div>
</div>
<br><br>
<form action="systemmonitor.php" method="post">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment