Commit 45eb7164 authored by Valentin Samir's avatar Valentin Samir

[munin-plugins] Ajout d'un plugin pour ipset

parent 8385237c
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Compteur des règles iptables
import sys,commands,string
IPSET = "ipset -L "
try :
arg = sys.argv[1]
except :
arg = ''
CHAINS = commands.getoutput('%s | grep -- ^Name: | awk \'{print $2}\'' % IPSET).split('\n')
if arg == "config" :
print 'graph_title Ipset'
print 'graph_args --base 1000 --lower-limit 0'
print 'graph_category network'
print "graph_vlabel nb de regles"
for chain in CHAINS :
nom = string.lower(chain.replace('_', '').replace('-', '').replace('.','').replace('/', ''))
label = chain.replace('_', '-').replace('.','-').replace('/','-')
print "%s.label %s" % (nom, label)
if CHAINS.index(chain) == 0 :
print "%s.draw AREA" % nom
else :
print "%s.draw STACK" % nom
else :
for chain in CHAINS :
nom = string.lower(chain.replace('_', '').replace('-', '').replace('.','').replace('/', ''))
label = chain.replace('_', '-').replace('.','-').replace('/','-')
value = int(commands.getoutput('%s %s | wc -l' % (IPSET, chain))) - 6
print "%s.value %d" % (nom, value)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment