mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
remove plugins existing in main munin repository
This commit is contained in:
parent
ea6afd78e1
commit
e005bb0ccb
@ -1,168 +0,0 @@
|
||||
#!/usr/bin/perl -w
|
||||
# -*- perl -*-
|
||||
|
||||
=head1 NAME
|
||||
|
||||
asterix_sippeers - Plugin to monitor number of sip peers registered
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
The following configuration parameters are used by this plugin
|
||||
|
||||
[asterisk_sippeers]
|
||||
env.host - hostname to connect to
|
||||
env.port - port number to connect to
|
||||
env.username - username used for authentication
|
||||
env.secret - secret used for authentication
|
||||
|
||||
The "username" and "secret" parameters are mandatory, and have no
|
||||
defaults.
|
||||
|
||||
=head2 DEFAULT CONFIGURATION
|
||||
|
||||
[asterisk_sippeers]
|
||||
env.host 127.0.0.1
|
||||
env.port 5038
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
|
||||
Ported to Asterisk 1.6 by cerien.jean@gmail.com
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
Gnu GPLv2
|
||||
|
||||
=begin comment
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 dated June, 1991.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA.
|
||||
|
||||
If you improve this script please send your version to my email
|
||||
address with the copyright notice upgrade with your name.
|
||||
|
||||
=end comment
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=contrib
|
||||
|
||||
=cut
|
||||
|
||||
# #################################################################################
|
||||
# Following example from current asterisk 1.4
|
||||
#> sip show peers
|
||||
#Name/username Host Dyn Nat ACL Port Status
|
||||
#104-RANDALLBUILT/104-RAND 74.218.176.166 D 5060 Unmonitored
|
||||
#...
|
||||
#102-ROCKSOLID/102-ROCKSOL (Unspecified) D 0 Unmonitored
|
||||
#101-ROCKSOLID/101-ROCKSOL (Unspecified) D N 0 UNKNOWN
|
||||
#20 sip peers [Monitored: 0 online, 1 offline Unmonitored: 2 online, 17 offline]
|
||||
# #################################################################################
|
||||
|
||||
use strict;
|
||||
|
||||
my $ret = undef;
|
||||
if (! eval "require Net::Telnet;")
|
||||
{
|
||||
$ret = "Net::Telnet not found";
|
||||
}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "graph_title Asterisk sip peers\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_order mon moff umon umoff\n";
|
||||
print "graph_vlabel peers\n";
|
||||
print "graph_category asterisk\n";
|
||||
#print "peers.label total\n";
|
||||
print "mon.draw AREA\n";
|
||||
print "mon.label monitored online\n";
|
||||
print "moff.draw STACK\n";
|
||||
print "moff.label monitored offline\n";
|
||||
print "umon.draw STACK\n";
|
||||
print "umon.label unmonitored online\n";
|
||||
print "umoff.draw STACK\n";
|
||||
print "umoff.label unmonitored offline\n";
|
||||
#graph_scale no
|
||||
#load.warning 10
|
||||
#load.critical 120
|
||||
#graph_info The ... describes ....
|
||||
#load.info Average load for the five minutes.
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
|
||||
my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
|
||||
|
||||
my $username = $ENV{'username'};
|
||||
my $secret = $ENV{'secret'};
|
||||
|
||||
my $pop = new Net::Telnet (Telnetmode => 0);
|
||||
$pop->open(Host => $host,
|
||||
Port => $port);
|
||||
|
||||
## Read connection message.
|
||||
my $line = $pop->getline;
|
||||
die $line unless $line =~ /^Asterisk/;
|
||||
|
||||
## Send user name.
|
||||
$pop->print("Action: login");
|
||||
$pop->print("Username: $username");
|
||||
$pop->print("Secret: $secret");
|
||||
$pop->print("Events: off");
|
||||
$pop->print("");
|
||||
|
||||
#Response: Success
|
||||
#Message: Authentication accepted
|
||||
|
||||
## Request status of messages.
|
||||
$pop->print("Action: command");
|
||||
$pop->print("Command: sip show peers");
|
||||
$pop->print("");
|
||||
|
||||
my ($peers,$monitor_online,$monitor_offline,$unmonitor_online,$unmonitor_offline)=(0,0,0,0,0);
|
||||
|
||||
while (($line = $pop->getline) and ($line !~ /END COMMAND/o))
|
||||
{
|
||||
my @fields = split(' ', $line);
|
||||
my $count = @fields;
|
||||
#20 sip peers [Monitored: 0 online, 1 offline Unmonitored: 2 online, 17 offline]
|
||||
if (($count > 10) and ($fields[1] eq 'sip' and $fields[2] eq 'peers')) {
|
||||
$peers = $fields[0];
|
||||
$monitor_online = $fields[4];
|
||||
$monitor_offline = $fields[6];
|
||||
$unmonitor_online = $fields[9];
|
||||
$unmonitor_offline = $fields[11];
|
||||
#print STDERR "$peers $monitor_online $monitor_offline $unmonitor_online $unmonitor_offline\n";
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$pop->print("Action: logoff");
|
||||
$pop->print("");
|
||||
|
||||
# purge the last lines to avoid error message on CLI
|
||||
while ($line = $pop->getline)
|
||||
{
|
||||
# print STDERR " $line \n";
|
||||
}
|
||||
#print "peers.value $peers\n";
|
||||
print "mon.value $monitor_online\n";
|
||||
print "moff.value $monitor_offline\n";
|
||||
print "umon.value $unmonitor_online\n";
|
||||
print "umoff.value $unmonitor_offline\n";
|
||||
|
||||
# vim:syntax=perl
|
@ -1,293 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Munin plugin for ejabberd2.
|
||||
# This script supports versions 2.0 and 2.1 of ejabberd.
|
||||
#
|
||||
# Written by Lasse Karstensen <lkarsten@hyse.org> 2007-05-27.
|
||||
# Based on ejabberd-plugin by Christian Dröge <Christian@draugr.de>
|
||||
#
|
||||
# Status, memory, threads, ejabberd2 and other code optimalisation
|
||||
# by Peter Viskup <skupko.sk@gmail.com>
|
||||
#
|
||||
# As connected users, registered users and server-connections have somewhat
|
||||
# different scales, this plugin uses munins suggest feature to create three
|
||||
# different graphs.
|
||||
#
|
||||
# ejabberd_connections
|
||||
# ejabberd_users
|
||||
# ejabberd_registrations
|
||||
# ejabberd_statuses
|
||||
# ejabberd_memory
|
||||
# ejabberd_threads
|
||||
# ejabberd_usersindays
|
||||
# ejabberd_uptime
|
||||
#
|
||||
# use ln -s ejabberd ejabberd_(connections|users|registrations|statuses|memory|threads|usersindays|uptime)
|
||||
# to activate.
|
||||
#
|
||||
# If the autodetect-feature for vhosts breaks, you can set
|
||||
# """
|
||||
# [ejabberd*]
|
||||
# env.vhosts foo.com bar.com
|
||||
# env.statuses available away chat xa # monitoring of statuses
|
||||
# env.days 1 7 30 # monitoring for usersindays
|
||||
# user ejabberd # user ejabberd should have enough priviledges
|
||||
# # depends on your setup
|
||||
# """
|
||||
# in plugin-conf.d/munin-node to override it.
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
EJCTL=$(which ejabberdctl)
|
||||
EJVER=$($EJCTL status | awk '/^ejabberd / {print $2}')
|
||||
|
||||
if [ "$1" == "autoconf" ]; then
|
||||
if [ -x $EJCTL > /dev/null ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
echo "no (ejabberdctl not found)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" == "suggest" ]; then
|
||||
echo "connections"
|
||||
echo "users"
|
||||
echo "registrations"
|
||||
echo "statuses"
|
||||
echo "memory"
|
||||
echo "threads"
|
||||
echo "usersindays"
|
||||
echo "uptime"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Add munin argument to ejabberdctl to prevent a lot of ejabberdctl
|
||||
# records in memory see discussion:
|
||||
# http://lists.jabber.ru/pipermail/ejabberd/2009-September/005337.html
|
||||
# Add these lines to ejabberdctl script to get it work
|
||||
#@@ -56,6 +56,15 @@
|
||||
# $KERNEL_OPTS \
|
||||
# "$@"
|
||||
# ;;
|
||||
#+ munin)
|
||||
#+ shift
|
||||
#+ exec $ERL $SNAME ejabberdctlmunin \
|
||||
#+ -pa $EBIN_DIR \
|
||||
#+ -s ejabberd_ctl \
|
||||
#+ -noinput \
|
||||
#+ $KERNEL_OPTS \
|
||||
#+ -extra $ERLANG_NODE "$@"
|
||||
#+ ;;
|
||||
# *)
|
||||
# exec $ERL $SNAME ejabberdctl$SUFFIX \
|
||||
# -pa $EBIN_DIR \
|
||||
#
|
||||
# Or just comment out following line
|
||||
EJCTL="$EJCTL munin"
|
||||
|
||||
# trying to autodetect running vhosts.
|
||||
if [ -z "$vhosts" ]; then
|
||||
for CFGPATH in /etc/ejabberd /usr/local/ejabberd/etc; do
|
||||
if [ -f "$CFGPATH/ejabberd.cfg" ]; then
|
||||
EJCFG=$CFGPATH/ejabberd.cfg
|
||||
fi
|
||||
done
|
||||
if [ -z "$EJCFG" ]; then
|
||||
echo "Unable to find ejabberd.cfg. Exiting." > /dev/stderr
|
||||
exit -1
|
||||
fi
|
||||
# you have to have all of vhosts defined on one line in $EJCFG or in plugins-conf.d/munin-node config file
|
||||
vhosts=$(awk '/^\s*{hosts/ {gsub( /\{\s?hosts\s?,|[\",\[\]]|\}\s?.|localhost/ ,""); print;}' $EJCFG)
|
||||
fi
|
||||
|
||||
# get ejabberd PID
|
||||
if [[ ${EJVER%\.+([0-9]|[0-9][0-9])} == 2.1 ]]; then
|
||||
EJPID=$(cat /var/run/ejabberd/ejabberd.pid)
|
||||
else
|
||||
EJPID=$(ps -ef | awk '/\/bin\/beam.smp/ && !/awk/ {print $2}')
|
||||
fi
|
||||
|
||||
if [ -z "$vhosts" ]; then
|
||||
echo "No vhosts to sample." > /dev/stderr
|
||||
echo "Please set env.vhosts in plugins-conf.d/munin-node." > /dev/stderr
|
||||
exit -1
|
||||
fi
|
||||
|
||||
MODE=$(basename $0 | sed 's/^ejabberd_//g')
|
||||
|
||||
if ! [ "$MODE" == "connections" -o "$MODE" == "users" \
|
||||
-o "$MODE" == "registrations" -o "$MODE" == "statuses" \
|
||||
-o "$MODE" == "memory" -o "$MODE" == "threads" \
|
||||
-o "$MODE" == "usersindays" -o "$MODE" == "uptime" ]; then
|
||||
echo "ERROR: Unknown mode \"$MODE\". Exiting." > /dev/stderr
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_category ejabberd'
|
||||
echo 'graph_info This graph shows statistics of ejabberd server'
|
||||
if [ "$MODE" == "memory" ]; then
|
||||
echo 'graph_args --base 1024 -l 0'
|
||||
echo 'graph_scale yes'
|
||||
echo 'graph_title Memory usage'
|
||||
echo 'graph_vlabel Bytes'
|
||||
echo "ejabberd_memory_size.label actual memory"
|
||||
echo "ejabberd_memory_size.info Memory used by ejabberd process in Bytes"
|
||||
echo "ejabberd_memory_peak.label memory peak"
|
||||
echo "ejabberd_memory_peak.info Memory peak of ejabberd process in Bytes"
|
||||
else
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_scale no'
|
||||
if [ "$MODE" == "connections" ]; then
|
||||
echo 'graph_title Server-to-server conections'
|
||||
echo 'graph_vlabel connections'
|
||||
echo 's2s_connections_out.label outgoing s2s connections'
|
||||
echo 's2s_connections_out.info Number of outgoing server to server connections'
|
||||
echo 's2s_connections_in.label incoming s2s connections'
|
||||
echo 's2s_connections_in.info Number of incoming server to server connections'
|
||||
elif [ "$MODE" == "users" ]; then
|
||||
echo 'graph_title Connected users'
|
||||
echo 'graph_vlabel users'
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "connected_users_$formathost.label $host connected users"
|
||||
echo "connected_unique_users_$formathost.label $host unique connected users"
|
||||
done
|
||||
elif [ "$MODE" == "registrations" ]; then
|
||||
echo 'graph_title User registrations'
|
||||
echo 'graph_vlabel users'
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "registered_$formathost.label $host registered users"
|
||||
echo "registered_$formathost.info Registered users for vhost $host"
|
||||
done
|
||||
elif [ "$MODE" == "statuses" ]; then
|
||||
echo 'graph_title User statuses'
|
||||
echo 'graph_vlabel users'
|
||||
for host in $vhosts; do
|
||||
for status in $statuses; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "status_${formathost}_${status}.label $status on $host"
|
||||
echo "status_${formathost}_${status}.info Users with status $status on $host [xa=not available, dnd=(do not disturb) or (busy), chat=free for chat]"
|
||||
done
|
||||
done
|
||||
elif [ "$MODE" == "threads" ]; then
|
||||
echo 'graph_title Threads'
|
||||
echo 'graph_vlabel threads'
|
||||
echo "ejabberd_threads.label number of threads"
|
||||
echo "ejabberd_threads.info Number of threads of ejabberd process"
|
||||
elif [ "$MODE" == "usersindays" ]; then
|
||||
echo 'graph_title Active users'
|
||||
echo 'graph_vlabel users'
|
||||
for host in $vhosts; do
|
||||
for num in $days; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "usersindays_${formathost}_${num}.label $host active users [$num days]"
|
||||
echo "usersindays_${formathost}_${num}.info Number of $host users active in last $num days"
|
||||
done
|
||||
done
|
||||
elif [ "$MODE" == "uptime" ]; then
|
||||
echo 'graph_title Uptime'
|
||||
echo 'graph_vlabel days'
|
||||
echo "uptime.label uptime"
|
||||
echo 'uptime.draw AREA'
|
||||
fi
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ${EJVER%\.+([0-9]|[0-9][0-9])} == 2.1 ]]; then
|
||||
if [ "$MODE" == "users" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "connected_users_$formathost.value $($EJCTL stats_host onlineusers $host)"
|
||||
echo "connected_unique_users_$formathost.value $($EJCTL connected_users_vhost $host | awk -v var=$host -F/ '{users[$1]} END {for (user in users) {if (index(user,var)) {count++}} print count}')"
|
||||
done
|
||||
elif [ "$MODE" == "registrations" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
num=$($EJCTL stats_host registeredusers $host)
|
||||
if [ "$?" != 0 ]; then
|
||||
num="U"
|
||||
fi
|
||||
echo "registered_$formathost.value $num"
|
||||
done
|
||||
elif [ "$MODE" == "statuses" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
for status in $statuses; do
|
||||
num=$($EJCTL status_num_host $host $status)
|
||||
if [ "$?" != 0 ]; then
|
||||
num="U"
|
||||
fi
|
||||
echo "status_${formathost}_${status}.value $num"
|
||||
done
|
||||
done
|
||||
elif [ "$MODE" == "usersindays" ]; then
|
||||
for host in $vhosts; do
|
||||
for num in $days; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "usersindays_${formathost}_${num}.value $($EJCTL num_active_users $host $num)"
|
||||
done
|
||||
done
|
||||
elif [ "$MODE" == "uptime" ]; then
|
||||
echo "uptime.value $($EJCTL stats uptimeseconds | awk '{printf "%.2f", $1/86400}')"
|
||||
elif [ "$MODE" == "connections" ]; then
|
||||
echo "s2s_connections_out.value $($EJCTL outgoing_s2s_number)"
|
||||
echo "s2s_connections_in.value $($EJCTL incoming_s2s_number)"
|
||||
fi
|
||||
elif [[ ${EJVER%\.+([0-9]|[0-9][0-9])} == 2.0 ]]; then
|
||||
if [ "$MODE" == "users" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "connected_users_$formathost.value $($EJCTL vhost $host stats onlineusers)"
|
||||
echo "connected_unique_users_$formathost.value $($EJCTL connected-users | awk -v var=$host -F/ '{users[$1]} END {for (user in users) {if (index(user,var)) {count++}} print count}')"
|
||||
done
|
||||
elif [ "$MODE" == "registrations" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
num=$($EJCTL vhost $host stats registeredusers)
|
||||
if [ "$?" != 0 ]; then
|
||||
num="U"
|
||||
fi
|
||||
echo "registered_$formathost.value $num"
|
||||
done
|
||||
elif [ "$MODE" == "statuses" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
for status in $statuses; do
|
||||
num=$($EJCTL vhost $host status-num $status)
|
||||
if [ "$?" != 0 ]; then
|
||||
num="U"
|
||||
fi
|
||||
echo "status_${formathost}_${status}.value $num"
|
||||
done
|
||||
done
|
||||
elif [ "$MODE" == "usersindays" ]; then
|
||||
for host in $vhosts; do
|
||||
for num in $days; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "usersindays_${formathost}_${num}.value $($EJCTL vhost $host num-active-users $num)"
|
||||
done
|
||||
done
|
||||
elif [ "$MODE" == "uptime" ]; then
|
||||
echo "uptime.value $($EJCTL stats uptime-seconds | awk '{printf "%.2f", $1/86400}')"
|
||||
elif [ "$MODE" == "connections" ]; then
|
||||
echo "s2s_connections_out.value $($EJCTL outgoing-s2s-number)"
|
||||
echo "s2s_connections_in.value $($EJCTL incoming-s2s-number)"
|
||||
fi
|
||||
else
|
||||
echo "# Unknown Ejabberd Version: $EJVER -> '${EJVER%\.+([0-9]|[0-9][0-9])}'"
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "memory" ]; then
|
||||
echo "ejabberd_memory_size.value $(awk '/VmSize/ {print $2*1024}' /proc/${EJPID}/status)"
|
||||
echo "ejabberd_memory_peak.value $(awk '/VmPeak/ {print $2*1024}' /proc/${EJPID}/status)"
|
||||
elif [ "$MODE" == "threads" ]; then
|
||||
echo "ejabberd_threads.value $(awk '/Threads/ {print $2}' /proc/${EJPID}/status)"
|
||||
fi
|
||||
exit 0
|
@ -1,91 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Plugin to monitor fail2ban blacklists.
|
||||
# Parses iptables output. Must be run as a user that may do such. Probably root.
|
||||
#
|
||||
# Requires: python, probably 2.3 or so :)
|
||||
#
|
||||
# Written by Lasse Karstensen <lasse.karstensen@gmail.com> September 2007.
|
||||
# Parameters understood:
|
||||
# config (required)
|
||||
# autoconf (optional)
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
libdir="/usr/share/fail2ban"
|
||||
iptablesbin="/sbin/iptables"
|
||||
|
||||
import sys, os, ConfigParser
|
||||
|
||||
|
||||
def get_fail2ban_checks(configfile="/etc/fail2ban.conf"):
|
||||
confReader = ConfigParser.ConfigParser()
|
||||
confReader.read(configfile)
|
||||
res = []
|
||||
for section in confReader.sections():
|
||||
# basic configuration, not essential for us so we skip it.
|
||||
if section in ["MAIL"]:
|
||||
continue
|
||||
if confReader.has_option(section, "enabled"):
|
||||
val = confReader.get(section, "enabled")
|
||||
if val.lower() == "true":
|
||||
res.append(section)
|
||||
return res
|
||||
|
||||
def list_iptables(chain):
|
||||
global iptablesbin
|
||||
cmd = "%s -n -L fail2ban-%s" % (iptablesbin, chain)
|
||||
num = 0
|
||||
for line in os.popen(cmd):
|
||||
line = line.strip()
|
||||
if line.split()[0] == "DROP":
|
||||
num = num + 1
|
||||
return num
|
||||
|
||||
def print_config():
|
||||
# noisy
|
||||
print 'graph_title Fail2ban blacklist'
|
||||
print 'graph_info This graph shows the number of host blocked by fail2ban.'
|
||||
print 'graph_category network'
|
||||
print 'graph_vlabel Count'
|
||||
|
||||
print 'graph_args --base 1000 -l 0'
|
||||
print 'graph_total total'
|
||||
|
||||
for checkname in get_fail2ban_checks():
|
||||
checkname_sane = checkname_sanitize(checkname)
|
||||
print '%s.label Rules in chain %s' % (checkname_sane, checkname_sane)
|
||||
print '%s.min 0' % checkname_sane
|
||||
|
||||
def checkname_sanitize(name):
|
||||
new = ""
|
||||
from string import digits, letters
|
||||
for char in name:
|
||||
if char not in letters+digits:
|
||||
new += "_"
|
||||
else:
|
||||
new += char
|
||||
return new
|
||||
|
||||
def main():
|
||||
if len(sys.argv) > 1 and sys.argv[1] == "autoconf":
|
||||
if os.path.isdir(libdir):
|
||||
print "yes"
|
||||
sys.exit(0)
|
||||
else:
|
||||
print "no"
|
||||
sys.exit(1)
|
||||
|
||||
sys.path.append(libdir)
|
||||
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
||||
print_config()
|
||||
sys.exit(0)
|
||||
|
||||
for checkname in get_fail2ban_checks():
|
||||
num = list_iptables(checkname)
|
||||
print "%s.value %s" % (checkname_sanitize(checkname), num)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,40 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Wildcard-plugin to monitor bans on Fail2ban jails. To monitor an jail, link
|
||||
# fail2ban_<jail> to this file. E.g.
|
||||
|
||||
# ln -s /usr/share/node/node/plugins-auto/fail2ban_
|
||||
# /etc/munin/node.d/fail2ban_ssh-iptables
|
||||
|
||||
# Magic markers (optional - used by munin-config and some installation
|
||||
# scripts):
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
JAIL=${0##*/fail2ban_}
|
||||
|
||||
case $1 in
|
||||
autoconf)
|
||||
if [ -x $(which fail2ban-client) ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
config)
|
||||
echo "graph_title Fail2ban - $JAIL"
|
||||
echo 'graph_vlabel active bans'
|
||||
echo 'graph_category network'
|
||||
echo 'graph_info This graph shows the amount of bans caught by Fail2ban'
|
||||
echo "fail2ban.label $JAIL"
|
||||
echo 'fail2ban.type GAUGE'
|
||||
echo 'fail2ban.info The number of current bans.'
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -n "fail2ban.value "
|
||||
$(which fail2ban-client) status $JAIL|awk '/Currently banned:/ { print $NF }'
|
@ -1,57 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# munin plugin to monitor bans on Fail2ban jails
|
||||
#
|
||||
# Origional Author: Thomas Leveil
|
||||
# Contributors: none
|
||||
# Version: 1.1
|
||||
#
|
||||
###############################################
|
||||
# You have to specify a different user in the munin-node config file as follow:
|
||||
#
|
||||
# [fail2ban_all_jails]
|
||||
# user root
|
||||
###############################################
|
||||
#
|
||||
# HISTORY
|
||||
# v1.1 : better autoconf
|
||||
#
|
||||
#%# family=contrib
|
||||
#%# capabilities=autoconf
|
||||
|
||||
|
||||
case $1 in
|
||||
autoconf)
|
||||
if [ -z $(which fail2ban-client) ]; then
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
if [ $(whoami) != "root" ]; then
|
||||
echo "no (fail2ban-client found but must run as root)"
|
||||
exit 1
|
||||
fi
|
||||
if [ -x $(which fail2ban-client) ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (fail2ban-client found but not executable)"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
config)
|
||||
echo "graph_title Fail2ban"
|
||||
echo 'graph_vlabel active bans'
|
||||
echo 'graph_category Network'
|
||||
echo 'graph_info number of jailled ip'
|
||||
echo 'graph_info This graph shows the amount of bans caught by Fail2ban'
|
||||
$(which fail2ban-client) status | awk '/Jail list:/ { for (i=4; i<=NF; i++) { sub(/,$/,"",$i); jail=$i; sub(/-/,"_",$i); print "fail2ban_"$i".label "jail } }'
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
$(which fail2ban-client) status | awk '/Jail list:/ { for (i=4; i<=NF; i++) { sub(/,$/,"",$i); print $i } }' | \
|
||||
while read JAIL; do
|
||||
echo -n "fail2ban_${JAIL//-/_}.value "
|
||||
$(which fail2ban-client) status $JAIL | awk '/Currently banned:/ { print $NF }'
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user