1
0
mirror of https://github.com/limosek/zaf.git synced 2024-11-24 03:19:05 +01:00

Updated cfg creation process

This commit is contained in:
Lukas Macura 2016-04-15 11:15:43 +02:00
parent 2f00b55838
commit 60009d71e6
2 changed files with 18 additions and 7 deletions

View File

@ -145,6 +145,20 @@ Commands:
./zaf cache-clean To remove all entries from cache ./zaf cache-clean To remove all entries from cache
``` ```
Zaf can even communicate with zabbix server using its API. If you set ZAF_ZBXAPI_URL, ZAF_ZBXAPI_USER and ZAF_ZBXAPI_PASS in /etc/zaf.conf, you can use it:
```
./zaf api command [parameters]
hostid 'host' Get hostid from hostname
host 'hostid' Get hostname from hostid
hostgroupid 'hostgroup' Get hostgroup id from hostgroup
hosts 'hostgroup' Get hosts in group
export-hosts dir [hostgroup] Backup all hosts [in group] (get their config from zabbix and save to dir/hostname.xml)
export-host 'host' Backup host (get config from zabbix to stdout)
import-template {plugin|file} Import template for plugin or from file
export-template 'name' Export template to stdout
export-templates dir Export all template to dir
```
### Installing plugin ### Installing plugin
To install plugin from common repository. If git is available, local git repo is tried first. If not, remote https repo is tried second. To install plugin from common repository. If git is available, local git repo is tried first. If not, remote https repo is tried second.
``` ```

View File

@ -218,16 +218,13 @@ zaf_ctrl_generate_cfg() {
$(which echo) "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $cache $lock$cmd"; $(which echo) "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $cache $lock$cmd";
continue continue
fi fi
cmd=$(zaf_ctrl_get_item_option $1 $i "Function")
if [ -n "$cmd" ]; then
$(which echo) "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $cache $lock$cmd";
continue;
fi
cmd=$(zaf_ctrl_get_item_option $1 $i "Script") cmd=$(zaf_ctrl_get_item_option $1 $i "Script")
if [ -n "$cmd" ]; then if [ -n "$cmd" ]; then
zaf_ctrl_get_item_option $1 $i "Script" >${ZAF_TMP_DIR}/${iscript}.sh; zaf_ctrl_get_item_option $1 $i "Script" | \
zaf_far '{INCLUDES}' '. /etc/zaf.conf; . ${ZAF_LIB_DIR}/zaf.lib.sh; . ${ZAF_LIB_DIR}/ctrl.lib.sh; . ${ZAF_LIB_DIR}/zbxapi.lib.sh; . ${ZAF_LIB_DIR}/cache.lib.sh; ' \
>${ZAF_TMP_DIR}/${iscript}.sh;
zaf_install_bin ${ZAF_TMP_DIR}/${iscript}.sh ${ZAF_PLUGINS_DIR}/$2/ zaf_install_bin ${ZAF_TMP_DIR}/${iscript}.sh ${ZAF_PLUGINS_DIR}/$2/
$(which echo) "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $cache $lock${ZAF_PLUGINS_DIR}/$2/${iscript}.sh $args"; $(which echo) "UserParameter=$ikey,$cache $lock${ZAF_PLUGINS_DIR}/$2/${iscript}.sh $args";
continue; continue;
fi fi
zaf_err "Item $i declared in control file but has no Cmd, Function or Script!" zaf_err "Item $i declared in control file but has no Cmd, Function or Script!"