VMware Cloud Community
grandview
Contributor
Contributor

VDR email notifications working...

We've managed to get email notifications working from our VDR installation (1.1.0.707). It certainly is not the most elegant solution; but I am hoping by sharing it with the community that it can be made much better.

There is an MTA running in the VDR; but I had no idea what the ramifications of configuring it would be. So we went a much simpler route.

I installed the telnet (telnet-0.17-39.el5.x86_64.rpm); and wrote a script to compare the prior list of logged errors found to the current list of errors found. A cron job runs every 15 minutes and an email is sent (via telnet) when new error messages are found.

I have attached our shell script and the rpm to this posting for your review. Please be gentle 8^)

Tags (4)
Reply
0 Kudos
137 Replies
mcretan
Contributor
Contributor

That's a nice tip, thanks for sharing.

FYI, You can also install telnet with:

yum -y install telnet

from the VDR command line.

Cheers,

Mike

Reply
0 Kudos
jim3cantos
Contributor
Contributor

"Basic" Reporting working.

Thank you for sharing!

Reply
0 Kudos
kcucadmin
Enthusiast
Enthusiast

why couldn't VMWare include somthing this simple in the wizard. how hard could it be to pass a few variables into a shell script...

i understand it's "New", and i understand they dont want to tread on thier partners business model. but i shouldn't have to pay upwards of 25k for a solution that can email reports...

Reply
0 Kudos
woisch
Contributor
Contributor

Hi, this is a good script but at the moment it only shows in the email

VDR Errors: <number>

I`m not a shell script guru but it is possible to get the complete error message in the mail and not only how many errors in the job?

By the way kcucadmin, i also ask me why vmware not implement a email function for data recovery.... in my opinion it is important

Reply
0 Kudos
jim3cantos
Contributor
Contributor

...after playing for a while with awk, adding this to the message seems to produce a "more or less" descriptive message of the errors:

strings -e l /var/vmware/datarecovery/operations_log.utx | grep -i "error" | awk -F"$" '{print substr($2,5, 30) substr($3, 9, 100) substr ($6, 17, 30) $8}'

sleep 1

The only problem is that the list of errors will be accumulative if the error log is not cleared. A improvement could be to clear the log from the script.

Also, the script will fail first time because file olderror.out doesn't exist. I think adding:

cat /dev/null >> /root/olderror.out

..at beginning of the script will work for that. See new attached vdralert.sh.

Also is important to don't try to correct "HELO" for "HELLO". Smiley Happy

Reply
0 Kudos
RParker
Immortal
Immortal

i understand they dont want to tread on thier partners business model. but i shouldn't have to pay upwards of 25k for a solution that can email reports...

excellent point!

Reply
0 Kudos
jim3cantos
Contributor
Contributor

Hello,

attached is new vdralert.sh version with number and short description of (only) new errors. No need to clear log.

Reply
0 Kudos
vmbru
Enthusiast
Enthusiast

We couldn't get the above to work so here is what we did (tweak of previous posts, installed mutt too, not as pretty, hopefully Azmir at Vmware can fix and give us email notification and faster integrity scanning in version 2.0 in 2011):

#vdralert5.sh

#SCRIPT TO CLEANU UP utx file then PARSE new LOG FILE AND CREATE ERROR ONLY LOG then email.

#!/bin/bash

  1. Find all errors

strings -el operations_log.utx > pre_errors.log

grep -B1 error pre_errors.log > errors.txt

  1. Send email with any errors found

mutt -s "Daily VDR Error Report attached please review" -a errors.txt youremail@yourdomain.com < /dev/null

exit 0

...then just add to cron

Reply
0 Kudos
woisch
Contributor
Contributor

could you pls post the whole script?

Reply
0 Kudos
vmbru
Enthusiast
Enthusiast

Here are 2 scripts to use.

The original script for this thread did not work for us as we never got the email because the diff code wasn't working. Maybe someone can tweak and get a decent script that shows new errors only and show the VM that failed, my script shows the error line and the VM name. Not a CentOS guru by any means, but know enough to be dangerous. Used the grep command -B1 to go back 1 line to grab the VM name. Hope this helps.

I put all my code in the /var/vmware/datarecovery folder.

Script1 is original code but added -B1 and commented out diff code as it would not work for us.

Script2 shows a bit more info but not as clean as 1.

Reply
0 Kudos
vmbru
Enthusiast
Enthusiast

Oh..for newbies out there...as far as the best best destination, do not use CIFS/SMB, try to first use VMFS/iSCSI (with a replicated SAN offsite) or NFS.

Reply
0 Kudos
woisch
Contributor
Contributor

Is it easy to implement a solution for sending also successful jobs?

Reply
0 Kudos
vmbru
Enthusiast
Enthusiast

Just use the word successful to the string. You might want to add Trouble as well, this comes up when a backup fails if it is still running and backup window timeframe ends.

Reply
0 Kudos
vmbru
Enthusiast
Enthusiast

Take that back on the Trouble string, it already contains error in line, change -B1 to -B2 to get vm name in that case.

Reply
0 Kudos
ben13
Contributor
Contributor

Hello, thanks for the script but wanted to let everyone know I did have a bit of an issue with it at first. For some reason it would work but it would truncate anything after sending DATA though it did send the subject , basically I wouldn't get the body of the email. This was telnet session to an Exchange 2007 server if that makes the difference.

What I had to do was adjust the line following the subject to REMOVE the space between the quotes, see snippet below:

echo "data"

sleep 1

echo "subject: VDR Errors: "$err

sleep 1

echo "from: VDR"

sleep 1

echo "to:someone@test.com"

sleep 1

echo ""

sleep 1

echo " "

sleep 1

echo "VDR Errors: "$err

sleep 1

cat /root/diff.out

once I did that I was able to get the body of the email without issue. Also note I added a from and to header, just so the email didn't look like it went to noone (in outlook it wasshowing a blank for the to field) and it "pretties" up the from field to just show VDR.

EDIT To field was formatted wrong.

Thanks again!

Ben

Reply
0 Kudos
jim3cantos
Contributor
Contributor

Hello,

for us the script (with diff code) is working fine so far. For example this is the mail received today (only one mail per day in our case):

VDR Errors: 4

&gt; 2/26/2010 4:12:00 AM: Failed to create snapshot for SOHS_BACKUP[02], error -3960 ( cannot quiesce virtual machine)

&gt; 2/26/2010 4:42:34 AM: Failed to create snapshot for SOHS_BACKUP[02], error -3960 ( cannot quiesce virtual machine)

&gt; 2/26/2010 4:58:07 AM: Failed to create snapshot for BNA_BACKUP[02], error -3960 ( cannot quiesce virtual machine)

&gt; 2/26/2010 6:07:50 AM: Failed to create snapshot for XEN3[02], error -3960 ( cannot quiesce virtual machine)

...the only issue detected so far is that in some cases (e.g. "integrity check failure"), awk code doesn't capture correct description of the error (but an error message is received anyway). For VM errors the description is fine as seen above.

Reply
0 Kudos
vmbru
Enthusiast
Enthusiast

Can you re-post the corrected script? Testing with beta VDR 1.2 today. Thanks

Reply
0 Kudos
MKguy
Virtuoso
Virtuoso

You \[a customer\] can beta test the upcoming VDR version?

Very cool.

We still need to rely on homegrown scripts for something as basic as emailing errors in this next version?

Well, shit.

There goes my last remnant of hope to wait until the next vSphere/VDR release.

-- http://alpacapowered.wordpress.com
Reply
0 Kudos
vmbru
Enthusiast
Enthusiast

Yep, 1.2 working fine, although only been 18 hours so far. The email function is coming I have been told, probably not this year. Our main concern is to get something stable and reliable.

Reply
0 Kudos