From 2c80379ec5b2d484c4c348ced15916c3c9538a6f Mon Sep 17 00:00:00 2001 From: Lukas Macura Date: Tue, 12 Apr 2016 20:31:05 +0200 Subject: [PATCH] Reworked cron and sudo in control --- fail2ban/control.zaf | 15 +---- fsx/control.zaf | 53 +++++++++++++--- fsx/template.xml | 147 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 191 insertions(+), 24 deletions(-) diff --git a/fail2ban/control.zaf b/fail2ban/control.zaf index d4623b6..cb8c11a 100644 --- a/fail2ban/control.zaf +++ b/fail2ban/control.zaf @@ -9,7 +9,7 @@ Description:: :: # Version of the plugin. -Version: 0.1 +Version: 0.2 # Url of plugin location to be able to update plugin Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/fail2ban @@ -26,18 +26,7 @@ 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 -:: +Sudo: fail2ban-client % Item banned_actual: Description:: diff --git a/fsx/control.zaf b/fsx/control.zaf index 156f53d..4e17cde 100644 --- a/fsx/control.zaf +++ b/fsx/control.zaf @@ -4,7 +4,7 @@ Description:: Plugin which will make deeper look into directory structure using discovery :: -Version: 0.1 +Version: 0.2 Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/fsx Web: https://github.com/limosek/zaf-plugins/ Maintainer: Lukas Macura @@ -15,17 +15,33 @@ Depens-opkg: busybox curl Depends-rpm: curl Depends-bin: curl find +# Sudo needed. It will be preconfigured if sudo is installed +Sudo: /usr/bin/find %, {PLUGINDIR}/%sh % + +# Cron for info about busy directories +# This is only example to get disk usage of common /var dirs +#Cron:: +#0 * * * * (zabbix zaf precache 'fsx.pathinfo_du[asroot,/var/]' && zaf precache 'fsx.pathinfo_du[asroot,/var/mail]' && zaf precache 'fsx.pathinfo_du[asroot,/var/lib]') >/dev/null 2>/dev/#null +#:: + Item discovery: Description:: - Discovery of files or directories. Enter % instead of * in mask. + Discovery of files or directories. Enter % instead of * in mask. If first argument is "asroot", sudo will be used. It must be configured. :: -Parameters: directory mask depth type +Parameters: asroot directory mask depth type Type: string +Cache: 3600 Script:: #!/bin/sh +case $1 in +asroot) + shift; exec sudo -E -n $0 "$@";; +aszabbix) + shift;; +esac . $ZAF_LIB_DIR/preload.sh - + [ -z "$1" ] && zaf_err "Directory must be entered." dir="$1" mask="-name '$(echo $2|tr '%' '*')'" @@ -46,10 +62,17 @@ Description:: f - file l - symbolink link :: -Parameters: discovered_path +Parameters: asroot discovered_path Type: character Script:: +#!/bin/sh +case $1 in +asroot) + shift; exec sudo -E -n $0 "$@";; +aszabbix) + shift;; +esac . $ZAF_LIB_DIR/preload.sh [ -z "$1" ] && zaf_err "Directory must be entered." @@ -65,10 +88,18 @@ Item pathinfo_du: Description:: Disk usage of discovered path in bytes :: -Parameters: discovered_path +Parameters: asroot discovered_path Type: integer +Cache: 3600 Script:: +#!/bin/sh +case $1 in +asroot) + shift; exec sudo -E -n $0 "$@";; +aszabbix) + shift;; +esac . $ZAF_LIB_DIR/preload.sh [ -z "$1" ] && zaf_err "Directory must be entered." @@ -81,10 +112,18 @@ Item pathinfo_items: Description:: Number of items in discovered path (dirs+files+rest) :: -Parameters: discovered_path +Parameters: asroot discovered_path Type: integer +Cache: 600 Script:: +#!/bin/sh +case $1 in +asroot) + shift; exec sudo -E -n $0 "$@";; +aszabbix) + shift;; +esac . $ZAF_LIB_DIR/preload.sh [ -z "$1" ] && zaf_err "Directory must be entered." diff --git a/fsx/template.xml b/fsx/template.xml index ac8bc43..2af0bbf 100644 --- a/fsx/template.xml +++ b/fsx/template.xml @@ -31,11 +31,11 @@ - ZAF fsx discovery of /var + ZAF fsx discovery of /var (under zabbix user) 7 - fsx.discovery[/var/,%,1,d] + fsx.discovery[aszabbix,/var/,%,1,d] 300 0 @@ -69,7 +69,7 @@ 0 - fsx.pathinfo_du[{#PATH}] + fsx.pathinfo_du[aszabbix,{#PATH}] 600 90 365 @@ -119,7 +119,7 @@ 0 - fsx.pathinfo_items[{#PATH}] + fsx.pathinfo_items[aszabbix,{#PATH}] 600 90 365 @@ -168,6 +168,145 @@ + + ZAF fsx discovery of /var (under root user, sudo needed) + 7 + + + fsx.discovery[asroot,/var/,%,1,d] + 300 + 0 + + + + 0 + 0 + + 0 + + + + + 0 + + + + + + + 0 + + + + 30 + Discover directories under /var + + + Path {#PATH} disk usage + 7 + + 0 + + fsx.pathinfo_du[asroot,{#PATH}] + 600 + 90 + 365 + 0 + 3 + + B + 0 + + + 0 + 0 + + 0 + + 1 + + + + 0 + 0 + + + + + + + 0 + + + Filesystems + + + fsx + + + ZAF + + + + + + + + Path {#PATH} items + 7 + + 0 + + fsx.pathinfo_items[asroot,{#PATH}] + 600 + 90 + 365 + 0 + 3 + + B + 0 + + + 0 + 0 + + 0 + + 1 + + + + 0 + 0 + + + + + + + 0 + + + Filesystems + + + fsx + + + ZAF + + + + + + + + + + + +