Add disk sensor
[khatus.git] / x4 / sanity_check
CommitLineData
4411059d
SK
1#! /bin/sh
2
3set -e
4
5. ./bin/khatus_x4_lib_common_sensor.sh
6
7dir="${prefix}/${host}"
8
1fd28945 9sensors_kill_all() {
7c4d20a9
SK
10 for pid_file in $(find $dir -type f -name pid)
11 do
12 kill -9 $(cat $pid_file) || true
13 rm $pid_file
14 done
3565cd1d 15 pkill khatus_x4_sensor || true
4411059d
SK
16}
17
1fd28945
SK
18sensors_fork_all() {
19 ./bin/khatus_x4_sensor_datetime &
3565cd1d 20 ./bin/khatus_x4_sensor_bluetooth&
1fd28945
SK
21 ./bin/khatus_x4_sensor_mpd &
22 ./bin/khatus_x4_sensor_energy &
6f89e24d 23 ./bin/khatus_x4_sensor_memory &
731a145e 24 ./bin/khatus_x4_sensor_loadavg &
5bbff27d 25 ./bin/khatus_x4_sensor_temp -i 1 -- -z 0 &
8c587a02 26 ./bin/khatus_x4_sensor_disk -- -f / &
1fd28945
SK
27}
28
29sensor_read_one() {
4411059d
SK
30 if test -f "$1"
31 then
32 cat "$1"
33 else
34 printf '%s\n' '--'
35 fi
36}
37
1fd28945
SK
38sensors_read_all() {
39 while :
40 do
41 battery_state="$(sensor_read_one ${dir}/khatus_x4_sensor_energy/out/battery_state)"
42 battery_percentage="$(sensor_read_one ${dir}/khatus_x4_sensor_energy/out/battery_percentage)"
3565cd1d
SK
43 bluetooth_controllers="$(sensor_read_one ${dir}/khatus_x4_sensor_bluetooth/out/count_powered_controllers)"
44 bluetooth_devices="$(sensor_read_one ${dir}/khatus_x4_sensor_bluetooth/out/count_connected_devices)"
1fd28945
SK
45 datetime="$(sensor_read_one ${dir}/khatus_x4_sensor_datetime/out/datetime)"
46 mpd="$(sensor_read_one ${dir}/khatus_x4_sensor_mpd/out/status)"
6f89e24d 47 mem="$(sensor_read_one ${dir}/khatus_x4_sensor_memory/out/percent_used)"
731a145e 48 load="$(sensor_read_one ${dir}/khatus_x4_sensor_loadavg/out/load_avg_1min)"
5bbff27d 49 temp="$(sensor_read_one ${dir}/khatus_x4_sensor_temp/out/thermal_zone0)"
8c587a02
SK
50 disk="$(sensor_read_one ${dir}/khatus_x4_sensor_disk/out/disk_usage_percentage)"
51 echo "E[${battery_state} ${battery_percentage}] M:${mem}% L:${load} T:${temp}°C D:${disk}% [${mpd}] [$bluetooth_controllers $bluetooth_devices] ${datetime}"
1fd28945
SK
52 sleep 1
53 done
54}
55
56main() {
57 sensors_kill_all
58 sensors_fork_all
59 sensors_read_all
60}
61
62main
This page took 0.036686 seconds and 4 git commands to generate.