mirror of
https://github.com/limosek/zaf-plugins.git
synced 2025-01-21 07:25:56 +01:00
Updated plugins to new control syntax
This commit is contained in:
parent
a1dc95674f
commit
c439a9b06a
@ -9,7 +9,7 @@ Description::
|
||||
::
|
||||
|
||||
# Version of the plugin.
|
||||
Version: 0.2
|
||||
Version: 0.3
|
||||
|
||||
# Url of plugin location to be able to update plugin
|
||||
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/fail2ban
|
||||
@ -32,7 +32,9 @@ Item banned_actual:
|
||||
Description::
|
||||
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]*"
|
||||
/Item
|
||||
|
||||
@ -40,7 +42,9 @@ Item banned_total:
|
||||
Description::
|
||||
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]*"
|
||||
/Item
|
||||
|
||||
@ -48,12 +52,6 @@ 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}'
|
||||
|
||||
::
|
||||
Script: sudo fail2ban-client status | grep "Jail list" |grep -E -o "([-[:alnum:]]*, )*[-[:alnum:]]*$" | zaf_discovery '{#F2BJAIL}'
|
||||
/Item
|
||||
|
||||
|
128
fsx/control.zaf
128
fsx/control.zaf
@ -4,7 +4,7 @@ Description::
|
||||
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
|
||||
Web: https://github.com/limosek/zaf-plugins/
|
||||
Maintainer: Lukas Macura <lukas@macura.cz>
|
||||
@ -27,55 +27,59 @@ Cron::
|
||||
Item discovery:
|
||||
Description::
|
||||
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
|
||||
Testparameters: aszabbix,/tmp/,%,10,d,name/+,0 aszabbix,/tmp/,%,10,d,du/+,10 asroot,/var/lib/dpkg/,%,1,d,name/-,10
|
||||
Precache: asroot,/var/,%,100,d,du/-,100
|
||||
Testparameters: /tmp/ /tmp/,%,f,1,name/+,10,root
|
||||
Precache: /tmp/
|
||||
Cache: 86400
|
||||
Script::
|
||||
#!/bin/sh
|
||||
|
||||
case $1 in
|
||||
case $who in
|
||||
asroot|root)
|
||||
shift; exec sudo -E -n $0 "$@";;
|
||||
aszabbix|zabbix)
|
||||
shift;;
|
||||
! zaf_is_root && exec sudo -E -n $0 "$@";;
|
||||
esac
|
||||
{INCLUDES}
|
||||
|
||||
[ "$#" -lt 6 ] && zaf_err "Bad parameters!"
|
||||
dir="$1"
|
||||
mask="-name '$(echo $2|tr '%' '*')'"
|
||||
depth="-maxdepth $3"
|
||||
type="-type $4"
|
||||
sort="$(echo $5|cut -d '/' -f 1)"
|
||||
sortorder="$(echo $5|cut -d '/' -f 2)"
|
||||
|
||||
mask="-name '$(echo $mask|tr '%' '*')'"
|
||||
depth="-maxdepth $maxdepth"
|
||||
type="-type $type"
|
||||
|
||||
sorttype="$(echo $sort|cut -d '/' -f 1)"
|
||||
sortorder="$(echo $sort|cut -d '/' -f 2)"
|
||||
[ "$sortorder" = "-" ] && so="-r"
|
||||
maxobjects=$6
|
||||
|
||||
if [ "$maxobjects" -gt 0 ]; then
|
||||
head="head -n $maxobjects"
|
||||
else
|
||||
head="cat"
|
||||
fi
|
||||
|
||||
case $sort in
|
||||
tmpf=$ZAF_TMP_DIR/fsx$$
|
||||
case $sorttype in
|
||||
name)
|
||||
zaf_dbg find "$dir" $depth $type $mask \| sort $so \| $head \| zaf_discovery '{#PATH}'
|
||||
eval find "$dir" $depth $type $mask | sort $so | $head | zaf_discovery '{#PATH}'
|
||||
zaf_dbg find "$directory" $depth $type $mask
|
||||
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)
|
||||
zaf_dbg find "$dir" $depth $type $mask -print0 \| xargs -0 du \| sort -n $so \| $head \| zaf_discovery '{#PATH}'
|
||||
eval find "$dir" $depth $type $mask -print0 | xargs -0 du | sort -n $so | tr '\t' ' ' | cut -d ' ' -f 2 | $head |zaf_discovery '{#PATH}'
|
||||
zaf_dbg find "$directory" $depth $type $mask -print0
|
||||
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
|
||||
rm -f $tmpf
|
||||
::
|
||||
/Item
|
||||
|
||||
@ -86,26 +90,22 @@ Description::
|
||||
f - file
|
||||
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
|
||||
TestParameters: aszabbix,/tmp/
|
||||
Testparameters: /tmp/ /tmp/,root
|
||||
Script::
|
||||
#!/bin/sh
|
||||
|
||||
case $1 in
|
||||
case $who in
|
||||
asroot|root)
|
||||
shift; exec sudo -E -n $0 "$@";;
|
||||
aszabbix|zabbix)
|
||||
shift;;
|
||||
! zaf_is_root && exec sudo -E -n $0 "$@";;
|
||||
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:
|
||||
|
||||
@ -113,24 +113,21 @@ Item pathinfo_du:
|
||||
Description::
|
||||
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
|
||||
TestParameters: aszabbix,/tmp/
|
||||
Testparameters: /tmp /tmp/,root
|
||||
Cache: 3600
|
||||
Script::
|
||||
#!/bin/sh
|
||||
|
||||
case $1 in
|
||||
case $who in
|
||||
asroot|root)
|
||||
shift; exec sudo -E -n $0 "$@";;
|
||||
aszabbix|zabbix)
|
||||
shift;;
|
||||
! zaf_is_root && exec sudo -E -n $0 "$@";;
|
||||
esac
|
||||
{INCLUDES}
|
||||
|
||||
[ -z "$1" ] && zaf_err "Directory must be entered."
|
||||
|
||||
du -sb "$1" | (read sum dir; echo $sum)
|
||||
du -sb "$path" | (read sum dir; echo $sum)
|
||||
::
|
||||
/Item:
|
||||
|
||||
@ -138,24 +135,21 @@ Item pathinfo_items:
|
||||
Description::
|
||||
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
|
||||
TestParameters: aszabbix,/tmp/
|
||||
Testparameters: /tmp /tmp/,root
|
||||
Cache: 600
|
||||
Script::
|
||||
#!/bin/sh
|
||||
|
||||
case $1 in
|
||||
case $who in
|
||||
asroot|root)
|
||||
shift; exec sudo -E -n $0 "$@";;
|
||||
aszabbix|zabbix)
|
||||
shift;;
|
||||
! zaf_is_root && exec sudo -E -n $0 "$@";;
|
||||
esac
|
||||
{INCLUDES}
|
||||
|
||||
[ -z "$1" ] && zaf_err "Directory must be entered."
|
||||
|
||||
ls -1 "$1" |wc -l
|
||||
ls -1 "$path" |wc -l
|
||||
::
|
||||
/Item:
|
||||
|
||||
|
@ -4,7 +4,7 @@ Description::
|
||||
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
|
||||
Web: https://github.com/limosek/zaf-plugins/
|
||||
Maintainer: Lukas Macura <lukas@macura.cz>
|
||||
@ -20,7 +20,24 @@ Item discovery:
|
||||
Description::
|
||||
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
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ Item discovery_interfaces:
|
||||
Description::
|
||||
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 discovery_classes:
|
||||
@ -27,7 +27,6 @@ Description::
|
||||
Discovery of tc classes
|
||||
::
|
||||
Script::
|
||||
{INCLUDES}
|
||||
ifs=$(tc qdisc show | sed 's/.*dev \([\_a-z0-9\-]*\).*/\1/' | sort | uniq)
|
||||
for i in $ifs; 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 discovery_qdiscs:
|
||||
Parameters: interface
|
||||
Parameters::
|
||||
interface '' ''
|
||||
::
|
||||
Description::
|
||||
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 qdisc_limit:
|
||||
Parameters: interface id
|
||||
Parameters:
|
||||
interface '' '' # Interface
|
||||
id '' '' # Id
|
||||
::
|
||||
Description::
|
||||
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 qdisc_flows:
|
||||
Parameters: interface id
|
||||
Parameters:
|
||||
interface '' '' # Interface
|
||||
id '' '' # Id
|
||||
::
|
||||
Description::
|
||||
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 class_sentbytes:
|
||||
Parameters: interface id
|
||||
Parameters:
|
||||
interface '' '' # Interface
|
||||
id '' '' # Id
|
||||
::
|
||||
Description::
|
||||
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 class_sentpackets:
|
||||
Parameters: interface id
|
||||
Parameters:
|
||||
interface '' '' # Interface
|
||||
id '' '' # Id
|
||||
::
|
||||
Description::
|
||||
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 class_dropped:
|
||||
Parameters: interface id
|
||||
Parameters:
|
||||
interface '' '' # Interface
|
||||
id '' '' # Id
|
||||
::
|
||||
Description::
|
||||
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 class_overlimit:
|
||||
Parameters: interface id
|
||||
Parameters:
|
||||
interface '' '' # Interface
|
||||
id '' '' # Id
|
||||
::
|
||||
Description::
|
||||
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
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ Description::
|
||||
::
|
||||
|
||||
# Version of the plugin.
|
||||
Version: 0.4
|
||||
Version: 0.5
|
||||
|
||||
# Url of plugin location to be able to update plugin
|
||||
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/zaf
|
||||
@ -37,61 +37,79 @@ Item plugins:
|
||||
Description::
|
||||
Returns installed plugins
|
||||
::
|
||||
Cmd:: zaf_list_plugins
|
||||
Cmd: zaf_list_plugins
|
||||
/Item
|
||||
|
||||
Item discovery.plugins:
|
||||
Item discovery_plugins:
|
||||
Description::
|
||||
Returns installed plugins in form suitable for zabbix discovery
|
||||
::
|
||||
Cmd:: zaf_discovery_plugins
|
||||
Cmd: zaf_discovery_plugins
|
||||
/Item
|
||||
|
||||
Item plugin_version:
|
||||
Parameters: plugin_name
|
||||
Parameters::
|
||||
plugin_name '' ''
|
||||
::
|
||||
Testparameters: zaf
|
||||
Description::
|
||||
Returns version of plugin
|
||||
::
|
||||
Cmd:: zaf_plugin_version $1
|
||||
Cmd: zaf_plugin_version $1
|
||||
/Item
|
||||
|
||||
Item plugin_url:
|
||||
Parameters: plugin_name
|
||||
Parameters::
|
||||
plugin_name '' ''
|
||||
::
|
||||
Testparameters: zaf
|
||||
Description::
|
||||
Returns base url of plugin
|
||||
::
|
||||
Cmd:: zaf_plugin_url $1
|
||||
Cmd: zaf_plugin_url $1
|
||||
/Item
|
||||
|
||||
Item plugin_web:
|
||||
Parameters: plugin_name
|
||||
Parameters::
|
||||
plugin_name '' ''
|
||||
::
|
||||
Testparameters: zaf
|
||||
Description::
|
||||
Returns home url of plugin
|
||||
::
|
||||
Cmd:: zaf_plugin_web $1
|
||||
Cmd: zaf_plugin_web $1
|
||||
/Item
|
||||
|
||||
Item plugin_maintainer:
|
||||
Parameters: plugin_name
|
||||
Parameters::
|
||||
plugin_name '' ''
|
||||
::
|
||||
Testparameters: zaf
|
||||
Description::
|
||||
Returns maintainer of plugin
|
||||
::
|
||||
Cmd:: zaf_plugin_maintainer $1
|
||||
Cmd: zaf_plugin_maintainer $1
|
||||
/Item
|
||||
|
||||
Item plugin_items:
|
||||
Parameters: plugin_name
|
||||
Parameters::
|
||||
plugin_name '' ''
|
||||
::
|
||||
Testparameters: zaf
|
||||
Description::
|
||||
Returns items defined in plugin
|
||||
::
|
||||
Cmd:: zaf_list_plugin_items $1
|
||||
Cmd: zaf_list_plugin_items $1
|
||||
/Item
|
||||
|
||||
Item plugin_template_url:
|
||||
Parameters: plugin_name
|
||||
Parameters::
|
||||
plugin_name '' ''
|
||||
::
|
||||
Testparameters: zaf
|
||||
Description::
|
||||
Returns base template url for plugin
|
||||
::
|
||||
Cmd:: zaf_plugin_template_url $1
|
||||
Cmd: zaf_plugin_template_url $1
|
||||
/Item
|
||||
|
||||
|
@ -73,7 +73,7 @@
|
||||
<type>7</type>
|
||||
<snmp_community/>
|
||||
<snmp_oid/>
|
||||
<key>zaf.discovery.plugins</key>
|
||||
<key>zaf.discovery_plugins</key>
|
||||
<delay>3600</delay>
|
||||
<status>0</status>
|
||||
<allowed_hosts/>
|
||||
|
Loading…
Reference in New Issue
Block a user