1
0
mirror of https://github.com/limosek/zaf-plugins.git synced 2025-01-21 23:45:56 +01:00

Updated plugins to new control syntax

This commit is contained in:
Lukas Macura 2016-04-21 15:29:20 +02:00
parent a1dc95674f
commit c439a9b06a
6 changed files with 158 additions and 112 deletions

View File

@ -9,7 +9,7 @@ Description::
:: ::
# Version of the plugin. # Version of the plugin.
Version: 0.2 Version: 0.3
# Url of plugin location to be able to update plugin # Url of plugin location to be able to update plugin
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/fail2ban Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/fail2ban
@ -32,7 +32,9 @@ Item banned_actual:
Description:: Description::
Returns number of currently banned IPs for jail Returns number of currently banned IPs for jail
:: ::
Parameters: jail Parameters::
jail '' ''
::
Cmd: sudo fail2ban-client status $1 | grep "Currently banned:" | grep -o -E "[0-9]*" Cmd: sudo fail2ban-client status $1 | grep "Currently banned:" | grep -o -E "[0-9]*"
/Item /Item
@ -40,7 +42,9 @@ Item banned_total:
Description:: Description::
Returns number of total banned IPs for jail Returns number of total banned IPs for jail
:: ::
Parameters: jail Parameters::
jail '' ''
::
Cmd: sudo fail2ban-client status $1 | grep "Total banned:" | grep -o -E "[0-9]*" Cmd: sudo fail2ban-client status $1 | grep "Total banned:" | grep -o -E "[0-9]*"
/Item /Item
@ -48,12 +52,6 @@ Item jail_discovery:
Description:: Description::
Returns discovered jails Returns discovered jails
:: ::
Script:: Script: sudo fail2ban-client status | grep "Jail list" |grep -E -o "([-[:alnum:]]*, )*[-[:alnum:]]*$" | zaf_discovery '{#F2BJAIL}'
#!/bin/sh
. $ZAF_LIB_DIR/zaf.lib.sh
sudo fail2ban-client status | grep "Jail list" |grep -E -o "([-[:alnum:]]*, )*[-[:alnum:]]*$" | zaf_discovery '{#F2BJAIL}'
::
/Item /Item

View File

@ -4,7 +4,7 @@ Description::
Plugin which will make deeper look into directory structure using discovery Plugin which will make deeper look into directory structure using discovery
:: ::
Version: 0.6 Version: 0.7
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/fsx Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/fsx
Web: https://github.com/limosek/zaf-plugins/ Web: https://github.com/limosek/zaf-plugins/
Maintainer: Lukas Macura <lukas@macura.cz> Maintainer: Lukas Macura <lukas@macura.cz>
@ -27,55 +27,59 @@ Cron::
Item discovery: Item discovery:
Description:: Description::
Discovery of files or directories. Discovery of files or directories.
{asroot|aszabbix} - which permissions to use. Sudo must be installed for asroot
directory - directory to scan
mask - mask to search. Use % instead of * in mask. Like '%' to find all objects, '%.txt' to find all .txt files
maxdepth - depth to search. 1 means only one directory, not subdirs
type - Type of objects to find (f=file,d=dir,l=link)
sort - how to sort results (name/[+-], du/[+-])
maxobjects - maximum objects to find. 0 means no limit.
:: ::
Parameters: {asroot|aszabbix} directory mask maxdepth type sort maxobjects Parameters::
directory '' '' # directory to scan
mask % '' # mask to search. Use % instead of * in mask. Like '%' to find all objects, '%.txt' to find all .txt files.
type d '^(d|f|l)$' # Type of objects to find (f=file,d=dir,l=link)
maxdepth 1 '' # depth to search. 1 means only one directory, not subdirs.
sort du/- '^(du|name)/([+-])$' # how to sort results (name/[+-], du/[+-]).
maxobjects 50 '' # maximum objects to find. 0 means no limit.
who zabbix '^(root|zabbix)$' # which permissions to use. Sudo must be installed for root. Default is zabbix
::
Type: string Type: string
Testparameters: aszabbix,/tmp/,%,10,d,name/+,0 aszabbix,/tmp/,%,10,d,du/+,10 asroot,/var/lib/dpkg/,%,1,d,name/-,10 Testparameters: /tmp/ /tmp/,%,f,1,name/+,10,root
Precache: asroot,/var/,%,100,d,du/-,100 Precache: /tmp/
Cache: 86400 Cache: 86400
Script:: Script::
#!/bin/sh
case $1 in case $who in
asroot|root) asroot|root)
shift; exec sudo -E -n $0 "$@";; ! zaf_is_root && exec sudo -E -n $0 "$@";;
aszabbix|zabbix)
shift;;
esac esac
{INCLUDES}
mask="-name '$(echo $mask|tr '%' '*')'"
[ "$#" -lt 6 ] && zaf_err "Bad parameters!" depth="-maxdepth $maxdepth"
dir="$1" type="-type $type"
mask="-name '$(echo $2|tr '%' '*')'"
depth="-maxdepth $3" sorttype="$(echo $sort|cut -d '/' -f 1)"
type="-type $4" sortorder="$(echo $sort|cut -d '/' -f 2)"
sort="$(echo $5|cut -d '/' -f 1)"
sortorder="$(echo $5|cut -d '/' -f 2)"
[ "$sortorder" = "-" ] && so="-r" [ "$sortorder" = "-" ] && so="-r"
maxobjects=$6
if [ "$maxobjects" -gt 0 ]; then if [ "$maxobjects" -gt 0 ]; then
head="head -n $maxobjects" head="head -n $maxobjects"
else else
head="cat" head="cat"
fi fi
case $sort in tmpf=$ZAF_TMP_DIR/fsx$$
case $sorttype in
name) name)
zaf_dbg find "$dir" $depth $type $mask \| sort $so \| $head \| zaf_discovery '{#PATH}' zaf_dbg find "$directory" $depth $type $mask
eval find "$dir" $depth $type $mask | sort $so | $head | zaf_discovery '{#PATH}' eval find "$directory" $depth $type $mask >$tmpf
[ -s "$tmpf" ] || { echo -n "NO_OBJECTS_FOUND"; zaf_err "NO_OBJECTS_FOUND"; }
zaf_dbg sort -n $so \| $head \| zaf_discovery '{#PATH}'
sort -n $so <$tmpf | $head | zaf_discovery '{#PATH}'
;; ;;
du) du)
zaf_dbg find "$dir" $depth $type $mask -print0 \| xargs -0 du \| sort -n $so \| $head \| zaf_discovery '{#PATH}' zaf_dbg find "$directory" $depth $type $mask -print0
eval find "$dir" $depth $type $mask -print0 | xargs -0 du | sort -n $so | tr '\t' ' ' | cut -d ' ' -f 2 | $head |zaf_discovery '{#PATH}' eval find "$directory" $depth $type $mask -print0 >$tmpf
[ -s "$tmpf" ] || { echo -n "NO_OBJECTS_FOUND"; zaf_err "NO_OBJECTS_FOUND"; }
zaf_dbg xargs -0 du \| sort -n $so \| $head \| zaf_discovery '{#PATH}'
xargs -0 du <$tmpf | sort -n $so | tr '\t' ' ' | cut -d ' ' -f 2 | $head |zaf_discovery '{#PATH}'
;; ;;
esac esac
rm -f $tmpf
:: ::
/Item /Item
@ -86,26 +90,22 @@ Description::
f - file f - file
l - symbolink link l - symbolink link
:: ::
Parameters: asroot discovered_path Parameters::
path '' '' # Path
who zabbix '^(root|zabbix)$' # which permissions to use. Sudo must be installed for root. Default is zabbix
::
Type: character Type: character
TestParameters: aszabbix,/tmp/ Testparameters: /tmp/ /tmp/,root
Script:: Script::
#!/bin/sh
case $1 in case $who in
asroot|root) asroot|root)
shift; exec sudo -E -n $0 "$@";; ! zaf_is_root && exec sudo -E -n $0 "$@";;
aszabbix|zabbix)
shift;;
esac esac
{INCLUDES}
[ -z "$1" ] && zaf_err "Directory must be entered."
[ -f "$1" ] && echo f && exit
[ -d "$1" ] && echo d && exit
[ -l "$1" ] && echo l && exit
[ -f "$path" ] && echo f && exit
[ -d "$path" ] && echo d && exit
[ -l "$path" ] && echo l && exit
:: ::
/Item: /Item:
@ -113,24 +113,21 @@ Item pathinfo_du:
Description:: Description::
Disk usage of discovered path in bytes Disk usage of discovered path in bytes
:: ::
Parameters: asroot discovered_path Parameters::
path '' '' # Path
who zabbix '^(root|zabbix)$' # which permissions to use. Sudo must be installed for root. Default is zabbix
::
Type: integer Type: integer
TestParameters: aszabbix,/tmp/ Testparameters: /tmp /tmp/,root
Cache: 3600 Cache: 3600
Script:: Script::
#!/bin/sh
case $1 in case $who in
asroot|root) asroot|root)
shift; exec sudo -E -n $0 "$@";; ! zaf_is_root && exec sudo -E -n $0 "$@";;
aszabbix|zabbix)
shift;;
esac esac
{INCLUDES}
[ -z "$1" ] && zaf_err "Directory must be entered." du -sb "$path" | (read sum dir; echo $sum)
du -sb "$1" | (read sum dir; echo $sum)
:: ::
/Item: /Item:
@ -138,24 +135,21 @@ Item pathinfo_items:
Description:: Description::
Number of items in discovered path (dirs+files+rest) Number of items in discovered path (dirs+files+rest)
:: ::
Parameters: asroot discovered_path Parameters::
path '' '' # Path
who zabbix '^(root|zabbix)$' # which permissions to use. Sudo must be installed for root. Default is zabbix
::
Type: integer Type: integer
TestParameters: aszabbix,/tmp/ Testparameters: /tmp /tmp/,root
Cache: 600 Cache: 600
Script:: Script::
#!/bin/sh
case $1 in case $who in
asroot|root) asroot|root)
shift; exec sudo -E -n $0 "$@";; ! zaf_is_root && exec sudo -E -n $0 "$@";;
aszabbix|zabbix)
shift;;
esac esac
{INCLUDES}
[ -z "$1" ] && zaf_err "Directory must be entered." ls -1 "$path" |wc -l
ls -1 "$1" |wc -l
:: ::
/Item: /Item:

View File

@ -4,7 +4,7 @@ Description::
Plugin which will make deeper look to processess and their usage. Plugin which will make deeper look to processess and their usage.
:: ::
Version: 0.1 Version: 0.2
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/psx Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/psx
Web: https://github.com/limosek/zaf-plugins/ Web: https://github.com/limosek/zaf-plugins/
Maintainer: Lukas Macura <lukas@macura.cz> Maintainer: Lukas Macura <lukas@macura.cz>
@ -20,7 +20,24 @@ Item discovery:
Description:: Description::
Discovery of runing processes Discovery of runing processes
:: ::
Cmd: {PLUGINDIR}/proc-discovery.sh Testparameters: ps systemd,root
Parameters::
pregex '.*' '' # regexp to match process name
uregex '.*' '' # regexp to match user name
::
Script::
if [ "${ZAF_PKG}" = "opkg" ]; then
AWK='{ print $2" "$5; }'
PS="w"
else
AWK='{ print $11" "$1; }'
PS="--no-headers caux"
fi
ps $PS | awk "$AWK" | sort | uniq | sed -e 's/\//\\\//g' -e '$s/.$//' | grep -E "^$pregex" | grep -E "$uregex\$" | zaf_discovery '{#PSNAME}' '{#PSUSER}'
::
/Item /Item

View File

@ -19,7 +19,7 @@ Item discovery_interfaces:
Description:: Description::
Discovery of tc enabled interfaces Discovery of tc enabled interfaces
:: ::
Script: {INCLUDES} tc qdisc show | sed 's/.*dev \([\_a-z0-9\-]*\).*/\1/' | sort | uniq | zaf_discovery '{#IFACE}' Script: tc qdisc show | sed 's/.*dev \([\_a-z0-9\-]*\).*/\1/' | sort | uniq | zaf_discovery '{#IFACE}'
/Item /Item
Item discovery_classes: Item discovery_classes:
@ -27,7 +27,6 @@ Description::
Discovery of tc classes Discovery of tc classes
:: ::
Script:: Script::
{INCLUDES}
ifs=$(tc qdisc show | sed 's/.*dev \([\_a-z0-9\-]*\).*/\1/' | sort | uniq) ifs=$(tc qdisc show | sed 's/.*dev \([\_a-z0-9\-]*\).*/\1/' | sort | uniq)
for i in $ifs; do for i in $ifs; do
tc class ls dev $i |cut -d ' ' -f 2,3,5 | while read type id parent; do tc class ls dev $i |cut -d ' ' -f 2,3,5 | while read type id parent; do
@ -38,59 +37,79 @@ done
/Item /Item
Item discovery_qdiscs: Item discovery_qdiscs:
Parameters: interface Parameters::
interface '' ''
::
Description:: Description::
Discovery of tc qdiscs Discovery of tc qdiscs
:: ::
Script: {INCLUDES} tc qdisc show |cut -d ' ' -f 2,3,5,7 | zaf_discovery '{#TYPE}' '{#ID}' '{#IFACE}' '{#PARENT}' Cmd: tc qdisc show |cut -d ' ' -f 2,3,5,7 | zaf_discovery '{#TYPE}' '{#ID}' '{#IFACE}' '{#PARENT}'
/Item /Item
Item qdisc_limit: Item qdisc_limit:
Parameters: interface id Parameters:
interface '' '' # Interface
id '' '' # Id
::
Description:: Description::
Show limit of given qdisc handle Show limit of given qdisc handle
:: ::
Script: {INCLUDES} tc -s qdisc show dev $1 | awk '/qdisc(.*)'$1':/ { print $7 }' | tr -d 'p' Cmd: tc -s qdisc show dev $1 | awk '/qdisc(.*)'$1':/ { print $7 }' | tr -d 'p'
/Item /Item
Item qdisc_flows: Item qdisc_flows:
Parameters: interface id Parameters:
interface '' '' # Interface
id '' '' # Id
::
Description:: Description::
Show flows of given qdisc handle Show flows of given qdisc handle
:: ::
Script: {INCLUDES} tc -s qdisc show dev $1 | awk '/qdisc(.*)'$1':/ { print $9 }' | tr -d 'p' Cmd: tc -s qdisc show dev $1 | awk '/qdisc(.*)'$1':/ { print $9 }' | tr -d 'p'
/Item /Item
Item class_sentbytes: Item class_sentbytes:
Parameters: interface id Parameters:
interface '' '' # Interface
id '' '' # Id
::
Description:: Description::
Show bytes sent to this class Show bytes sent to this class
:: ::
Script: {INCLUDES} tc -s class show dev $1 | awk '/class(.*)'$2'/ { getline; print $2 }' Cmd: tc -s class show dev $1 | awk '/class(.*)'$2'/ { getline; print $2 }'
/Item /Item
Item class_sentpackets: Item class_sentpackets:
Parameters: interface id Parameters:
interface '' '' # Interface
id '' '' # Id
::
Description:: Description::
Show packets sent to this class Show packets sent to this class
:: ::
Script: {INCLUDES} tc -s class show dev $1 | awk '/class(.*)'$2'/ { getline; print $4 }' Cmd: tc -s class show dev $1 | awk '/class(.*)'$2'/ { getline; print $4 }'
/Item /Item
Item class_dropped: Item class_dropped:
Parameters: interface id Parameters:
interface '' '' # Interface
id '' '' # Id
::
Description:: Description::
Show dropped packets in this class Show dropped packets in this class
:: ::
Script: {INCLUDES} tc -s class show dev $1 | awk '/class(.*)'$2'/ { getline; print $7 }' | tr -d ',' Cmd: tc -s class show dev $1 | awk '/class(.*)'$2'/ { getline; print $7 }' | tr -d ','
/Item /Item
Item class_overlimit: Item class_overlimit:
Parameters: interface id Parameters:
interface '' '' # Interface
id '' '' # Id
::
Description:: Description::
Show overlimit packets in this class Show overlimit packets in this class
:: ::
Script: {INCLUDES} tc -s class show dev $1 | awk '/class(.*)'$2'/ { getline; print $9 }' | tr -d ',' Cmd: tc -s class show dev $1 | awk '/class(.*)'$2'/ { getline; print $9 }' | tr -d ','
/Item /Item

View File

@ -8,7 +8,7 @@ Description::
:: ::
# Version of the plugin. # Version of the plugin.
Version: 0.4 Version: 0.5
# Url of plugin location to be able to update plugin # Url of plugin location to be able to update plugin
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/zaf Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/zaf
@ -37,61 +37,79 @@ Item plugins:
Description:: Description::
Returns installed plugins Returns installed plugins
:: ::
Cmd:: zaf_list_plugins Cmd: zaf_list_plugins
/Item /Item
Item discovery.plugins: Item discovery_plugins:
Description:: Description::
Returns installed plugins in form suitable for zabbix discovery Returns installed plugins in form suitable for zabbix discovery
:: ::
Cmd:: zaf_discovery_plugins Cmd: zaf_discovery_plugins
/Item /Item
Item plugin_version: Item plugin_version:
Parameters: plugin_name Parameters::
plugin_name '' ''
::
Testparameters: zaf
Description:: Description::
Returns version of plugin Returns version of plugin
:: ::
Cmd:: zaf_plugin_version $1 Cmd: zaf_plugin_version $1
/Item /Item
Item plugin_url: Item plugin_url:
Parameters: plugin_name Parameters::
plugin_name '' ''
::
Testparameters: zaf
Description:: Description::
Returns base url of plugin Returns base url of plugin
:: ::
Cmd:: zaf_plugin_url $1 Cmd: zaf_plugin_url $1
/Item /Item
Item plugin_web: Item plugin_web:
Parameters: plugin_name Parameters::
plugin_name '' ''
::
Testparameters: zaf
Description:: Description::
Returns home url of plugin Returns home url of plugin
:: ::
Cmd:: zaf_plugin_web $1 Cmd: zaf_plugin_web $1
/Item /Item
Item plugin_maintainer: Item plugin_maintainer:
Parameters: plugin_name Parameters::
plugin_name '' ''
::
Testparameters: zaf
Description:: Description::
Returns maintainer of plugin Returns maintainer of plugin
:: ::
Cmd:: zaf_plugin_maintainer $1 Cmd: zaf_plugin_maintainer $1
/Item /Item
Item plugin_items: Item plugin_items:
Parameters: plugin_name Parameters::
plugin_name '' ''
::
Testparameters: zaf
Description:: Description::
Returns items defined in plugin Returns items defined in plugin
:: ::
Cmd:: zaf_list_plugin_items $1 Cmd: zaf_list_plugin_items $1
/Item /Item
Item plugin_template_url: Item plugin_template_url:
Parameters: plugin_name Parameters::
plugin_name '' ''
::
Testparameters: zaf
Description:: Description::
Returns base template url for plugin Returns base template url for plugin
:: ::
Cmd:: zaf_plugin_template_url $1 Cmd: zaf_plugin_template_url $1
/Item /Item

View File

@ -73,7 +73,7 @@
<type>7</type> <type>7</type>
<snmp_community/> <snmp_community/>
<snmp_oid/> <snmp_oid/>
<key>zaf.discovery.plugins</key> <key>zaf.discovery_plugins</key>
<delay>3600</delay> <delay>3600</delay>
<status>0</status> <status>0</status>
<allowed_hosts/> <allowed_hosts/>