{"id":807,"date":"2016-05-01T11:38:48","date_gmt":"2016-05-01T15:38:48","guid":{"rendered":"http:\/\/149.28.118.115\/?p=807"},"modified":"2016-05-01T11:38:48","modified_gmt":"2016-05-01T15:38:48","slug":"monitoring-wordpress-micro-ec2-aws-instance-with-prtg","status":"publish","type":"post","link":"https:\/\/www.postinger.com\/index.php\/2016\/05\/01\/monitoring-wordpress-micro-ec2-aws-instance-with-prtg\/","title":{"rendered":"Monitoring WordPress Micro EC2 AWS instance with PRTG"},"content":{"rendered":"<p>Postinger.com runs on a micro EC2 instance from amazon. Occasionally the database uses too much CPU, memory or iops and crashes. I&#8217;m sure I should be running on a instance with more resources. I&#8217;ve adjusted swap, memory usage and threads apache uses but still occasionally the database crashes.<br \/>\n<div id=\"attachment_809\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-809\" class=\"wp-image-809 size-large\" src=\"https:\/\/www.postinger.com\/wp-content\/uploads\/2016\/05\/Screen-Shot-2016-05-01-at-7.51.13-AM-1024x117.png\" alt=\"Screen Shot 2016-05-01 at 7.51.13 AM\" width=\"625\" height=\"71\" \/><p id=\"caption-attachment-809\" class=\"wp-caption-text\">this is the error<\/p><\/div><br \/>\n&#8220;Error establishing a database connection&#8221;<br \/>\nI 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.<br \/>\nAdd an HTTP Advanced Web Sensor, checking for a word that will appear on your wordpress page(the word &#8220;WordPress&#8221; is a good choice for this)<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-810 size-full\" src=\"https:\/\/www.postinger.com\/wp-content\/uploads\/2016\/05\/2016-05-01_1133.png\" alt=\"2016-05-01_1133\" width=\"664\" height=\"652\" \/><br \/>\nInstall the <a href=\"http:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/download.html\" target=\"_blank\" rel=\"noopener noreferrer\">puTTY msi<\/a> on your prtg server(or copy puTTY and plink.exe to it.<br \/>\nIn your Path to your PRTG install&#8217;s notification\\exe directory (E:\\PRTG Network Monitor\\Notifications\\EXE) Add a batch file with the following line:<\/p>\n<pre>echo yes | plink -ssh ec2-user@domain\u00a0-i e:\\path\\to\\key.ppk sudo shutdown -r now\n#echo yes, answers the prompt to trust the signature, <a href=\"http:\/\/docs.aws.amazon.com\/AWSEC2\/latest\/UserGuide\/putty.html\" target=\"_blank\" rel=\"noopener noreferrer\">the key is generated via\u00a0PuTTYgen\n<\/a><\/pre>\n<p>Add a notification to execute a program, select the batch file you saved in the above referenced path.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-811\" src=\"https:\/\/www.postinger.com\/wp-content\/uploads\/2016\/05\/2016-05-01_1136.png\" alt=\"2016-05-01_1136\" width=\"456\" height=\"418\" \/><br \/>\nAdd a state trigger referencing your notification and set the appropriate timing.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-813\" src=\"https:\/\/www.postinger.com\/wp-content\/uploads\/2016\/05\/2016-05-01_1139.png\" alt=\"2016-05-01_1139\" width=\"817\" height=\"315\" \/><br \/>\nThat 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\u00a0to restart the database or whatever else you see fit.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Postinger.com runs on a micro EC2 instance from amazon. Occasionally the database uses too much CPU, memory or iops and crashes. I&#8217;m sure I should be running on a instance with more resources. I&#8217;ve adjusted swap, memory usage and threads apache uses but still occasionally the database crashes. &#8220;Error establishing a database connection&#8221; I have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[7],"tags":[11,12,22,36],"class_list":["post-807","post","type-post","status-publish","format-standard","hentry","category-tech","tag-aws","tag-ec2","tag-prtg","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.postinger.com\/index.php\/wp-json\/wp\/v2\/posts\/807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.postinger.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.postinger.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.postinger.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.postinger.com\/index.php\/wp-json\/wp\/v2\/comments?post=807"}],"version-history":[{"count":0,"href":"https:\/\/www.postinger.com\/index.php\/wp-json\/wp\/v2\/posts\/807\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.postinger.com\/index.php\/wp-json\/wp\/v2\/media?parent=807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.postinger.com\/index.php\/wp-json\/wp\/v2\/categories?post=807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.postinger.com\/index.php\/wp-json\/wp\/v2\/tags?post=807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}