Skip to content

Instantly share code, notes, and snippets.

@raphapr
Last active July 29, 2017 01:57
Show Gist options
  • Save raphapr/73414fb0fdfd1041f139d8ac9f80cbea to your computer and use it in GitHub Desktop.
Save raphapr/73414fb0fdfd1041f139d8ac9f80cbea to your computer and use it in GitHub Desktop.
Sends LDAP (389 DS) metrics to Librato
#!/bin/bash
# It sends LDAP (389 DS) metrics to Librato
# Install shellbrato:
# git clone https://github.com/djosephsen/shellbrato.git
# sudo cp -a shellbrato /opt
source /opt/shellbrato/shellbrato.sh
debug "shellbrato successfully sourced"
debug "curl is ${C}"
debug "jq is ${JQ}"
debug "queue file is ${QFILE}"
LBUSER=
LBTOKEN=
src="host"
metric_name="freeipa.ldap.monitor"
wait_secs=30
metrics=(
anonymousbinds
simpleauthbinds
strongauthbinds
currentconnections
totalconnections
entriessent
bytessent
bytesrecv
searchops
modifyentryops
inops
)
getLDAPMetrics()
{
printf "$query_output" | sed -n -e 's/^.*'"$1"': //p' | head -n 1
}
while true; do
now=$(date +%s)
query_output=$(ldapsearch -x -b "cn=Monitor")
for i in ${!metrics[*]}
do
metric_subname=${metrics[$i]}
metric_value=$(getLDAPMetrics ${metrics[$i]})
Q=$(queueCounter "${now}||${metric_name}.${metric_subname}||${metric_value}||${src}")
sendMetrics ${Q}
done
sleep ${wait_secs}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment