-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipc-monitor
45 lines (38 loc) · 909 Bytes
/
ipc-monitor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
########################
#### IPC-Monitor #######
########################
# Start webserver
lighttpd -D -f /etc/lighttpd/lighttpd.conf &
# Start Monitoring
while :
do
# Get CPU Temp
CPUTEMP=$(paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | awk '{ print $2 }' | sed 's/\(.\)..$//')
# Set color depending on temp
if [ "$CPUTEMP" -le 68 ]; then
CPUCOL="green"
fi
if [ "$CPUTEMP" -ge 69 ] && [ "$CPUTEMP" -le 74 ]; then
CPUCOL="orange"
fi
if [ "$CPUTEMP" -ge 75 ]; then
CPUCOL="red"
fi
# Write index.html
cat <<EOF > /var/www/localhost/htdocs/index.html
<html>
<head>
<title>IPC Monitoring</title>
<meta http-equiv="refresh" content="1">
</head>
<body>
<h1>IPC-Monitoring</h1>
<p style="color:$CPUCOL;">
CPU Temp: $CPUTEMP ℃
</p>
</body>
</html>
EOF
# Repeat until stop
sleep 1
done