-function check_zabbix_schema_and_data()
-{
- schema_present=$( psql -U $ZABBIX_DB_USER $ZABBIX_DB_NAME -c "\d;" < /dev/null | grep hosts )
- if [ -z $schema_present ] ; then
- echo "... initial import can take SEVERAL minutes. please wait ..."
- if_present_load "/usr/local/zabbix/misc/create/schema/postgresql.sql"
- if_present_load "/usr/local/zabbix/misc/create/data/data.sql"
- if_present_load "/usr/local/zabbix/misc/create/data/images_pgsql.sql"
- ## TODO: update ZABBIX Server entry, "update hosts set status=0, host='MyPLC Server' where hostid=10017"
- fi
-}
-
-function check_zabbix_templates_and_import ()
-{
- # LOG IN
- COOKIE_FILE=/tmp/cookiejar.txt
- rm -f ${COOKIE_FILE}
- TEMPLATES_DIR=${MONITORPATH}/zabbix/templates
- curl -s --cookie $COOKIE_FILE --cookie-jar $COOKIE_FILE \
- --form "enter=Enter" \
- --form "name=Admin" \
- --form "password=zabbix" \
- "http://${PLC_MONITOR_HOST}/zabbix/index.php?login=1"
-
- deleted=$( grep 'deleted' $COOKIE_FILE )
- if [ -n "$deleted" ] ; then
- echo "Login to the zabbix web server failed!!!"
- return 1
- fi
-
- for file in ${TEMPLATES_DIR}/*.xml ; do
- # 0 - update , 1 - skip, 0 - add
- echo "############### IMPORTING $file" >> /var/log/monitor.log
- curl -s --cookie $COOKIE_FILE --cookie-jar $COOKIE_FILE \
- --form "config=1" \
- --form "import_file=@${file}" \
- --form "rules[host][exist]=0" \
- --form "rules[host][missed]=0" \
- --form "rules[template][exist]=0" \
- --form "rules[template][missed]=1" \
- --form "rules[item][exist]=0" \
- --form "rules[item][missed]=0" \
- --form "rules[trigger][exist]=0" \
- --form "rules[trigger][missed]=0" \
- --form "rules[graph][exist]=0" \
- --form "rules[graph][missed]=0" \
- --form "import=Import" \
- "http://${PLC_MONITOR_HOST}/zabbix/exp_imp.php" >> /var/log/monitor.log
- done
-}
-
-