Grepping failed connections from OpenLDAP log

July 2011


Connections lost are shown in the OpenLDAP log on lines of their own, not showing the IP of the host at the other end. They do show the connection number, and it has a corresponding line telling the server ACCEPTed it, and that line does show the IP. Now to get the IPs of hosts losing their connections...

  1. Grep the connection numbers of failed connection into patterns

    patterns now looks like:

    <snip>
    conn=15381
    conn=22922
    conn=15378
    conn=24178
    <snip>
    		

  2. Grep the connection ACCEPTs into ACCEPTS

    (Throw away part of the line to make subsequent greps faster.)

  3. Grep and sort (number of) failed connections from ACCEPTS using patterns

    [Note]Note

    Using a loop like this appears to be many orders of magnitude faster than using the -f option of grep.