TOP ▲ itcore TOPTIPSmrtg.php

MRTG ルータの複数ポートの合計をグラフ化する。 | itcore 2018年

[/etc/mrtg/mrtg36.cfg]
WorkDir: /var/www/mrtg/36
Options[_]: bits
Timezone[_]: Japan
MaxBytes[_]: 4000000
Unscaled[_]: dwmy
EnableIPv6: no
#-----------------------------------------------------------------
# インターネット出口 port1 + port11
#-----------------------------------------------------------------
Target[Internet]: `/etc/mrtg/internet.sh`
Title[Internet]: Internet
PageTop[Internet]: <h1>Internet</h1>

[/etc/mrtg/internet.sh]
#!/bin/sh
uptime=`snmpwalk -v 2c -c public 161.213.223.36 .1.3.6.1.2.1.1.3 | cut -d ' ' -f 5-`
# DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (3362467594) 389 days, 4:11:15.94
in_port1=`snmpwalk -v 2c -c public 161.213.223.36 .1.3.6.1.2.1.2.2.1.10.1 | awk '{ print $4}'`
in_port11=`snmpwalk -v 2c -c public 161.213.223.36 .1.3.6.1.2.1.2.2.1.10.11 | awk '{ print $4}'`
out_port1=`snmpwalk -v 2c -c public 161.213.223.36 .1.3.6.1.2.1.2.2.1.16.1 | awk '{ print $4}'`
out_port11=`snmpwalk -v 2c -c public 161.213.223.36 .1.3.6.1.2.1.2.2.1.16.11 | awk '{ print $4}'`
# IF-MIB::ifInOctets.1 = Counter32: 1361135738
in_internet=`expr $in_port1 + $in_port11`
out_internet=`expr $out_port1 + $out_port11`
echo $in_internet
echo $out_internet
echo $uptime
echo "Internet"