check_ELBinstance : Nagios Plugin to check instances attached with ELB

Recently I created a new nagios plugin which check the no. of instances attached in ELB (Elastic Load Balancer) . Here we are talking about ELB in AWS (Amazon Web Service) Cloud. Elastic Load Balancing automatically distributes incoming application traffic across multiple Amazon EC2 instances in the cloud.

Details of check_ELBinstance nagios plugin

Requirement : To check no. of desired instances attached in ELB. If no. of instances count does’nt match then send the alert (Critical)
By this way we can monitor, if desired number of instances in ELB increased or decreased in number.

Scripting : Bash scripting is used for creating the check_ELBinstance nagios plugin.


Install aws command line interface on Nagios Server. It requires Python 2.6.5 or higher.
Run the below given command –

pip install awscli

Download check_ELBinstance

You can download this plugin and do changes as per your requirement.
I have saved this nagios plugin in github. The given below is the link

In either way you can create a file in nagios plugin directory on Nagios Server. And copy paste the below given contents.

# Author : Sharad Kumar Chhetri
# Date Of Creation : 1-Nov-2014
# Version  : 1.0
# Description : It checks the no. of instances available in ELB . When the instances count do not matches as per desire value it will send alert.
# Blog :

### Supportive URL : ###


#### For getting Region infromation,Reference URL:


## In ELB_NAME - Provide name of ELB


## In INSTANCE_COUNT give the value of desired number of Instances should be in ELB


## The ELB_INSTANCE_COUNT gives output of no. of  instances attached in ELB
ELB_INSTANCE_COUNT=$(aws --region $REGION elb describe-load-balancers --load-balancer-names $ELB_NAME --output text|grep INSTANCES|wc -l)

echo "OK: Total no. of instances $ELB_INSTANCE_COUNT found in ELB $ELB_NAME"
exit 0
echo "CRIT: Number of instances in ELB $ELB_NAME do not matches with desired value"
exit 2






5 responses to “check_ELBinstance : Nagios Plugin to check instances attached with ELB”

  1. Nishith N.Vyas Avatar
    Nishith N.Vyas

    Can we monitor AWS ALB using this command? My command output is as mentioned below.


    An error occurred (LoadBalancerNotFound) when calling the DescribeLoadBalancers operation: There is no ACTIVE Load Balancer named ‘test-alb’
    CRIT: Number of instances in ELB test-alb is 0,which do’nt matches with desired value i.e 2

    The AWS Access Key & Secret Access Keys are okay.

  2. Benjamin John Avatar
    Benjamin John

    This one worked great. Do you have any other Nagios-AWS plugins?

    1. Nishith N.Vyas Avatar
      Nishith N.Vyas

      Have you configured ELB/CLB or ALB?

  3. prem Avatar

    showing ok on the command line but showing critical on nagios we interface ..
    please help

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: