<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Munin plugin for Shorewall accounting</title>
	<atom:link href="http://atlee.ca/blog/2006/01/20/munin-shorewall/feed/" rel="self" type="application/rss+xml" />
	<link>http://atlee.ca/blog/2006/01/20/munin-shorewall/</link>
	<description>programming, photography, media, and anything else that strikes my fancy</description>
	<lastBuildDate>Wed, 30 Jun 2010 13:38:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: monitoring-traffic-with-munin-and-shorewall</title>
		<link>http://atlee.ca/blog/2006/01/20/munin-shorewall/comment-page-1/#comment-50910</link>
		<dc:creator>monitoring-traffic-with-munin-and-shorewall</dc:creator>
		<pubDate>Sun, 05 Apr 2009 15:32:45 +0000</pubDate>
		<guid isPermaLink="false">http://atlee.ca/blog/2006/01/18/munin-shorewall/#comment-50910</guid>
		<description>[...] copied the code from the website and fixed up all quote characters and other html issues, saved it to [...]</description>
		<content:encoded><![CDATA[<p>[...] copied the code from the website and fixed up all quote characters and other html issues, saved it to [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taeram</title>
		<link>http://atlee.ca/blog/2006/01/20/munin-shorewall/comment-page-1/#comment-48912</link>
		<dc:creator>Taeram</dc:creator>
		<pubDate>Mon, 09 Feb 2009 19:24:21 +0000</pubDate>
		<guid isPermaLink="false">http://atlee.ca/blog/2006/01/18/munin-shorewall/#comment-48912</guid>
		<description>Absolutely beautiful solution! It&#039;s exactly what I was looking for. Thanks!</description>
		<content:encoded><![CDATA[<p>Absolutely beautiful solution! It&#8217;s exactly what I was looking for. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Epsylon3</title>
		<link>http://atlee.ca/blog/2006/01/20/munin-shorewall/comment-page-1/#comment-43076</link>
		<dc:creator>Epsylon3</dc:creator>
		<pubDate>Sat, 30 Aug 2008 18:03:29 +0000</pubDate>
		<guid isPermaLink="false">http://atlee.ca/blog/2006/01/18/munin-shorewall/#comment-43076</guid>
		<description>[code]
#!/usr/bin/python
# shorewall_accounting
# A munin plugin for tracking traffic as recorded by shorewall accounting rules
# Written by Chris AtLee 
# Released under the GPL v2
import sys, commands, re
accountingLineExp = re.compile(r&quot;^\s*\d+[KMG]*\s+(\d+)([KMGT]*)\s+(\w+).*$&quot;)
 
def getBytesByChain():
    trafficCmd = &quot;shorewall&quot;
    status, output = commands.getstatusoutput(&quot;/sbin/shorewall show accounting 2&gt;/dev/null&quot;)
    if status != 0:
        raise OSError(&quot;Error running command (%s)[%i]: %s&quot; % (trafficCmd, status, output))
    chains = {}
    for line in output.split(&quot;\n&quot;):
        m = accountingLineExp.match(line)
        if m is not None:
            target = m.group(3)
            bytes = int(m.group(1))

	    if m.group(2) == &quot;K&quot;:
	    	bytes *= 1024
            elif m.group(2) == &quot;M&quot;:
		bytes *= 1024 * 1024
	    elif m.group(2) == &quot;G&quot;:
		bytes *= 1024 * 1024 * 1024
	    elif m.group(2) == &quot;T&quot;:
		bytes *= 1024 * 1024 * 1024 * 1024

            if target in chains:
                chains[target] += bytes
            else:
                chains[target] = bytes
#	else:
#	    print &quot;IGNORED LINE %s&quot; % ( line)

    retval = []
    chainNames = chains.keys()
    chainNames.sort()
    for name in chainNames:
        retval.append((name, chains[name]))
    return retval
 
if len(sys.argv) &gt; 1:
    if sys.argv[1] == &quot;autoconf&quot;:
        print &quot;yes&quot;
        sys.exit(0)
    elif sys.argv[1] == &quot;config&quot;:
        print &quot;graph_title Shorewall accounting&quot;
        print &quot;graph_category network&quot;
        print &quot;graph_vlabel bits per ${graph_period}&quot;
        for chain,bytes in getBytesByChain():
            print &quot;%s.min 0&quot; % chain
            print &quot;%s.type DERIVE&quot; % chain
            print &quot;%s.label %s&quot; % (chain, chain)
            print &quot;%s.cdef %s,8,*&quot; % (chain, chain)
        sys.exit(0)
 
for chain, bytes in getBytesByChain():
    print &quot;%s.value %i&quot; % (chain, bytes)

[/code]</description>
		<content:encoded><![CDATA[<p>[code]<br />
#!/usr/bin/python<br />
# shorewall_accounting<br />
# A munin plugin for tracking traffic as recorded by shorewall accounting rules<br />
# Written by Chris AtLee<br />
# Released under the GPL v2<br />
import sys, commands, re<br />
accountingLineExp = re.compile(r"^\s*\d+[KMG]*\s+(\d+)([KMGT]*)\s+(\w+).*$")</p>
<p>def getBytesByChain():<br />
    trafficCmd = "shorewall"<br />
    status, output = commands.getstatusoutput("/sbin/shorewall show accounting 2&gt;/dev/null")<br />
    if status != 0:<br />
        raise OSError("Error running command (%s)[%i]: %s" % (trafficCmd, status, output))<br />
    chains = {}<br />
    for line in output.split("\n"):<br />
        m = accountingLineExp.match(line)<br />
        if m is not None:<br />
            target = m.group(3)<br />
            bytes = int(m.group(1))</p>
<p>	    if m.group(2) == "K":<br />
	    	bytes *= 1024<br />
            elif m.group(2) == "M":<br />
		bytes *= 1024 * 1024<br />
	    elif m.group(2) == "G":<br />
		bytes *= 1024 * 1024 * 1024<br />
	    elif m.group(2) == "T":<br />
		bytes *= 1024 * 1024 * 1024 * 1024</p>
<p>            if target in chains:<br />
                chains[target] += bytes<br />
            else:<br />
                chains[target] = bytes<br />
#	else:<br />
#	    print "IGNORED LINE %s" % ( line)</p>
<p>    retval = []<br />
    chainNames = chains.keys()<br />
    chainNames.sort()<br />
    for name in chainNames:<br />
        retval.append((name, chains[name]))<br />
    return retval</p>
<p>if len(sys.argv) &gt; 1:<br />
    if sys.argv[1] == "autoconf":<br />
        print "yes"<br />
        sys.exit(0)<br />
    elif sys.argv[1] == "config":<br />
        print "graph_title Shorewall accounting"<br />
        print "graph_category network"<br />
        print "graph_vlabel bits per ${graph_period}"<br />
        for chain,bytes in getBytesByChain():<br />
            print "%s.min 0" % chain<br />
            print "%s.type DERIVE" % chain<br />
            print "%s.label %s" % (chain, chain)<br />
            print "%s.cdef %s,8,*" % (chain, chain)<br />
        sys.exit(0)</p>
<p>for chain, bytes in getBytesByChain():<br />
    print "%s.value %i" % (chain, bytes)</p>
<p>[/code]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chris</title>
		<link>http://atlee.ca/blog/2006/01/20/munin-shorewall/comment-page-1/#comment-1065</link>
		<dc:creator>chris</dc:creator>
		<pubDate>Thu, 26 Jan 2006 20:58:37 +0000</pubDate>
		<guid isPermaLink="false">http://atlee.ca/blog/2006/01/18/munin-shorewall/#comment-1065</guid>
		<description>Wah!

Stupid web hosting changed the permissions on all my files.  Should be ok now :)</description>
		<content:encoded><![CDATA[<p>Wah!</p>
<p>Stupid web hosting changed the permissions on all my files.  Should be ok now <img src='http://atlee.ca/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Travis</title>
		<link>http://atlee.ca/blog/2006/01/20/munin-shorewall/comment-page-1/#comment-1064</link>
		<dc:creator>Travis</dc:creator>
		<pubDate>Thu, 26 Jan 2006 18:56:36 +0000</pubDate>
		<guid isPermaLink="false">http://atlee.ca/blog/2006/01/18/munin-shorewall/#comment-1064</guid>
		<description>Bah!  I finally remember to go grab my moustache pic from the Christmas dinner so that I include in as a historical artifact and your gallery isn&#039;t working.  What kind of techhead are you?</description>
		<content:encoded><![CDATA[<p>Bah!  I finally remember to go grab my moustache pic from the Christmas dinner so that I include in as a historical artifact and your gallery isn&#8217;t working.  What kind of techhead are you?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
