Page 1 of 1

Contribution : CSF & Munin

Posted: 21 Aug 2013, 17:10
by diegors
Hi!

I found for make a graph with fail2ban stats. Works fine [1]

Now, I addapt this for CSF, so, I am sharing with you

1 - Script

Save as you want

Code: Select all

#!/bin/bash

PROGNAME=csf
STATEDIR=/var/lib/munin/plugin-state

CHAINLIST=$(iptables -L -n |grep Chain|awk {'print $2'})

if [ "$1" = "config" ]
then
 echo 'system.type ABSOLUTE'
 echo 'graph_title CSF'
 echo 'graph_vlabel Number of ban'
 echo 'graph_category Security'
 for f  in $CHAINLIST; do
 echo "$f.label $f"
 done
 exit 0
fi

for f  in $CHAINLIST; do
 echo "$f.value $(iptables -L $f -n|egrep -v 'Chain|pkts'|wc -l)"
done
We should test if is working

Code: Select all

# bash csf_munin 
INPUT.value 45
FORWARD.value 2
OUTPUT.value 48
ALLOWIN.value 4
ALLOWOUT.value 4
DENYIN.value 202
DENYOUT.value 202
INVALID.value 12
INVDROP.value 3
LOCALINPUT.value 4
LOCALOUTPUT.value 4
LOGDROPIN.value 24
LOGDROPOUT.value 6
acctboth.value 45
OK.
Install :

Code: Select all

# cp csf_munin /usr/share/munin/plugins/csf
# chmod +x /usr/share/munin/plugins/csf
# ln /usr/share/munin/plugins/csf /etc/munin/plugins/csf
# echo '[csf]
user root' >>  /etc/munin/plugin-conf.d/munin-node
# service munin-node restart
Stopping Munin Node agents:                                [  OK  ]
Starting Munin Node:                                       [  OK  ]
Test again:

Code: Select all

telnet localhost 4949
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
# munin node at vps.lalalala.com
fetch csf
INPUT.value 44
FORWARD.value 1
OUTPUT.value 47
ALLOWIN.value 3
ALLOWOUT.value 3
DENYIN.value 201
DENYOUT.value 201
INVALID.value 11
INVDROP.value 2
LOCALINPUT.value 3
LOCALOUTPUT.value 3
LOGDROPIN.value 23
LOGDROPOUT.value 5
acctboth.value 44
.
quit
Connection closed by foreign host.

[1] - http://www.majorxtrem.be/2009/08/14/plu ... our-munin/

----

Edition 1 - 21/08/2013 - 16:56:

When I do the

# echo '[csf]
> user root' >> /etc/munin/plugin-conf.d/munin-node

It's fail because "> user root" is not a valid config :P
Removed ">" char

Re: Contribution : CSF & Munin

Posted: 21 Aug 2013, 17:12
by diegors
Yes.. You can send your improvements!

Re: Contribution : CSF & Munin

Posted: 05 Mar 2014, 17:19
by BBLN
Sad to see noone has replied to this topic yet. I have just loaded the plugin and it seems to work perfectly fine. Awesome job! Really a nice addition to my monitoring.

Re: Contribution : CSF & Munin

Posted: 15 Jan 2015, 14:31
by darkroast
Doesn't work for me... I can run the plugin from the command line, and it gives me stats, but there's no graph in Munin.