+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
+}
+
+