0

I'm new to monit service. I want to execute select query if a application server goes down using monit. Configuration in /etc/monitrc is like:-

check host www.example.com with address www.example.com
       if failed port 80 protocol http 
       then exec /tmp/test.sh

and test.sh contains following with the permission of chmod a+x /tmp/test.sh

mysql -u root -p root
use database;
select * from tablename;

The monit service is not executing /tem/test.sh file. How can I do it using monit ?

1 Answers1

1

You need a Shebang and using the right parameters to the mysql-binary:

This should work:

#!/bin/bash
mysql -u root -p root database -e "SELECT * FROM table"
boppy
  • 476
  • 2
  • 5