From 7e6f876feb4934a84c50f98aa08a4d4a2435e93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Vysko=C4=8Dil?= <vyskocilpavel@muni.cz> Date: Tue, 13 Aug 2019 12:33:43 +0200 Subject: [PATCH] Added new script for ldap_status check --- README.md | 27 +++++++++++++++++++++++++++ ldap_status.sh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100755 ldap_status.sh diff --git a/README.md b/README.md index c0ce570..4baa6a3 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,33 @@ instanceName="" proxyDomainName="login.elixir-czech.org" </pre> +### ldap_status.sh +This script checks if the LDAP servers are accessible + +* Requirements: + * library *ldap-utils* + <pre> + apt-get install ldap-utils + </pre> +* Attributes to be filled: + <pre> + # LDAP username + user="" + + # LDAP password + password="" + + # Base dn of LDAP tree + basedn="" + + # eduPersonPrincipalName which will be searched + searchedIdentity="" + + # List of LDPA hostnames separated by space + # Included ldap:// or ldaps:// + hostnames="" + </pre> + ## List of plugins Plugins are located in /usr/lib/check_mk/plugins/ diff --git a/ldap_status.sh b/ldap_status.sh new file mode 100755 index 0000000..ef18c73 --- /dev/null +++ b/ldap_status.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# LDAP username +user="" + +# LDAP password +password="" + +# Base dn of LDAP tree +basedn="" + +# eduPersonPrincipalName which will be searched +searchedIdentity="" + +# List of LDPA hostnames separated by space +# Included ldap:// or ldaps:// +hostnames="" + +for hostname in $hostnames +do + if [[ -z $password ]]; then + ldapresult=$(ldapsearch -x -H $hostname -b $basedn "(eduPersonPrincipalNames=$searchedIdentity)" 2>&1) + else + ldapresult=$(ldapsearch -x -H $hostname -D $user -w $password -b $basedn "(eduPersonPrincipalNames=$searchedIdentity)" 2>&1) + fi + result=$? + if [[ $result == 0 ]]; then + echo "0 ldap_status-$hostname - OK" + else + echo "2 ldap_status-$hostname - $ldapresult" + fi +done -- GitLab