[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Monitoring OpenLDAP 1.2



>>>>> "Seth" == Seth Vidal <skvidal@phy.duke.edu> writes:

    >>  > I'd like to write/obtain a script that monitors slapd,
    >> checks response > time, and does something (sends me mail, for
    >> instance) when the response > time gets out of hand.  Anybody
    >> already done it?
    >> 
    >> Try Big Brother (www.bb4.com)

    Seth> try mon too: http://www.kernel.org/software/mon/

I have the problem that slapd (v1.2.11-1.sc) dies about once a month.

I execute this little perlscript once every five minutes:

(it's started like: 'check_slapd.pl slapd')

----- s n i p -----
#!/usr/bin/perl -w

$pid     = '';
$dummy   = '';
$PROCESS = '';
$DEBUG   = 0;

if( $ARGV[0] ) {
    $PROCESS = $ARGV[0];

    open(LIST, "/bin/ps axwww |");
    $dummy = <LIST>;

    print "Searching for $PROCESS...\n" if($DEBUG);

    while(<LIST>) {
	@ps_list = split;

	if( $ps_list[4] =~ /$PROCESS/ ) {
	    print "Found: $ps_list[4] (pid: $ps_list[0])\n" if($DEBUG);

	    $pid = $ps_list[0];
	}
    }

    if(! $pid) {
	print "Restarting slapd!!\n";
	exec("/etc/init.d/openldapd start");
    }
    
    #exit($pid);
} else {
    print "Usage: check_slapd <process>\n";
    exit( 0 );
}
----- s n i p -----

-- 
 Turbo     __ _     Debian GNU     Unix _IS_ user friendly - it's just 
 ^^^^^    / /(_)_ __  _   ___  __  selective about who its friends are 
         / / | | '_ \| | | \ \/ /   Debian Certified Linux Developer  
  _ /// / /__| | | | | |_| |>  <  Turbo Fredriksson   turbo@tripnet.se
  \\\/  \____/_|_| |_|\__,_/_/\_\ Stockholm/Sweden