Ki akartam próbálni a munin fail2ban pluginjét. De nem akar működni.
A rendszer egy debian lenny.
Letöltöttem három különböző verziót:
http://exchange.munin-monitoring.org/plugins/search?keyword=fail2ban
betettem a helyére, megcsináltam a symlinket, beállítottam a jogosultságokat, és beírtam a
/etc/munin/plugin-conf.d/munin-node
[fail2ban*]
user root
vagy:
[fail2ban_all_jails]
user root
majd újraindítottam a munin-t,ami legenerálja a html-t, de nem teszi mellé a képeket. Így a grafikon nem jelenik meg.
# munin-run fail2ban
# munin-run fail2ban config
graph_title Fail2ban blacklist
graph_info This graph shows the number of host blocked by fail2ban.
graph_category network
graph_vlabel Count
graph_args --base 1000 -l 0
graph_total total
# munin-run --debug fail2ban config
# Saving mysql*->env->mysqlopts = --defaults-extra-file=/etc/mysql/debian.cnf...
# Saving postfix_mailvolume->env->logfile = mail.log...
# file: 'fail2ban'
# Checking fail2ban*...
# Checking fail2ban*...
# Checking fail2ban*...
# Checking fail2ban*...
# Want to run as euid/egid 0/113
# Running as uid/gid/euid/egid 0/113 113/0/113 113
# DEBUG: About to exec "/etc/munin/plugins/fail2ban"
graph_title Fail2ban blacklist
graph_info This graph shows the number of host blocked by fail2ban.
graph_category network
graph_vlabel Count
graph_args --base 1000 -l 0
graph_total total
Mért nem készülnek el a képek?
- 2341 megtekintés
Hozzászólások
tapasztalatom szerint a muninnak 2-3 alkalommal le kell futnia ahhoz, hogy legyen grafikon meg rajta adat...
meg nem árt, ha van banned ip is:)
- A hozzászóláshoz be kell jelentkezni
Erre én is gondoltam, ezeken túl vagyok.
- A hozzászóláshoz be kell jelentkezni
gondolom, amikor a konfigba beleírtad, hogy rootként fusson, a munin-node-ot nem felejtetted el újraindítani.
- A hozzászóláshoz be kell jelentkezni
Így van, lásd feljebb...
- A hozzászóláshoz be kell jelentkezni
feljebb ez van: "majd újraindítottam a munin-t,ami legenerálja a html-t,": nekem ez nem értelmezhető.
azt a munint, ami html-t generál, nem kell újraindítani, azt kell újraindítani, ami az adatokat szolgáltatja.
- A hozzászóláshoz be kell jelentkezni
Pontatlanul fogalmaztam ezek szerint.
# invoke-rc.d munin-node restart
Stopping Munin-Node: done.
Starting Munin-Node: done.
vagy:
# /etc/init.d/munin-node restart
Stopping Munin-Node: done.
Starting Munin-Node: done.
közben lefuttattam egy ilyet:
./munin-graph --debug --stdout --force-root | less
semmi hibára utalót nem találtam benne, a fail2ban-nál annyi volt a gyanús, hogy a commentnél azt írja:
"COMMENT:Last update\: Thu Jan 1 01\:00\:00 1970\r"
Lehet, hogy nem látja az eseményeket és ezért nem is frissíti a grafikont?
- A hozzászóláshoz be kell jelentkezni
Erre a parancsra sem generálja le a képeket:
munin-graph --force --nolazy
- A hozzászóláshoz be kell jelentkezni
Nálam sem készített graph-ot, majd belőttem ezt a fail2ban scriptet.
Eddig ugyan az volt a kimenetem mint neked, de most:
# munin-run --debug fail2ban config
# Processing plugin configuration from /etc/munin/plugin-conf.d/munin-node
# Set /rgid/ruid/egid/euid/ to /110/65534/110 110 /65534/
# Setting up environment
# About to run '/etc/munin/plugins/fail2ban config'
Can't exec "/etc/munin/plugins/fail2ban": Nincs ilyen fájl vagy könyvtár at /usr/share/perl5/Munin/Node/Service.pm line 215.
# FATAL: Failed to exec.
/usr/share/perl5/Munin/Node/Service.pm 179-216 sor:
sub exec_service {
my ($class, $dir, $service, $arg) = @_;
$class->change_real_and_effective_user_and_group($service);
unless (Munin::Node::OS->check_perms_if_paranoid("$dir/$service")) {
logger ("Error: unsafe permissions on $service. Bailing out.");
exit 2;
}
$class->export_service_environment($service);
Munin::Node::OS::set_plugin_umask();
my @command = grep defined, _service_command($dir, $service, $arg);
print STDERR "# About to run '", join (' ', @command), "'\n"
if $config->{DEBUG};
exec @command;
}
$ ll /usr/share/munin/plugins/fail2ban
-rwxr-xr-x 1 root root 2,9K júl 13 23.17 /usr/share/munin/plugins/fail2ban
$ ll /etc/munin/plugins/fail2ban
lrwxrwxrwx 1 root root 33 júl 13 18.27 /etc/munin/plugins/fail2ban -> /usr/share/munin/plugins/fail2ban
$ ll /usr/share/perl5/Munin/Node/Service.pm
-rw-r--r-- 1 root root 9,0K 2010 okt 5 /usr/share/perl5/Munin/Node/Service.pm
Szal így most totál nem megy. Valakinek valami ötlet? Esetleg valakinek van működő munin fail2ban scriptje?
- A hozzászóláshoz be kell jelentkezni
Szia.
Nálunk ezek mennek:
Az összes szabályt egy grafikonon jeleníti meg: http://pastebin.com/vuBM22Uc
Csak a linknévben megadott szabályt veszi figyelembe: http://pastebin.com/rjyyZv9V
Üdv: Zoli
- A hozzászóláshoz be kell jelentkezni
Köszi a választ,
Az első esetben (ami a legjobb lenne):
# ./fail2ban
File "./fail2ban", line 31
val=confReader.get(section, "enabled")
^
IndentationError: unindent does not match any outer indentation level
A másodikban:
# ./fail2ban_ssh
/etc/munin/plugins/fail2ban_ssh: 18: Syntax error: word unexpected (expecting "in")
Sajnos nálam egyik sem megy... nem tudom mi lett elírva, de a scripteket is átnéztem.
- A hozzászóláshoz be kell jelentkezni
Az elsőt javítottam, a másolás során valahogy belekerült néhány indent hiba: http://pastebin.com/StstbAM6
A másodiknál mi az alapértelmezett shell beállításod? Azon a gépen, ahonnan kimásoltam az alábbi shellel hiba nélkül működik: GNU bash, version 3.2.39
Üdv: Zoli
- A hozzászóláshoz be kell jelentkezni
Köszi a javítást, az első megy.
A második tulajdonképp nem nagyon érdekel, ha az első megy. Remélhetőleg annyi ban nem lesz, hogy külön grafikonok kellene ábrázoltatnom.
A bash verzióm:
GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu)
Nincs különbség... még sem megy... - de lényegtelen, az első megy.
Továbbá, köszönöm a segítséged, a probléma megoldva.
Ha nem bánod, a pastebin rejtelmei(elévülés) miatt inkább ide is bemásolom az utókor és a memóriám kedvéért.
#!/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 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/jail.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()
- A hozzászóláshoz be kell jelentkezni
subscribe
- A hozzászóláshoz be kell jelentkezni