#
# monitoring indexer
#
check process indexer with pidfile /opt/bertin/mediacentric/var/run/mediacentric-indexer.pid
	start program = "/usr/sbin/service mediacentric-indexer start" with timeout 20 seconds
	stop program = "/usr/sbin/service mediacentric-indexer stop"
	if NOT EXIST for 2 times within 5 cycles
		then exec "/opt/bertin/mediacentric/bin/monit_alert.sh mediacentric-indexer KO"
	else if SUCCEEDED
		then exec "/opt/bertin/mediacentric/bin/monit_alert.sh mediacentric-indexer OK"

check program indexer_check_module_rabbitQ with path "/opt/bertin/mediacentric/bin/check_module_rabbitQ.sh mediacentric-indexer"
	if status = 1 for 3 cycles then exec "/opt/bertin/mediacentric/bin/restart_service.sh mediacentric-indexer 'no rabbit consumer'"

check file indexer_log with path /opt/bertin/mediacentric/logs/indexer.log
	if match "java.lang.OutOfMemoryError" then exec "/opt/bertin/mediacentric/bin/monit_alert_logs.sh mediacentric-indexer OutOfMemory" repeat every 1 cycle
	if match "Too many open files" then exec "/opt/bertin/mediacentric/bin/monit_alert_logs.sh mediacentric-indexer TooManyOpenFiles" repeat every 1 cycle
