#!/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