最後更新: 2024-04-24
目錄
介紹
CLI
- iftop # Console, 有 Per IP
- bmon # Console & HTML. 沒有 Per IP
有歷史記錄的
* vnstat # 本身是 console. GUI 有 luci-app-vnstat, 沒有 Per IP
# luci-app-vnstat 為了 gen 圖, 會安裝 libjpeg-turbo, libpng, libwebp, libgd
* nlbwmon
* wrtbwmon # 利用 iptables 的 cron script
唔建議安
- bandwidthd # 大食. graphs and charts are built by individual IPs [Per User]
- collectd # 大食. GUI: luci_app_statistics
iftop
opkg install iftop
# 要用 'br-lan' 如果用 eth0 的話會看不到 lan 內每 IP 的情況
# 不做 hostname 及 port lookups, 不顯示頭頂那條 bar
NCURSES_NO_UTF8_ACS=1 iftop -nNb -i br-lan
bmon
https://github.com/tgraf/bmon
opkg install bmon
interface: vmbr0 at myserver bmon 2.0.1 # Interface RX Rate RX # TX Rate TX # qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq myserver (source: local) 0 vmbr0 1.01KiB 18 1.22KiB 2 1 lo 0.00B 0 0.00B 0 2 eth1 0.00B 0 0.00B 0 3 eth0 1.28KiB 18 1.22KiB 2 4 vmbr1 0.00B 0 0.00B 0 qqqqqqqqqqqqqqqqqqqq Press g to enable graphical statistics qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqq Press d to enable detailed statistics qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq ^ prev interface, v next interface, <- prev node, -> next node, ? help
Display Settings
- g Toggle graphical statistics
- d Toggle detailed statistics
- c Toggle combined node list
- l Toggle interface list
- f (Un)fold sub interfaces
Write HTML statistics
opkg install uhttpd bmon
/etc/init.d/uhttpd start
mkdir /tmp/bmon
ln -s /tmp/bmon/ /www/
bmon -O html:path=/www/bmon/
wrtbwmon
https://github.com/pyrovski/wrtbwmon
Backup Data
# local backup storage 15 * * * * cp /tmp/usage.db /mnt/usbdrive/wrtbwmon/ * * * * * [ ! -f /tmp/usage.db ] && cp /mnt/usbdrive/wrtbwmon/usage.db /tmp/ # online backup storage 15 * * * * cd /tmp && ftpput -u username -p password usage.db . some_ftp_server_url * * * * * [ ! -f /tmp/usage.db ] && wget some_url/usage.db -O /tmp/usage.db
Daily-log-rotation
0 0 * * * mv /tmp/usage.db /mnt/usbdrive/wrtbwmon/usage-$(date '+%Y.%m.%d').db