Reworked cron and sudo in control

1.3
Lukas Macura 2016-04-12 20:31:05 +02:00
parent 92b151bf1a
commit 2c80379ec5
3 changed files with 191 additions and 24 deletions

View File

@ -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::

View File

@ -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 <lukas@macura.cz>
@ -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."

View File

@ -31,11 +31,11 @@
<items/>
<discovery_rules>
<discovery_rule>
<name>ZAF fsx discovery of /var</name>
<name>ZAF fsx discovery of /var (under zabbix user)</name>
<type>7</type>
<snmp_community/>
<snmp_oid/>
<key>fsx.discovery[/var/,%,1,d]</key>
<key>fsx.discovery[aszabbix,/var/,%,1,d]</key>
<delay>300</delay>
<status>0</status>
<allowed_hosts/>
@ -69,7 +69,7 @@
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>fsx.pathinfo_du[{#PATH}]</key>
<key>fsx.pathinfo_du[aszabbix,{#PATH}]</key>
<delay>600</delay>
<history>90</history>
<trends>365</trends>
@ -119,7 +119,7 @@
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>fsx.pathinfo_items[{#PATH}]</key>
<key>fsx.pathinfo_items[aszabbix,{#PATH}]</key>
<delay>600</delay>
<history>90</history>
<trends>365</trends>
@ -168,6 +168,145 @@
<graph_prototypes/>
<host_prototypes/>
</discovery_rule>
<discovery_rule>
<name>ZAF fsx discovery of /var (under root user, sudo needed)</name>
<type>7</type>
<snmp_community/>
<snmp_oid/>
<key>fsx.discovery[asroot,/var/,%,1,d]</key>
<delay>300</delay>
<status>0</status>
<allowed_hosts/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<delay_flex/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<filter>
<evaltype>0</evaltype>
<formula/>
<conditions/>
</filter>
<lifetime>30</lifetime>
<description>Discover directories under /var</description>
<item_prototypes>
<item_prototype>
<name>Path {#PATH} disk usage</name>
<type>7</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>fsx.pathinfo_du[asroot,{#PATH}]</key>
<delay>600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>B</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Filesystems</name>
</application>
<application>
<name>fsx</name>
</application>
<application>
<name>ZAF</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>Path {#PATH} items</name>
<type>7</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>fsx.pathinfo_items[asroot,{#PATH}]</key>
<delay>600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>B</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Filesystems</name>
</application>
<application>
<name>fsx</name>
</application>
<application>
<name>ZAF</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
</item_prototypes>
<trigger_prototypes/>
<graph_prototypes/>
<host_prototypes/>
</discovery_rule>
</discovery_rules>
<macros/>
<templates/>