Tuesday, December 17, 2013

Email Notification When Print Queue Is Down In Unix

www.unixbabuforum.inI need to check the print queue and immediately send an email notification to some users in Unix if the print queue is down. How can this be automated?


www.unixbabuforum.inThere are 2 ways to automate this. 

1) Use some monitoring tool 
2) Write a script to run certain time to check the status. Frequency could be based on how urgent and how important it is for you to trigger the alert to the user. 

Assuming that in your case Step 1 is not possible, I am going to give you a hint on how you could write a script. 

#!/usr/bin/ksh 

prtlist=/tmp/print_list.txt 
lpstat > $prtlist 

for i in `cat $prtlist | grep ":" | awk '{print $1}' | sort -u | cut -d':' -f1` 
do 
status=`lpstat -p$i | head -3 | tail -1 | awk '{print $3}'` 
if [ "${status}" != "READY" ] 
then 
mail -vs "Print queue $i is down `date`" " email@removed " 
fi 
done 

You could schedule this to run every 5 minutes or 15 minutes. Now that you have the idea go ahead use your own logic and enhance it and twist it according to your need. 

0 comments:

Post a Comment

 
Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM