```
| ```
|
INTERVAL=3 # seconds
| INTERVAL=1 # seconds
|
if [ ! -e "$SHMFILE" ];then
| if [ -e "$SHMFILE" ];then
cat "$SHMFILE"
else
|
else
cat "$SHMFILE"
| |
if [ -e "$SHMFILE" ];then
# possible race condition, another daemon already running
exit 0
| cd /
umask 177 # u+rw,g-rwx,o-rwx
# check for file in atomic operation
(set -o noclobber;>"$SHMFILE") &> /dev/null
if [ "$?" == 1 ]; then
# file exists, possible race condition, another daemon already running
exit 1
|
cd /
umask 177 # u+rw,g-rwx,o-rwx
touch "$SHMFILE"
| |
a=($r)
r1=${a[0]}
t1=${a[1]}
r2=${a[2]}
t2=${a[3]}
rkbps=`awk "BEGIN {printf \"%d\", ($r2 - $r1) / 1024 * (1 / $INTERVAL)}"`
| if [ "$?" == 0 ];then
a=($r)
r1=${a[0]}
t1=${a[1]}
r2=${a[2]}
t2=${a[3]}
rkbps=`awk "BEGIN {printf \"%d\", ($r2 - $r1) / 1024 * (1 / $INTERVAL)}"`
|
echo -n "<txt><span weight='bold' fgcolor='#FFF900' bgcolor='red'> $rkbps kb/s / $tkbps kb/s </span></txt>" > "$SHMFILE"
| echo -n "<txt><span weight='bold' fgcolor='#FFF900' bgcolor='red'> $rkbps kb/s / $tkbps kb/s </span></txt>" > "$SHMFILE"
else
echo -n "<txt><span weight='bold' fgcolor='#FFF900' bgcolor='red'> qvm-run failed </span></txt>" > "$SHMFILE"
fi
|