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 = "";
my $smtp=Net::SMTP->new($smtp_host, Timeout => 30, Debug => 1) or die "Could not create SNTP object";

#WorkForce Tree
$host = "";

#Production Tree
$host = "";

$host = "";

$host = "";

$host = "";

print "There are $linelen matching.\n";
print "\n\n";


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




  #anonymous bind

  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->datasend("Subject: $dn\n");
       $smtp->datasend("The driver has shutdown \n");
  foreach $entry ($result->all_entries) {
   $userentry = $result->pop_entry;
   $dn= $userentry->dn;
   $dn =~ s/,?(cn|ou|o)=/\./g;
 print "$dn state = $state\n";

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

© Micro Focus