mirror of
https://github.com/limosek/zaf-plugins.git
synced 2024-11-01 08:17:19 +01:00
136 lines
2.5 KiB
Plaintext
136 lines
2.5 KiB
Plaintext
|
|
Plugin: fsx
|
|
Description::
|
|
Plugin which will make deeper look into directory structure using discovery
|
|
::
|
|
|
|
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>
|
|
|
|
# Dependencies
|
|
Depends-dpkg: dash curl
|
|
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. If first argument is "asroot", sudo will be used. It must be configured.
|
|
::
|
|
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 '%' '*')'"
|
|
depth="-maxdepth $3"
|
|
if [ -n "$4" ]; then
|
|
type="-type $4"
|
|
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
|
|
::
|
|
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."
|
|
|
|
[ -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
|
|
::
|
|
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."
|
|
|
|
du -sb "$1" | (read sum dir; echo $sum)
|
|
::
|
|
/Item:
|
|
|
|
Item pathinfo_items:
|
|
Description::
|
|
Number of items in discovered path (dirs+files+rest)
|
|
::
|
|
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."
|
|
|
|
ls -1 "$1" |wc -l
|
|
::
|
|
/Item:
|
|
|
|
|