From 922edfe2cb6f10b9df87fb9f3f29df0acb384b1d Mon Sep 17 00:00:00 2001 From: Lukas Macura Date: Tue, 5 Apr 2016 12:46:35 +0200 Subject: [PATCH] Added fail2ban plugin Repaired discovery of openssh plugin --- fail2ban/README.md | 8 +++ fail2ban/control.zaf | 71 ++++++++++++++++++++ fail2ban/template.xml | 150 ++++++++++++++++++++++++++++++++++++++++++ openssh/control.zaf | 6 +- 4 files changed, 232 insertions(+), 3 deletions(-) create mode 100644 fail2ban/README.md create mode 100644 fail2ban/control.zaf create mode 100644 fail2ban/template.xml diff --git a/fail2ban/README.md b/fail2ban/README.md new file mode 100644 index 0000000..1a2b4f3 --- /dev/null +++ b/fail2ban/README.md @@ -0,0 +1,8 @@ + +# Plugin fail2ban +Zaf plugin for monitoring fail2ban with LLD + +# Credits +2014 dron, jiri.slezka@slu.cz +2016 limo, lukas.macura@slu.cz + diff --git a/fail2ban/control.zaf b/fail2ban/control.zaf new file mode 100644 index 0000000..3cd8362 --- /dev/null +++ b/fail2ban/control.zaf @@ -0,0 +1,71 @@ + +Plugin: fail2ban + +Description:: + Plugin fail2ban + Zaf plugin for monitoring fail2ban with LLD + Credits + 2014 dron, jiri.slezka@slu.cz + 2016 limo, lukas.macura@slu.cz +:: + +# Version of the plugin. +Version: 0.1 + +# Url of plugin location to be able to update plugin +Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/fail2ban + +# Homepage of plugin +Web: https://github.com/limosek/zaf-plugins/ + +# Maintainer +Maintainer: Lukas Macura + +# Dependencies +Depends-dpkg: dash curl fail2ban sudo +Depens-opkg: busybox curl fail2ban sudo +Depends-rpm: curl fail2ban sudo +Depends-bin: curl fail2ban-client sudo + +# We need to setup sudo to reach fail2ban-client as zabbix user +Install-script:: +#!/bin/sh + +. $ZAF_LIB_DIR/zaf.lib.sh + + if [ -d /etc/sudoers.d ]; then + echo zabbix ALL=NOPASSWD: $(which fail2ban-client) '*' >/etc/sudoers.d/zaf-fail2ban + else + zaf_wrn "Cannot setup sudo. Please do it manualy or run zabbix agent as root." + fi +:: + +Item banned_actual: +Description:: + Returns number of currently banned IPs for jail +:: +Parameters: jail +Cmd: sudo fail2ban-client status $1 | grep "Currently banned:" | grep -o -E "[0-9]*" +/Item + +Item banned_total: +Description:: + Returns number of total banned IPs for jail +:: +Parameters: jail +Cmd: sudo fail2ban-client status $1 | grep "Total banned:" | grep -o -E "[0-9]*" +/Item + +Item jail_discovery: +Description:: + Returns discovered jails +:: +Script:: +#!/bin/sh + +. $ZAF_LIB_DIR/zaf.lib.sh +sudo fail2ban-client status | grep "Jail list" |grep -E -o "([-[:alnum:]]*, )*[-[:alnum:]]*$" | zaf_discovery '{#F2BJAIL}' + +:: +/Item + diff --git a/fail2ban/template.xml b/fail2ban/template.xml new file mode 100644 index 0000000..613f1d1 --- /dev/null +++ b/fail2ban/template.xml @@ -0,0 +1,150 @@ + + + 2.0 + 2014-09-30T10:56:29Z + + + Templates + + + + + + diff --git a/openssh/control.zaf b/openssh/control.zaf index 46ce48b..f5a828b 100644 --- a/openssh/control.zaf +++ b/openssh/control.zaf @@ -4,7 +4,7 @@ Description:: Plugin which will discover openssh config options and will return their values. :: -Version: 0.1 +Version: 0.2 Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/openssh Web: https://github.com/limosek/zaf-plugins/ Maintainer: Lukas Macura @@ -13,7 +13,7 @@ Maintainer: Lukas Macura Depends-dpkg: dash Depens-opkg: busybox Depends-rpm: grep -Depends-bin: grep tr +Depends-bin: grep tr sort uniq Item discovery: Description:: @@ -35,7 +35,7 @@ Script:: grep -v '^#' "$cfg" | tr -s '\n' | \ while read opt; do [ -n "$opt" ] && echo $opt - done | zaf_discovery '{#OPTION}' + done | sort | uniq | zaf_discovery '{#OPTION}' :: /Item