-
Notifications
You must be signed in to change notification settings - Fork 5
/
system-stats-xen
executable file
·47 lines (42 loc) · 1.08 KB
/
system-stats-xen
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
46
47
#!/bin/sh
## System stats for Qubes dom0
## Chris Laprise 2018
## https://github.com/tasket/Qubes-scripts
delay=5
sortcol=3
sensor_lines='Package id 0|fan1'
newline='
'
header="\033[2K\nVM NAME CPU(% ) MEMORY(MB)"
sumline="________________________________________"
other_stats () {
sensors |grep -E "^($sensor_lines)"
}
clear
other_stats
echo -e "$header\n"
cpusum=0; memsum=0; table="$sumline"
stdbuf -oL xentop -b -f -d $delay \
| stdbuf -oL awk '{printf ("%-22s %5d %7d\n", $1,$4,$5/1000) }' \
| (
read ln
while true; do
read -t 0.1 ln
if [ $? = 0 ]; then
table="$table$newline$ln"
read name cpu mem <<<"$ln"
(( cpusum += cpu ))
(( memsum += mem ))
else # End of list, print totals, make new page.
sort -k $sortcol -n -r <<<"$table"
printf '%-22s %5d %7d\033[J\033[H' " " $cpusum $memsum
read ln
cpusum=0; memsum=0
table="$sumline"
#clear
#sensors |grep -E "^($sensor_lines)"
other_stats
echo -e "$header\n\033[2K"
fi
done
)