Novell Home

Identifying Down Drivers in DirXML

Novell Cool Solutions: Tip

Digg This - Slashdot This

Posted: 9 Sep 2004
 

Sometimes the cause of a DirXML problem is that one or more drivers are shut down. So wouldn't it be nice to know right when that happens, rather than way after the fact? Thanks to this tip sent in by Chad, one of our DirXML readers, now you can. Here's the scoop:

Identifying Down Drivers

At a client's site I had been synchronizing a production eDirectory tree (5 drivers) with a WorkForce tree (1 driver) using DirXML. Sometimes by chance I would find that the drivers were shut down, or I would find out when users complained (imagine that) that their eGuide information wasn't updating. I needed to identify when drivers were down.

So, I wrote a PERL script to check the driver status via LDAP and email the DirXML admin (me) if there was a problem. The script was added to the Crontab process and runs on the hour from 7 a.m. to 5 p.m. from Monday through Friday.

The PERL Script


#!/usr/bin/perl # dxml.pl
# add to crontab: 0 7-17 * * 1-5 perl --autodestroy dxml.pl
# runs on the hour from 7am - 5pm Mon-Friday. --autodestroy causes the perl script to exit quietly.
# Program makes anonymous ldap call to server that holds master replica of dirxml partition
# and checks if the driver is running and sends mail if it is not.
# ncisrael@myrealbox.com
#

use Net::LDAP;
use Time::Local;
use Net::SMTP;

# Create email information
$returnemail="LA DIRXML";
#create an object
my $smtp_host = "172.20.10.20";
my $smtp=Net::SMTP->new($smtp_host, Timeout => 30, Debug => 1) or die "Could not create SNTP object";

#WorkForce Tree
$host = "172.20.4.252";
$baseDN="o=la";
&veify($host,$returnemail,$baseDN);

#Production Tree
$host = "172.29.4.252";
$baseDN="ou=DirXML,ou=north,o=la";
&veify($host,$returnemail,$baseDN);

$host = "172.30.5.252";
$baseDN="ou=DirXML,ou=south,o=la";
&veify($host,$returnemail,$baseDN);

$host = "172.35.4.252";
$baseDN="ou=DirXML,ou=east,o=la";
&veify($host,$returnemail,$baseDN);

$host = "172.34.5.252";
$baseDN="ou=DirXML,ou=west,o=la";
&veify($host,$returnemail,$baseDN);

print "There are $linelen matching.\n";
print "\n\n";
#$smtp->quit;


#**************************************************************************

sub veify {
 my($host, $returnemail, $baseDN) = @_;

  $ldapuser="anonymous";

  $ldap_filter="objectclass=DirXML-Driver";
  @attribs=["DirXML-State"];


  $ldap=Net::LDAP->new($host);

  #anonymous bind
  $ldap->bind(dn=>$ldapuser);

  my $result=$ldap->search(base => $baseDN, scope => "sub", filter => $ldap_filter, attrs => @attribs) or die "LDAP Error ", ldap_error_name($result->code);
  my @entries = $result->entries;
  my $linelen = @entries;
  foreach $entry ($result->all_entries) {
   $userentry = $result->pop_entry;
   @dirstate = $userentry->get('DirXML-State');
   $state = $dirstate[0];
   $dn= $userentry->dn;
   $dn =~ s/,?(cn|ou|o)=/\./g;
   print "$dn state = $state\n";
  if ($state ne "2") {
   print "driver is off\n";
     $smtp->mail("$returnemail");
       $smtp->to("ncisrael@myrealbox.com");
       $smtp->data();
       $smtp->datasend("Subject: $dn\n");
       $smtp->datasend("\n");
       $smtp->datasend("The driver has shutdown \n");
         $smtp->dataend();
   }
  }
  foreach $entry ($result->all_entries) {
   $userentry = $result->pop_entry;
   $dn= $userentry->dn;
   $dn =~ s/,?(cn|ou|o)=/\./g;
 print "$dn state = $state\n";
  }
  $ldap->unbind;
}


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell