Files
syno_scripts/monitor.sh
2018-03-13 08:04:28 +01:00

55 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
uptime
echokos () {
if [ $1 -ge 1024 ] ; then
echo "$(( $1 / 1024 )) Mo/s"
else
echo "$(( $1 )) Ko/s"
fi
}
total () {
multiplier="0"
number="$1"
while [ "$number" -ge 1024 ] ; do
multiplier=$(($multiplier + 1))
number=$(($number / 1024))
done
case "$multiplier" in
1)
echo "$number Ko"
;;
2)
echo "$number Mo"
;;
3)
echo "$number Go"
;;
4)
echo "$number To"
;;
*)
echo "$1 o"
;;
esac
}
R1=$(cat /sys/class/net/eth0/statistics/rx_bytes)
T1=$(cat /sys/class/net/eth0/statistics/tx_bytes)
sleep 5
R2=$(cat /sys/class/net/eth0/statistics/rx_bytes)
T2=$(cat /sys/class/net/eth0/statistics/tx_bytes)
TBPS=$(($T2 - $T1))
RBPS=$(($R2 - $R1))
TKBPS=$(($TBPS / 1024 / 5))
RKBPS=$(($RBPS / 1024 / 5))
echo "D/L: $(echokos $RKBPS) ($(total $T2)) • U/L: $(echokos $TKBPS) ($(total $R2))"
echo ""
echo "## CONNEXIONS ACTIVES"
tor=$(netstat -ntp | grep -c tor)
bt=$(netstat -ntp | grep -c transmission)
ftp=$(netstat -nt | grep -c 4275)
afp=$(netstat -ntp | grep -c afpd)
echo "$tor peers TOR""$bt peers BT""$ftp FTP • $afp AFP"
echo ""
echo "## ACTIVITÉ BITTORRENT"
/usr/local/transmission/bin/transmission-remote -l | grep -v "Idle\|Stopped"
/usr/local/transmission/bin/transmission-remote -st | sed -e '/^TOTAL/,$d'