Cloud Watch Custom metrics for monitoring Apache Workers

31 / May / 2014 by abhishek.tomar 0 comments

In my last blog, I shared how to setup custom Cloud Watch metrics for memory and disk usage. In this blog, I’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 “Busy Workers” and “Idle Workers” .

Steps to monitor the Workers are as follows

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.

 #!/bin/bash

# First we will take the instance id.
 INSTANCE_ID=$(curl 

# In our next two Variable we are saving our Busy and Idle workers
 BUSYWORKERS=`wget -q -O - http://localhost/server-status?auto | grep BusyWorkers | awk '{ print $2 }'`
 IDLEWORKERS=`wget -q -O - http://localhost/server-status?auto | grep IdleWorkers | awk '{ print $2 }'`

# Following commands will put the Busy and Idle worker to Cloud Watch
 /usr/local/bin/aws cloudwatch put-metric-data --metric-name "httpd-BusyWorkers" --unit Count --value $BUSYWORKERS --dimensions InstanceId=$INSTANCE_ID --namespace EC2:HTTP-Apache
/usr/local/bin/aws cloudwatch put-metric-data --metric-name "httpd-IdleWorker" --unit Count --value $IDLEWORKERS --dimensions InstanceId=$INSTANCE_ID --namespace EC2:HTTP-Apache

* * * * * /opt/mon-script/monapachestatus.sh

The above command will push the data to cloud watch every minute.

FOUND THIS USEFUL? SHARE IT

Leave a Reply

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