snmpget 192.168.0.5 -c hogehoge ifOutOctets.2 ifInOctets.2 |
#!/bin/sh date snmpget 192.168.0.5 -c hogehoge ifOutOctets.2 ifInOctets.2 |
chmod 755 traffic |
[/usr/local/bin]$ traffic 2004年 7月 6日 火曜日 20:15:14 JST interfaces.ifTable.ifEntry.ifOutOctets.2 = Counter32: 1878082077 interfaces.ifTable.ifEntry.ifInOctets.2 = Counter32: 62298744 |
#!/bin/sh date >> /var/log/traffic.log snmpget 192.168.0.5 -c hogehoge ifOutOctets.2 ifInOctets.2 >> /var/log/traffic.log |
chmod 755 traffic-log |
[root]# crontab -l # DO NOT EDIT THIS FILE - edit the master and reinstall. # (/tmp/crontab.15493 installed on Mon Jul 5 22:34:31 2004) # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $) */2 * * * * /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/bin/mrtg127.cfg |
crontab -e |
*/2 * * * * /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/bin/mrtg127.cfg 0 * * * * /usr/local/bin/traffic-log ~ |
[root]# tail -12 traffic.log Tue Jul 6 03:00:00 JST 2004 interfaces.ifTable.ifEntry.ifOutOctets.2 = Counter32: 853309161 interfaces.ifTable.ifEntry.ifInOctets.2 = Counter32: 32660076 Tue Jul 6 04:00:00 JST 2004 interfaces.ifTable.ifEntry.ifOutOctets.2 = Counter32: 1159173337 interfaces.ifTable.ifEntry.ifInOctets.2 = Counter32: 40872960 Tue Jul 6 05:00:00 JST 2004 interfaces.ifTable.ifEntry.ifOutOctets.2 = Counter32: 1354041122 interfaces.ifTable.ifEntry.ifInOctets.2 = Counter32: 46430373 Tue Jul 6 06:00:00 JST 2004 interfaces.ifTable.ifEntry.ifOutOctets.2 = Counter32: 1356877970 interfaces.ifTable.ifEntry.ifInOctets.2 = Counter32: 46596295 |