2016-04-04 13:59:26 +02:00
|
|
|
|
|
|
|
Plugin: fsx
|
|
|
|
Description::
|
|
|
|
Plugin which will make deeper look into directory structure using discovery
|
|
|
|
::
|
|
|
|
|
2016-04-12 20:31:05 +02:00
|
|
|
Version: 0.2
|
2016-04-04 13:59:26 +02:00
|
|
|
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/fsx
|
|
|
|
Web: https://github.com/limosek/zaf-plugins/
|
|
|
|
Maintainer: Lukas Macura <lukas@macura.cz>
|
|
|
|
|
|
|
|
# Dependencies
|
|
|
|
Depends-dpkg: dash curl
|
|
|
|
Depens-opkg: busybox curl
|
|
|
|
Depends-rpm: curl
|
|
|
|
Depends-bin: curl find
|
|
|
|
|
2016-04-12 20:31:05 +02:00
|
|
|
# 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
|
|
|
|
#::
|
|
|
|
|
2016-04-04 13:59:26 +02:00
|
|
|
Item discovery:
|
|
|
|
Description::
|
2016-04-12 20:31:05 +02:00
|
|
|
Discovery of files or directories. Enter % instead of * in mask. If first argument is "asroot", sudo will be used. It must be configured.
|
2016-04-04 13:59:26 +02:00
|
|
|
::
|
2016-04-12 20:31:05 +02:00
|
|
|
Parameters: asroot directory mask depth type
|
2016-04-04 13:59:26 +02:00
|
|
|
Type: string
|
2016-04-12 20:31:05 +02:00
|
|
|
Cache: 3600
|
2016-04-04 13:59:26 +02:00
|
|
|
Script::
|
|
|
|
#!/bin/sh
|
|
|
|
|
2016-04-12 20:31:05 +02:00
|
|
|
case $1 in
|
|
|
|
asroot)
|
|
|
|
shift; exec sudo -E -n $0 "$@";;
|
|
|
|
aszabbix)
|
|
|
|
shift;;
|
|
|
|
esac
|
2016-04-04 13:59:26 +02:00
|
|
|
. $ZAF_LIB_DIR/preload.sh
|
2016-04-12 20:31:05 +02:00
|
|
|
|
2016-04-04 13:59:26 +02:00
|
|
|
[ -z "$1" ] && zaf_err "Directory must be entered."
|
|
|
|
dir="$1"
|
2016-04-04 14:48:57 +02:00
|
|
|
mask="-name '$(echo $2|tr '%' '*')'"
|
|
|
|
depth="-maxdepth $3"
|
2016-04-04 13:59:26 +02:00
|
|
|
if [ -n "$4" ]; then
|
2016-04-04 14:48:57 +02:00
|
|
|
type="-type $4"
|
2016-04-04 13:59:26 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
eval find "$dir" $depth $type $mask | zaf_discovery '{#PATH}'
|
|
|
|
|
|
|
|
::
|
|
|
|
/Item
|
|
|
|
|
|
|
|
Item pathinfo_type:
|
|
|
|
Description::
|
|
|
|
Type of discovered path (d,f,l)
|
|
|
|
d - directory
|
|
|
|
f - file
|
|
|
|
l - symbolink link
|
|
|
|
::
|
2016-04-12 20:31:05 +02:00
|
|
|
Parameters: asroot discovered_path
|
2016-04-04 13:59:26 +02:00
|
|
|
Type: character
|
|
|
|
Script::
|
2016-04-12 20:31:05 +02:00
|
|
|
#!/bin/sh
|
2016-04-04 13:59:26 +02:00
|
|
|
|
2016-04-12 20:31:05 +02:00
|
|
|
case $1 in
|
|
|
|
asroot)
|
|
|
|
shift; exec sudo -E -n $0 "$@";;
|
|
|
|
aszabbix)
|
|
|
|
shift;;
|
|
|
|
esac
|
2016-04-04 13:59:26 +02:00
|
|
|
. $ZAF_LIB_DIR/preload.sh
|
|
|
|
|
|
|
|
[ -z "$1" ] && zaf_err "Directory must be entered."
|
|
|
|
|
|
|
|
[ -f "$1" ] && echo f && exit
|
|
|
|
[ -d "$1" ] && echo d && exit
|
|
|
|
[ -l "$1" ] && echo l && exit
|
|
|
|
|
|
|
|
::
|
|
|
|
/Item:
|
|
|
|
|
|
|
|
Item pathinfo_du:
|
|
|
|
Description::
|
|
|
|
Disk usage of discovered path in bytes
|
|
|
|
::
|
2016-04-12 20:31:05 +02:00
|
|
|
Parameters: asroot discovered_path
|
2016-04-04 13:59:26 +02:00
|
|
|
Type: integer
|
2016-04-12 20:31:05 +02:00
|
|
|
Cache: 3600
|
2016-04-04 13:59:26 +02:00
|
|
|
Script::
|
2016-04-12 20:31:05 +02:00
|
|
|
#!/bin/sh
|
2016-04-04 13:59:26 +02:00
|
|
|
|
2016-04-12 20:31:05 +02:00
|
|
|
case $1 in
|
|
|
|
asroot)
|
|
|
|
shift; exec sudo -E -n $0 "$@";;
|
|
|
|
aszabbix)
|
|
|
|
shift;;
|
|
|
|
esac
|
2016-04-04 13:59:26 +02:00
|
|
|
. $ZAF_LIB_DIR/preload.sh
|
|
|
|
|
|
|
|
[ -z "$1" ] && zaf_err "Directory must be entered."
|
|
|
|
|
|
|
|
du -sb "$1" | (read sum dir; echo $sum)
|
|
|
|
::
|
|
|
|
/Item:
|
|
|
|
|
|
|
|
Item pathinfo_items:
|
|
|
|
Description::
|
|
|
|
Number of items in discovered path (dirs+files+rest)
|
|
|
|
::
|
2016-04-12 20:31:05 +02:00
|
|
|
Parameters: asroot discovered_path
|
2016-04-04 13:59:26 +02:00
|
|
|
Type: integer
|
2016-04-12 20:31:05 +02:00
|
|
|
Cache: 600
|
2016-04-04 13:59:26 +02:00
|
|
|
Script::
|
2016-04-12 20:31:05 +02:00
|
|
|
#!/bin/sh
|
2016-04-04 13:59:26 +02:00
|
|
|
|
2016-04-12 20:31:05 +02:00
|
|
|
case $1 in
|
|
|
|
asroot)
|
|
|
|
shift; exec sudo -E -n $0 "$@";;
|
|
|
|
aszabbix)
|
|
|
|
shift;;
|
|
|
|
esac
|
2016-04-04 13:59:26 +02:00
|
|
|
. $ZAF_LIB_DIR/preload.sh
|
|
|
|
|
|
|
|
[ -z "$1" ] && zaf_err "Directory must be entered."
|
|
|
|
|
|
|
|
ls -1 "$1" |wc -l
|
|
|
|
::
|
|
|
|
/Item:
|
|
|
|
|
|
|
|
|