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.

Revisions

  1. raphapr revised this gist Jun 13, 2017. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion ldap_send_metrics.sh
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,6 @@ debug "curl is ${C}"
    debug "jq is ${JQ}"
    debug "queue file is ${QFILE}"


    LBUSER=
    LBTOKEN=

  2. raphapr revised this gist Jun 13, 2017. 1 changed file with 15 additions and 6 deletions.
    21 changes: 15 additions & 6 deletions ldap_send_metrics.sh
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,25 @@
    #!/bin/bash

    source /opt/shellbrato/shellbrato.sh
    # It sends LDAP (389 DS) metrics to Librato

    LBUSER=
    LBTOKEN=
    # 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
    @@ -36,10 +45,10 @@ while true; do
    query_output=$(ldapsearch -x -b "cn=Monitor")
    for i in ${!metrics[*]}
    do
    metric_name=${metrics[$i]}
    metric_subname=${metrics[$i]}
    metric_value=$(getLDAPMetrics ${metrics[$i]})
    Q=$(queueCounter "${now}||freeipa.ldap.monitor.${metric_name}||${metric_value}||${src}")
    Q=$(queueCounter "${now}||${metric_name}.${metric_subname}||${metric_value}||${src}")
    sendMetrics ${Q}
    done
    sleep 30
    sleep ${wait_secs}
    done
  3. raphapr created this gist Jun 13, 2017.
    45 changes: 45 additions & 0 deletions ldap_send_metrics.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    #!/bin/bash

    source /opt/shellbrato/shellbrato.sh

    LBUSER=
    LBTOKEN=

    debug "shellbrato successfully sourced"
    debug "curl is ${C}"
    debug "jq is ${JQ}"
    debug "queue file is ${QFILE}"

    src="host"

    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_name=${metrics[$i]}
    metric_value=$(getLDAPMetrics ${metrics[$i]})
    Q=$(queueCounter "${now}||freeipa.ldap.monitor.${metric_name}||${metric_value}||${src}")
    sendMetrics ${Q}
    done
    sleep 30
    done