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

Repaired send operation

This commit is contained in:
Lukas Macura
2017-02-15 15:35:16 +01:00
parent eaf83df311
commit 8b81fea72c
3 changed files with 44 additions and 8 deletions

14
zaf
View File

@@ -224,21 +224,28 @@ get)
send)
shift
if [ -z "$1" ]; then
# No parameters - pipe to zabbix_sender
zaf_dbg "Waiting for data on stdin (host item value) per line"
zscmd="zabbix_sender -z '$ZAF_ZBXSRV_HOST' -p '$ZAF_ZBXSRV_PORT' -i -"
zaf_dbg $zscmd
eval $zscmd 2>&1 | zaf_dbg
eval $zscmd
exit
else
if [ -n "$2" ]; then
# Hostname as parameter - rerun with right hostname set
exec $0 send "$2" "$3" ZAF_HOSTNAME="$1"
else
if echo "$1" | grep -q ':'; then
# Hostname:item - rerun with right hostname set
exec $0 send "$(echo $1 |cut -d ':' -f 2-)" "$3" ZAF_HOSTNAME="$(echo $1 |cut -d ':' -f 1)"
fi
if zaf_is_item "$1"; then
# Item supported by zaf
plugin=$(zaf_get_plugin_name "$1")
item=$(zaf_get_item_name "$1")
zscmd="zabbix_sender -z '$ZAF_ZBXSRV_HOST' -p '$ZAF_ZBXSRV_PORT' -s '$(zaf_hostname)' -k '$plugin.$item' -o '$(zaf_run_item $1)'"
zaf_dbg $zscmd
eval $zscmd 2>&1 | zaf_dbg
eval $zscmd
exit
else
if echo $1 | grep -q '='; then
@@ -251,12 +258,11 @@ send)
fi
zscmd="zabbix_sender -z '$ZAF_ZBXSRV_HOST' -p '$ZAF_ZBXSRV_PORT' -s '$(zaf_hostname)' -k '$item' -o '$value'"
zaf_dbg $zscmd
eval $zscmd 2>&1 | zaf_dbg
eval $zscmd
exit
fi
fi
fi
;;
register)
shift