[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [hobbit] Graphing number of references to iptables chain
- To: hobbit (at) hswn.dk
- Subject: Re: [hobbit] Graphing number of references to iptables chain
- From: Iain Conochie <iain (at) shihad.org>
- Date: Wed, 05 Sep 2007 10:30:29 +0100
- References: <46DE4085.5010400 (at) zandahar.net> <20070905055836.GA13645 (at) hswn.dk> <46DE7128.2040509 (at) shihad.org> <971b43ce0709050218t8fe2550w1625981d87037274 (at) mail.gmail.com>
- User-agent: Thunderbird 1.5.0.12 (X11/20070509)
<snip>
Here you go. This must bu run as root so either Set UID root (bad!) or
use sudo
#!/bin/sh
SUDO=/usr/bin/sudo
IPTABLES=/usr/sbin/iptables
CHAINS="INPUT OUTPUT FORWARD"
#BBTMP=/tmp
TOUCH=/bin/touch
$TOUCH $BBTMP/packets.$$
$TOUCH $BBTMP/bytes.$$
for i in $CHAINS
do sudo $IPTABLES -L -n -v -x| grep ^"Chain $i"| awk {'print $2 " "
$6 " : " $5'}| sed s/packets,/packets/g >> $BBTMP/packets.$$
done
for i in $CHAINS
do sudo $IPTABLES -L -n -v -x| grep ^"Chain $i"| awk {'print $2 " "
$8 " : " $7'}| sed s/bytes\)/bytes/g >> $BBTMP/bytes.$$
done
echo " " >> $BBTMP/packets.$$
echo " " >> $BBTMP/bytes.$$
$BB $BBDISP "status $MACHINE.iptables green `date` IPtables output
`cat $BBTMP/packets.$$; echo; cat $BBTMP/bytes.$$`"
rm $BBTMP/packets.$$
rm $BBTMP/bytes.$$
And here is the entry for hobbitgraph.cfg
[iptables]
TITLE IP-Tables
YAXIS Bytes
DEF:Input=iptables.rrd:INPUTbytes:AVERAGE
DEF:Output=iptables.rrd:OUTPUTbytes:AVERAGE
DEF:Forward=iptables.rrd:FORWARDbytes:AVERAGE
LINE2:Input#0000FF:Input Bytes
LINE2:Output#00FF00:Output Bytes
LINE2:Forward#FF0000:Forward Bytes
COMMENT:\n
GPRINT:Input:LAST:Input \: %5.1lf%s (cur)
GPRINT:Input:MAX: \: %5.1lf%s (max)
GPRINT:Input:MIN: \: %5.1lf%s (min)
GPRINT:Input:AVERAGE: \: %5.1lf%s (avg)\n
GPRINT:Output:LAST:Output \: %5.1lf%s (cur)
GPRINT:Output:MAX: \: %5.1lf%s (max)
GPRINT:Output:MIN: \: %5.1lf%s (min)
GPRINT:Output:AVERAGE: \: %5.1lf%s (avg)\n
GPRINT:Forward:LAST:Forward \: %5.1lf%s (cur)
GPRINT:Forward:MAX: \: %5.1lf%s (max)
GPRINT:Forward:MIN: \: %5.1lf%s (min)
GPRINT:Forward:AVERAGE: \: %5.1lf%s (avg)\n
Cheers
Iain