How do I achieve this in bash scripting or python?

if glassfish_domain_down then exec "/path/to/script"
This is what I am planning to do.(In monit)

But how do I check if glassfish domain is down?

Here's one way:

checking if glassfish domain is down?

Step 1) Say domain_i_want_to_monitor is the domain I want to monitor and if it's down, it'll be saved to output.txt
./asadmin list-domains| grep 'not'| grep 'domain_i_want_to_monitor'> output.txt

Step 2)
connect to database at IP,Port,Username,Password

Step 3)
write an insert query in database.

Step 4)
exit

How do I incorporate all of these things in a single script?

@Ihattaren , what commands have you actually tried ? ,
Surely just typing 'suggested' commands and seeing the results/checking exit status etc would allow you to determine what is needed. Reading some documentation/asking-colleagues would help - ie do some basic 'research' before asking for someone else to do the basics for you !.

So, unless I'm missing something this seems a trivial task .

NB: i have no access to this tool

1 Like

I dont fully get what you want to do, but you can fully automate MySQL queries with SSH like so:

ssh -i user@example.com "echo 'SHOW TABLES;' | mysql -u mysql_user -pmysql_pw database_name"
1 Like