Minggu, 20 Mei 2012

Buat MRTG dari iptables

cara membuat mrtg ato capture snmp melalui iptables:
iptables -t mangle -N newarmada
iptables -t mangle -A PREROUTING -s 202.78.196.91 -j newarmada
iptables -t mangle -A POSTROUTING -d
202.78.196.91 -j newarmada
iptables -t mangle -A newarmada -j ACCEPT
setelah itu save iptablesnya
iptables-save > /etc/sysconfig/iptables
edit snmpd.conf :
exec .1.3.6.1.4.1.2021.123 trafik /bin/sh
/usr/local/sbin/trafstat.sh anu123 (angka 123 setelah angka 2021 adalah
nomor urutan rule)
isi dari trafstat.sh:
#!/bin/sh
statname=$1
uptime=unused
statin=`iptables -t mangle -nL PREROUTING -vx | grep -w $statname | awk '{print s+=$2}' | tail -1`
statout=`iptables -t mangle -nL POSTROUTING -vx | grep -w $statname | awk '{print s+=$2}' | tail -1`
echo $statin

echo $statout
echo $statname
echo $uptime
trs restart dech snmpnya hehehehe
untuk setting mrtg.cfgnya:
# Created by
# ./cfgmaker bridg3@202.78.192.164
### Global Config Options
# for UNIX
WorkDir: /var/www/mrtg/mrtghtb
# or for NT
# WorkDir: c:\mrtgdata
### Global Defaults
# to get bits instead of bytes and graphs growing to the right

Options[_]: growright, bits
##############################
########################################
# System: Sengkuni
# Description: Linux Sengkuni 2.4.23 #1 SMP Wed Feb 18 12:40:43 WIT 2004 i686
# Contact: support <
support@dtp.net.id>
# Location: DTPNet Cyber Bld 5th Floor
###################################################################### # bppt
#Target[bppt]: .1.3.6.1.4.1.2021.337.101.2&.1.3.6.1.4.1.2021.337.101.1:
bridg3@202.78.192.164
Target[bppt]: .1.3.6.1.4.1.2021.337.101.1&.1.3.6.1.4.1.2021.337.101.2:bridg3@202.78.192.164
Options[bppt]: nopercent,growright, bits

Title[bppt]: IPTEKNET BPPT Panamsat
MaxBytes[bppt]: 1250000
LegendI[bppt]: Traffic in
LegendO[bppt]: Traffic out
PageTop[bppt]:

IPTEKNET BPPT Panamsat













System: Router in IDC - 7th Floor
Maintainer: support@dtp.net.id
Description:Traffic IPTEKNET PAS-2
ifType: FastEthernet
ifName:
Bandwidth: 2048 kbps Up - 6144 kbps Down
Bandwidth: 1256 Kbps up (blue) - 3840 Kbps down (green)

Tidak ada komentar:

Posting Komentar

Komentarnya mana

readbud - get paid to read and rate articles