Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with customized notifications

Status
Not open for further replies.

pluscarden

Programmer
Jan 26, 2004
26
0
0
GB
I am running NW on a UNIX platform and have created a customized notification that will be invoked on Savegroup completion. This is what I have specified in the action field :

/usr/scripts/save_report.sh

The actual shell script (save_report.sh) contains the following :


#!/usr/bin/ksh

awk -f save_report.awk -

echo "script finished at $(date)" >> runreport


and the awk script itself contains the following :

BEGIN {
GROUP=""
}

/^NetWorker [Ss]avegroup/
{
GROUP=$4

if ( $0 ~ /All Succeeded/ ) {
print "" > "/home/"GROUP".ok"
exit
}

if ( $0 ~ / 0 Hostname/ && $0 ~ / 0 Failed/ && $0 !~ /aborted/ )
{
print "" > "/home/"GROUP".ok"
exit
}

{
if ( GROUP != "" ) {
print $0 >> "/home/"GROUP".notok"
}
}
The general idea is that, providing the Savegroup Notification's header line doesn't contain any fail messages, a dummy file containing the group name and the extension '.ok' will be produced. Otherwise, the entire report will be written to a file (line by line) consisting of the group name and the extension '.not ok'.

My problem is that it doesn't seem to work!

I know that the shell script is definitely getting called because there are entries in the 'runreport' file.

I am assuming the notification process passes the Savegroup Completion Message to the program specified in the action field via standard input (?). Consequently, I would have thought that the awk script would automatically read it from there. I did add the '-' at the end of the awk command to ensure it definitely reads from standard input.

Can anyone see what I am doing wrong? Is there something else I need to specify in the action field to ensure the Savegroup Notification message gets passed to my shell script?







 
P.S. I have also tested the script on the command line by catting the contents of a savegroup notification message to it :

cat savegrpnotice | save_report.sh

and this works fine.

So, as stated above, the problem seems to be that my script isn't being passed anything from the notification process.

Am also assuming the header line does begin with the text 'NetWorker..." since this is how it looks in the e-mails sent to root (also via the notification process).
 
In your script and your awk file, specify the full path for your file names... for example:

awk -f /usr/scritps/save_report.awk

It seemed to work for me... though I got a core dump in the end...
 
thanks...I will try that and let you know how I get on. Any ideas what caused your core dump (just in case I have the same prob)?
 
no... I didn't spend too much time on it... and it's beena while since i had to look at a core dump. :)
 
My script now seems to work okay. Thanks for that.

However, I have been playing around with an alternative method (which I would prefer to the awk) but this also seems to be giving me probs. Instead of calling the awk script I tried using the following in my UNIX script :

#!/usr/bin/ksh

GROUP=""

while read LINE
do
if [ "${GROUP}" != "" ]
then
echo ${LINE} >> ${REP}
else
if [ "$(echo ${LINE}|grep '^NetWorker [Ss]avegroup')" ]
then
GROUP=$(echo ${LINE}|awk '{g=$4;gsub("[[:punct:]]","",g);print g}')
if [ "$(echo ${LINE} | grep 'All Succeeded')" ] || [ "$(echo ${LINE} | grep -v 'aborted' | grep ' 0 Failed' | grep ' 0 Hostname')" ]
then
REP=/home/${GROUP}.ok
touch ${REP}
break
else
REP=/home/myrep/${GROUP}.notok
echo ${LINE} > ${REP}
fi
fi
fi
done

The general idea is the same. A successful backup will result in an empty file being created consisting of the group name and the extension 'ok'. Otherwise, a file containing the contents of the Savegroup Completion Message and the extension 'notok' will be created.

The problem seems to be that the conditions involving the grep commands are not being evaluated as expected. The net result is that nothing happens!

I have run the script on the command line and it works fine. Just seems to be when it is called by the Notification system that it doesn't work.

Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top