1
0
mirror of https://github.com/limosek/zaf.git synced 2025-11-01 18:17:37 +01:00

Added and documented itemsh command

This commit is contained in:
Lukas Macura
2016-12-11 16:20:06 +01:00
parent 6204eacd6a
commit 7f774f409d
4 changed files with 42 additions and 3 deletions

View File

@@ -226,6 +226,8 @@ zaf_ctrl_install() {
# Generates zabbix items cfg from control file
# $1 control
# $2 pluginname
# $3 if set, no script will be created
# $4 if set, cmd is set always to $4
zaf_ctrl_generate_items_cfg() {
local items
local cmd
@@ -281,8 +283,11 @@ zaf_ctrl_generate_items_cfg() {
else
retscr="";
fi
cmd=$(zaf_ctrl_get_item_option $1 $i "Cmd")
if [ -z "$4" ]; then
cmd=$(zaf_ctrl_get_item_option $1 $i "Cmd")
else
cmd="$4"
fi
if [ -n "$cmd" ]; then
printf "%s" "UserParameter=$ikey,${env}${zafparams}${preload}${cache}${lock}${cmd}${retscr}"; echo
continue
@@ -294,7 +299,12 @@ zaf_ctrl_generate_items_cfg() {
zaf_ctrl_get_item_option $1 $i "Script"
) >${ZAF_TMP_DIR}/${iscript}.sh;
[ -z "$3" ] && zaf_install_bin ${ZAF_TMP_DIR}/${iscript}.sh ${ZAF_PLUGINS_DIR}/$2/
printf "%s" "UserParameter=$ikey,${env}${preload}${zafparams}${cache}${lock}${ZAF_PLUGINS_DIR}/$2/${iscript}.sh ${args}"; echo
if [ -z "$4" ]; then
script="${ZAF_PLUGINS_DIR}/$2/${iscript}.sh"
else
script="$4"
fi
printf "%s" "UserParameter=$ikey,${env}${preload}${zafparams}${cache}${lock}$script ${args}"; echo
rm -f ${ZAF_TMP_DIR}/${iscript}.sh
continue;
fi

View File

@@ -212,6 +212,17 @@ zaf_is_plugin() {
false
}
zaf_is_item() {
local plugin
local item
plugin=$(echo $1|cut -d '.' -f 1)
item=$(echo $1|cut -d '.' -f 2)
[ -z "$plugin" ] || [ -z "$item" ] && return 1
zaf_is_plugin "$plugin" && zaf_list_plugin_items "$plugin" | grep -qE "\.(${item}\$|${item}\[)"
}
zaf_discovery_plugins() {
zaf_list_plugins | zaf_discovery '{#PLUGIN}'
}