usage: trackthis VALUE (OUTPUT_FILE)
Code: Select all
#!/bin/bash
# tracks anything you throw at it
# scale is 1:6
horizontal=$1
scaled=6
if [[ $2 == "" ]]; then
trackfile=/tmp/trackfile
else
trackfile=$2
fi
graph(){
for i in `seq $1`
do
if [ `expr $i % $scaled` -eq 0 ]
then
echo -n "="
fi
done
echo " $horizontal"
}
printgraph(){
for line in ${horizontal[@]}
do
etad=$(date +%H:%M:%S)
(printf "$etad: " 2>&1) | tee -a $trackfile
(graph $horizontal 2>&1) | tee -a $trackfile
done
}
while :
do
read -a horizontal
printgraph
exit 0
done
Code: Select all
[email protected]:~$ while true; do free -m |grep cache|tail -n1|awk '{ print $3 }' | trackthis; sleep 2s; done
19:29:08: ============================================ 268
19:29:10: ============================================ 268
19:29:12: ============================================ 268