Linux下网络流量监控netuse使用 阴

jackxiang 2016-6-26 11:35 | |
git clone https://github.com/dufferzafar/netuse /usr/local/netuse
cd /usr/local/netuse
cp config.py.example config.py
ln -s netuse.py /usr/bin/netuse

Crontab:



vi /usr/bin/netuse
#!/usr/bin/python3  
不存在python3怎么办?
ln -s /usr/bin/python /usr/bin/python3


vi /usr/local/netuse/dumper 把网卡修改成自己的网卡eth1:
# which registers itself as a ppp device.
echo $(cat /sys/class/net/ppp0/statistics/rx_bytes)";"$(date +%s) >> ~/.net/$year/$month/down/$date                                                          
echo $(cat /sys/class/net/ppp0/statistics/tx_bytes)";"$(date +%s) >> ~/.net/$year/$month/up/$date
修改为:

修改为:eth1


标准统计(主要看看vps一天多少流量):
[root@iZ25z0ugwgtZ netuse]# netuse
Downloaded:        5 MB
Uploaded:          0 MB

Data Left:      10235 MB
Days Left:         3 Days
End Date:       2016-06-29 (11:59 PM)

Suggested:      3411 MB (Per Day)

一周一瞥(好像有点问题):
[root@iZ25z0ugwgtZ netuse]# netuse -w
Data downloaded this week:

Traceback (most recent call last):
  File "/bin/netuse", line 277, in <module>
    weekly()
  File "/bin/netuse", line 186, in weekly
    format="{:>5.0f}",
  File "/usr/local/netuse/termgraph.py", line 56, in chart
    print_blocks(labels[i], data[i], step, args)
  File "/usr/local/netuse/termgraph.py", line 63, in print_blocks
    blocks = int(count / step)
ZeroDivisionError: integer division or modulo by zero

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/8765/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2016-6-26 11:38
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]