Differences between revisions 2 and 3
Revision 2 as of 2009-09-18 20:38:14
Size: 3471
Editor: ahasenack
Comment:
Revision 3 as of 2009-09-18 20:44:57
Size: 4359
Editor: ahasenack
Comment:
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
Some sample scripts that plot LDAP related information. Most rely on the server being a recent enough version of OpenLDAP (the version tested was 2.4.18) and with the `cn=monitor` backend enabled. Some sample scripts that plot LDAP related information. Most rely on the server being a recent enough version of OpenLDAP (the version tested was 2.4.18) and with the `cn=monitor` backend enabled. To learn more about this backend please consult the slapd-monitor(5) manpage.
Line 12: Line 12:
This script counts the number of successful bind operations that were completed within 5min and calculates the per second average. If your server is very lightly used, you will get very low numbers here. You may divide by 60 then (one minute) instead of 5 to get the number of binds per minute.
Line 56: Line 57:
This script counts the number of search operations that were completed within 5min and calculates the per second average. If your server is very lightly used, you will get very low numbers here. You may divide by 60 then (one minute) instead of 5 to get the number of searches per minute.
Line 100: Line 102:
Here we count the number of active connections to the slapd service. Note this script will output the number of connections it reads at the time it is run.
Line 123: Line 126:
This script outputs the uptime of the OpenLDAP service, in hours.

Examples for Custom Graphs

Here in this page we collect a few sample scripts to be used with Custom Graphs.

LDAP

Some sample scripts that plot LDAP related information. Most rely on the server being a recent enough version of OpenLDAP (the version tested was 2.4.18) and with the cn=monitor backend enabled. To learn more about this backend please consult the slapd-monitor(5) manpage.

The scripts consider that access to the information at cn=monitor is restricted and attempts to bind as an example user. Please adjust the user and password to your needs. If anonymous searches are allowed, then just drop the -D "$binddn" -w "$bindpw" parameters from the ldapsearch command line.

LDAP binds/s

This script counts the number of successful bind operations that were completed within 5min and calculates the per second average. If your server is very lightly used, you will get very low numbers here. You may divide by 60 then (one minute) instead of 5 to get the number of binds per minute.

# YOU NEED TO ADJUST THESE TWO
binddn="uid=ldap monitor,ou=system accounts,dc=example,dc=org"
bindpw="ldapmonitor"

basedn="cn=Bind,cn=Operations,cn=Monitor"
attr="monitorOpCompleted"
# 5 minutes
interval=$((5 * 60))
oldfile=/tmp/old-binds.dat

function calc() {
    echo "scale=2; $1" | bc
}

if [ -z "$(which ldapsearch)" ]; then
    echo "ERROR, please install ldap-utils"
    exit 1
fi

if [ -z "$(which bc)" ]; then
    echo "ERROR, please install bc"
    exit 1
fi


binds=$(ldapsearch -x -D "$binddn" -w "$bindpw" -b "$basedn" "$attr" | grep -E ^"$attr" | awk '{print $2}')
if [ -z "$binds" ]; then
    echo "ERROR, no binds returned"
    exit 1
fi

[ -f "$oldfile" ] && old=`cat $oldfile`

curr="$binds"

if [ -z "$old" ]; then
    old=$curr
fi
echo $curr > $oldfile
calc "($curr-$old)/$interval"

LDAP searches/s

This script counts the number of search operations that were completed within 5min and calculates the per second average. If your server is very lightly used, you will get very low numbers here. You may divide by 60 then (one minute) instead of 5 to get the number of searches per minute.

# YOU NEED TO ADJUST THESE TWO
binddn="uid=ldap monitor,ou=system accounts,dc=example,dc=org"
bindpw="ldapmonitor"

basedn="cn=Search,cn=Operations,cn=Monitor"
attr="monitorOpCompleted"
# 5 minutes
interval=$((5 * 60))
oldfile=/tmp/old-searches.dat

function calc() {
    echo "scale=2; $1" | bc
}

if [ -z "$(which ldapsearch)" ]; then
    echo "ERROR, please install ldap-utils"
    exit 1
fi

if [ -z "$(which bc)" ]; then
    echo "ERROR, please install bc"
    exit 1
fi


binds=$(ldapsearch -x -D "$binddn" -w "$bindpw" -b "$basedn" "$attr" | grep -E ^"$attr" | awk '{print $2}')
if [ -z "$binds" ]; then
    echo "ERROR, no binds returned"
    exit 1
fi

[ -f "$oldfile" ] && old=`cat $oldfile`

curr="$binds"

if [ -z "$old" ]; then
    old=$curr
fi
echo $curr > $oldfile
calc "($curr-$old)/$interval"

LDAP active connections

Here we count the number of active connections to the slapd service. Note this script will output the number of connections it reads at the time it is run.

# YOU NEED TO ADJUST THESE TWO
binddn="uid=ldap monitor,ou=system accounts,dc=example,dc=org"
bindpw="ldapmonitor"

basedn="cn=Current,cn=Connections,cn=Monitor"
attr="monitorCounter"

if [ -z "$(which ldapsearch)" ]; then
    echo "ERROR, please install ldap-utils"
    exit 1
fi

data=$(ldapsearch -x -D "$binddn" -w "$bindpw" -b "$basedn" "$attr" | grep -E ^"$attr" | awk '{print $2}')
if [ -z "$data" ]; then
    echo "ERROR, no data returned"
    exit 1
fi

echo "$data"

slapd uptime

This script outputs the uptime of the OpenLDAP service, in hours.

# YOU NEED TO ADJUST THESE TWO
binddn="uid=ldap monitor,ou=system accounts,dc=example,dc=org"
bindpw="ldapmonitor"

basedn="cn=Current,cn=Connections,cn=Monitor"
attr="monitorCounter"

if [ -z "$(which ldapsearch)" ]; then
    echo "ERROR, please install ldap-utils"
    exit 1
fi

data=$(ldapsearch -x -D "$binddn" -w "$bindpw" -b "$basedn" "$attr" | grep -E ^"$attr" | awk '{print $2}')
if [ -z "$data" ]; then
    echo "ERROR, no data returned"
    exit 1
fi

echo "$data"

CustomGraphs/Examples (last edited 2010-11-23 09:50:37 by ahasenack)