DD2-monitor/exemple.sh

41 lines
529 B
Bash
Raw Normal View History

2018-12-06 02:30:13 +11:00
#!/bin/bash
DATAFILE=/tmp/fake-datafile
2018-12-06 03:58:55 +11:00
#----- collect the datas
2018-12-06 02:30:13 +11:00
> ${DATAFILE}
2018-12-14 05:39:06 +11:00
for s in $(seq 1 2000)
2018-12-06 02:30:13 +11:00
do
2019-01-27 23:03:59 +11:00
v=$(./fake-values -s -t 4)
2018-12-06 03:58:55 +11:00
echo $s $v >> ${DATAFILE}
2018-12-06 02:30:13 +11:00
done
2019-01-27 23:03:59 +11:00
tail -5 ${DATAFILE}
2018-12-06 03:58:55 +11:00
#----- do dome useless computations
awk '
2019-01-27 23:03:59 +11:00
NR==1 {
debut = $2
}
2018-12-14 05:39:06 +11:00
{
# print $2-debut, $3
2019-01-27 23:03:59 +11:00
v = int($3/35);
2018-12-14 05:39:06 +11:00
bucket[v]++;
}
2019-01-27 23:03:59 +11:00
2018-12-14 05:39:06 +11:00
END {
for (v=0; v<40; v++) {
2019-01-27 23:03:59 +11:00
printf "%4d ", v;
for (foo=0; foo<bucket[v]/2; foo++) {
2018-12-14 05:39:06 +11:00
printf "-";
}
print "*"
}
}
2018-12-06 03:58:55 +11:00
' \
< ${DATAFILE}
2018-12-06 02:48:53 +11:00