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

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

check file core_log with path /opt/bertin/mediacentric/logs/core.log
	if match "java.lang.OutOfMemoryError" then exec "/usr/sbin/service mediacentric-core restart" repeat every 1 cycle
	if match "Too many open files" then exec "/usr/sbin/service mediacentric-core restart" repeat every 1 cycle
	
