IDM Driver Status Script

0 Likes

I am working towards implementing IDM 4 into my environment. I found that on one of my servers, the driver had stopped without my knowledge. So I decided to write a bash script to check the status of the driver, restart it if needed, and email whenever the status of the driver changes.



Create the folder /var/opt/novell/scripts Copy the chkdriver.sh script into the directory, edit the variables as indicated in the script (#edit me comment) and set the permissions so it can be executed.



On line 7, that is a reminder note to add the ip address of your SMTP server to the /etc/mail.rc file so the script can send notifications...




#!/bin/bash

admin="admin.tree" #edit me
password="secret" #edit me
dxml_driver="driver-name.context.tree" #edit me

#add "set smtp=smtp.ip.add.ress" to /etc/mail.rc file so the script can send email

email_to="network.admin@mydomain.com" #edit me
email_body="/var/opt/novell/scripts/idm_driver_status.msg" #edit me

dxcmd_output=`/opt/novell/eDirectory/bin/dxcmd -user $admin -password $password -getstate $dxml_driver`
dxml_drvstate=$?
case $dxml_drvstate in
0) #stopped
echo -n "Driver state 0 - Stopped"
email_subj="IDM Driver $dxml_driver has STOPPED"
echo `! date` " - IDM Driver $dxml_driver status: Stopped... Attempting to restart driver $dxml_driver" >$email_body
dxcmd_output=`/opt/novell/eDirectory/bin/dxcmd -user $admin -password $password -start $dxml_driver`
/bin/mail -s "$email_subj" "$email_to" < $email_body
;;
1) #starting
echo -n "Driver state 1 - Starting"
email_subj="IDM Driver $dxml_driver is STARTING"
echo `! date` " - IDM Driver $dxml_driver status: Starting... Please check the server" >$email_body
/bin/mail -s "$email_subj" "$email_to" < $email_body
;;
2) #running
if grep -q -i running /var/opt/novell/scripts/idm_driver_status.msg
then
echo -n "No Change in Driver state 2 - Running"
echo ""
else
echo -n "Driver state 2 - Running"
email_subj="IDM Driver $dxml_driver is RUNNING"
echo `! date` " - IDM Driver $dxml_driver status: Running" >$email_body
/bin/mail -s "$email_subj" "$email_to" < $email_body
fi
;;
3) #stopping
echo -n "Driver state 3 - Stopping"
email_subj="IDM Driver $dxml_driver is STOPPING"
echo `! date` " - IDM Driver $dxml_driver status: Stopping... Please check the server" >$email_body
/bin/mail -s "$email_subj" "$email_to" < $email_body
;;
esac

Tags:

Labels:

How To-Best Practice
Collateral
Comment List
Related
Recommended