Nagios Plugin - Check if LDAP attribute exist
- Simply put the nagios plugin check_ldap_request.pl in your nagios-plugins directory
- Install the perl module using cpan (install Net::LDAP)
define command{
command_name check_ldap_request
command_line$USER2$ /check_ldap_request.pl -H$HOSTADDRESS$ -b "dc=ldap,dc=company,dc=lan" -f "uid=pmavro"
}
define service{
use generic-services
hostgroup_name ldapsrv
service_description LDAP request check
check_command check_ldap_request
}
Usage : ./check_ldap -H hostname -b base -f filer [-s scope] [-h]
-H : LDAP server hostname or IP
-b : Base of LDAP server (ex: "dc=ldap,dc=company,dc=lan")
-f : Specify a filter (ex: "uid=pmavro")
-s : LDAP Scope (ex: sub)
-h : Print this help message
$ ./check_ldap_request.pl -H prd-ldap-srv -b "dc=openldap,dc=mycompany,dc=com" -f "uid=pmavro"
LDAP request OK - 'uid=pmavro' exists
$ ./check_ldap_request.pl -H prd-ldap-srv -b "dc=openldap,dc=mycompany,dc=com" -f "cn=foo"
LDAP request CRITICAL - unable to find 'cn=foo'