Situatie
Vrem sa contorizam traficul de net folosit pe zi / luna.
Solutie
Pasi de urmat
Ne logam pe SSH la router dd-wrt (default este 192.168.1.1)
Introducem credentialele (default : username : root passowrd : root )
Pe calculator deschidem notepad si introducem urmatorul text :
#!/bin/sh fnc_mail() { subj="$1" msg="$2" if [ -z "$3" -o "$(dirname $3)" = "." ]; then logfile="/tmp/lastmail.log"; else logfile="$3"; fi sendmail -S"server.smtp.care.trimite" -f"cinetrimite@server.net" -F"DD-WRT" -d"server.net" -s"$subj" -m"$msg" unde-sa-ajunga@gmail.com > $logfile 2>&1 } #cauta traficul din ziua precedenta si luna in curs apoi trimite email aff="aff" #keyword workaround yday=$(date -D %s -d $(( $(date +%s) - 86400)) +%d) ymon=$(date -D %s -d $(( $(date +%s) - 86400)) +tr$aff-%m-%Y) if [ $(date +%d) -eq 1 ]; then monmsg="Last Month"; else monmsg="Month to Date"; fi msg=$(nvram get $ymon | awk '{print $'$yday', $NF}' | sed 's/([^:]*):([^ ]*) [([^:]*):([^]]*)]/Totals for YesterdaynIncoming: 1 MBnOutgoing: 2 MBnnTotals for '"${monmsg}"'nIncoming: 3 MBnOutgoing: 4 MBn/') fnc_mail "Bandwidth Report" "$msg" "/tmp/bwmail.log"
Dupa ce ne-am logat uploadam in /tmp fisierul trafic.sh
Din putty rulam urmatoarele comenzi :
cd /tmp
chmod +x trafic.sh
./trafic.sh
Leave A Comment?