{"id":14037,"date":"2014-05-31T22:58:24","date_gmt":"2014-05-31T17:28:24","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=14037"},"modified":"2016-12-19T15:02:53","modified_gmt":"2016-12-19T09:32:53","slug":"cloud-watch-custom-metrics-for-monitoring-apache-workers","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/cloud-watch-custom-metrics-for-monitoring-apache-workers\/","title":{"rendered":"Cloud Watch Custom metrics for monitoring Apache Workers"},"content":{"rendered":"<p>In my last blog, I shared how to setup custom Cloud Watch metrics for memory and disk usage. In this blog, I&#8217;ll discuss how to monitor Apache Worker connections in Cloud Watch.<\/p>\n<p>Few days back We got a requirement to monitor Apache Worker connections. For that We decided to use Cloud Watch to monitor the &#8220;Busy Workers&#8221; and &#8220;Idle Workers&#8221; .<\/p>\n<p>Steps to monitor the Workers are as follows<\/p>\n<p>Prerequisite : Running Apache\/HTTPD web server with the module mod_status. Installed Cloud Watch Monitoring API tools. Add the following script to crontab to automate the metrics transfer to Cloud Watch.<\/p>\n<pre> #!\/bin\/bash\r\n\r\n# First we will take the instance id.\r\n INSTANCE_ID=$(curl \r\n\r\n# In our next two Variable we are saving our Busy and Idle workers\r\n BUSYWORKERS=`wget -q -O - http:\/\/localhost\/server-status?auto | grep BusyWorkers | awk '{ print $2 }'`\r\n IDLEWORKERS=`wget -q -O - http:\/\/localhost\/server-status?auto | grep IdleWorkers | awk '{ print $2 }'`\r\n\r\n# Following commands will put the Busy and Idle worker to Cloud Watch\r\n \/usr\/local\/bin\/aws cloudwatch put-metric-data --metric-name \"httpd-BusyWorkers\" --unit Count --value $BUSYWORKERS --dimensions InstanceId=$INSTANCE_ID --namespace EC2:HTTP-Apache\r\n\/usr\/local\/bin\/aws cloudwatch put-metric-data --metric-name \"httpd-IdleWorker\" --unit Count --value $IDLEWORKERS --dimensions InstanceId=$INSTANCE_ID --namespace EC2:HTTP-Apache<\/pre>\n<p>* * * * * \/opt\/mon-script\/monapachestatus.sh<\/p>\n<p>The above command will push the data to cloud watch every minute.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my last blog, I shared how to setup custom Cloud Watch metrics for memory and disk usage. In this blog, I&#8217;ll discuss how to monitor Apache Worker connections in Cloud Watch. Few days back We got a requirement to monitor Apache Worker connections. For that We decided to use Cloud Watch to monitor the [&hellip;]<\/p>\n","protected":false},"author":90,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":29},"categories":[1174],"tags":[1262],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/14037"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/90"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=14037"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/14037\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=14037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=14037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=14037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}