]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/monitoring/plugins/check_openldap_replication
Squash changes containing private information
[perso/Immae/Config/Nix.git] / modules / private / monitoring / plugins / check_openldap_replication
diff --git a/modules/private/monitoring/plugins/check_openldap_replication b/modules/private/monitoring/plugins/check_openldap_replication
deleted file mode 100755 (executable)
index 7136ad5..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/bash
-
-STATE_OK=0
-STATE_WARNING=1
-STATE_CRITICAL=2
-STATE_UNKNOWN=3
-
-distant_host="$1"
-replication_dn="$2"
-replication_pw="$3"
-base="$4"
-config="$5"
-
-to_date() {
-  i="$1"
-  i=$(echo "$i" | grep contextCSN | cut -d":" -f2 | sed -e "s/\s//g")
-  i=$(echo "$i" | cut -d"#" -f1)
-  i=$(echo "$i" | cut -d"." -f1)
-  echo "$i"
-}
-
-# ldap
-remote_ldap=$(ldapsearch -H $distant_host -D "$replication_dn" -y "$replication_pw" -b "$base" -s base -LLL contextCSN )
-exit_code_remote=$?
-remote_ldap=$(to_date "$remote_ldap")
-
-# slapcat
-local_ldap=$(slapcat -b "$base" -f "$config" -a "(entryDN=$base)")
-exit_code_local=$?
-local_ldap=$(to_date "$local_ldap")
-
-offset=$(($remote_ldap - $local_ldap))
-
-if [[ $exit_code_remote -ne 0 || $exit_code_local -ne 0 ]]; then
-  echo "UNKNOWN - Impossible to run ldap command"
-  exit $STATE_UNKNOWN
-elif [[ -z "$offset" ]]; then
-  echo "UNKNOWN - No replication found"
-  exit $STATE_UNKNOWN
-else
-  output="Replication lag for openldap is ${offset}s"
-  LC_ALL=C lag=$(printf "%.*f" 0 $lag)
-
-  if [[ $offset -lt 5 ]]; then
-    echo "OK - $output | time=${offset}s;5;10;;"
-    exit $STATE_OK
-  elif [[ $offset -lt 10 ]]; then
-    echo "WARNING - $output | time=${offset}s;5;10;;"
-    exit $STATE_WARNING
-  else
-    echo "CRITICAL - $output | time=${offset}s;5;10;;"
-    exit $STATE_CRITICAL
-  fi
-fi