Introduction

Starting with the new version of GreenLight (2.9.6) you can use the new Sensor called "Linux Shell Script" Sensor to perform individual checks. One of the best examples is for instance a LDAP query check.

With the following example you will see how easy it is to configure such a check. The check performs a ldap connection followed by a user query.

Configuration

  • Make sure that ldapsearch is available on your GreenLight Appliance box (download the ldap-utils.deb and install it with the sudo dpkg -i command)
  • Create a ShellScript with the following content and store it in the following path /opt/panagenda/scripts/gl_sensor

#!/bin/sh
TIME_START=$(($(date +%s%N)/1000000))
LDAPRESULT=`ldapsearch -x -H ldap://"$1" mail="$3" | grep "# numEntries:" | awk '{print $3}'`
TIME_DONE=$(($(date +%s%N)/1000000))

if [ "$LDAPRESULT" -gt "0" ]
        then
                echo ldap.query.successful:1
                echo ldap.query.time_ms:$(($TIME_DONE - $TIME_START))
        else
                echo ldap.query.successful:0
                echo ldap.query.time_ms:$(($TIME_DONE - $TIME_START))
fi


Note: If you need to authenticate to your ldap server, please adjust the following line:

#LDAPS and authentication  
LDAPRESULT=`ldapsearch -x -H ldaps://"$1" -D <user> -w <password> -s sub "$3" | grep "# numEntries:" | awk '{print $3}'`

(of course you could put username /password to the parameter fields in the UI and to set $4 and $5 in the script)


In belows example i want to query for a particular internet mail address


  • Add your LDAP server as a target server


  • Save / Close and Execute the Sensor


The Output will be the following


So you get valuable information if the object was found successfully AND how long the Query was running to get the object.

With this Information you can build for instance the following graph



Conclusion

The Linux Shell Script Sensor is a powerful sensor! It is one of the most flexible Sensors GreenLight offers.

Using this sensor enables you to create specific requests Of course, there are plenty of other use cases conceivable, where this Sensor can help you with. (e.g Nagios)