Monitoring WordPress Micro EC2 AWS instance with PRTG

Postinger.com runs on a micro EC2 instance from amazon. Occasionally the database uses too much CPU, memory or iops and crashes. I’m sure I should be running on a instance with more resources. I’ve adjusted swap, memory usage and threads apache uses but still occasionally the database crashes.

Screen Shot 2016-05-01 at 7.51.13 AM

this is the error

“Error establishing a database connection”

I have a PRTG instance running at home monitoring my internal network. I know PRTG has the ability to check for a word from an external webpage. So here is the solution.

Add an HTTP Advanced Web Sensor, checking for a word that will appear on your wordpress page(the word “WordPress” is a good choice for this)

2016-05-01_1133

Install the puTTY msi on your prtg server(or copy puTTY and plink.exe to it.

In your Path to your PRTG install’s notification\exe directory (E:\PRTG Network Monitor\Notifications\EXE) Add a batch file with the following line:

echo yes | plink -ssh [email protected] -i e:\path\to\key.ppk sudo shutdown -r now
#echo yes, answers the prompt to trust the signature, the key is generated via PuTTYgen

Add a notification to execute a program, select the batch file you saved in the above referenced path.

2016-05-01_1136

Add a state trigger referencing your notification and set the appropriate timing.

2016-05-01_1139

That should do it. My batch file restarts the whole instance which for me is fine, but you may want to tweak the batch file only to restart the database or whatever else you see fit.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.