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
vmbru
Enthusiast
Enthusiast

Vdr 1.2 out now for all... sportsfans!

They are trying to get it stable, been ok for us.

Hopefully next version has email feature builtin and integrity check as a hidden background task that does not interfere.

I hope they try to support more then 1TB.

Reply
0 Kudos
Stevester
Contributor
Contributor

Good Day Everyone,

The vdr-reportv2 script is nice, but how do you filter so only the logs for the current day are sent, and NOT the entire logs? I am a newbie at bash scripting

Thanks

Stevester

Reply
0 Kudos
MattseG2
Enthusiast
Enthusiast

YFYI:

Hey Guys,

i upgraded to VDR 1.2 after patching our ESXs from 4.0.0 to 4.0.0u2.

Believe it or not: VDR 1.2 must have TELNET already installed.

Thats because i forgot the "yum -y install telnet" command and implemented e-mail-notifications like explained before in this thread.

By testing the vdrreport-script on the CLI, it worked without TELNET being installed to the VDR-appliance.

Greetings from good ole Germany

Reply
0 Kudos
Innuendo_
Contributor
Contributor

Hi everyone

the mailx way:

never configured exim before - where do i have to set up my internal mail server (exchange)? Is there any smallest/easiest config for exim sending only to ms exchange arround?

the telnet way:

vdralert is working on my test maschine, but latest vdrreport always says no jobs ?!?

regards

Innu

Reply
0 Kudos
Jelloir
Enthusiast
Enthusiast

You could use egrep and the date commands to filter certain date ranges/times from the ouput.

Try modifying the line beginning with $STRINGS to:

$STRINGS -e l $BINLOG | egrep -i "$(date -d 'yesterday' +'%-d/%-m/%Y')|$(date +'%-d/%-m/%Y')" \

This should only ouput yesterdays and todays logs. Obviously you need to ensure your VDR servers date is correct.

I have not tested this and you will probably need to change the date formats because I set the locale for our VDR server to D/M/YYYY instead of American Style with the month first.

If you just want today or yesterday only then you will need to remove one of the date commands from the egrep command but be aware that if your backup time window spans a day you may be missing stuff from the log.

Let me know if it works.

Reply
0 Kudos
vmbru
Enthusiast
Enthusiast

Anyone on vdr 1.2 yet? Seeing any weird integrity checks running at 50 percent with both numbers incrementing?

Sent from my Verizon Wireless BlackBerry

Reply
0 Kudos
Stevester
Contributor
Contributor

Good Day Jelloir,

Unfortuantely this is still not working. Mainly because your egrep command doesn't have a file specified to perform the match to. I created two variables: EGREP=bin/egrep and CURRENTDATE=`date +"%-m/%-d/%Y"` and performed the following substitution - $EGREP -i $CURRENTDATE $BINLOG \. However i still only the full output and not the current date matched.

Reply
0 Kudos
Jelloir
Enthusiast
Enthusiast

Hi Stevester,

I have tested this and fixed some errors, including removing the old /tmp/vdrlog*.txt

Attached is an updated version which should work as expected (double check your date format of course).

I'll leave it to you to add variables for date commands etc where you want.

Reply
0 Kudos
Jelloir
Enthusiast
Enthusiast

Hi Innuendo_,

Exim MTA on the VDR Server

Exim is already installed and running on VDR so edit Exim's config file to add the following settings

vi /etc/exim/exim.conf

Locate the line that reads "# qualify_domain =", uncomment it and edit it to (replace example.com with your FQDN):

qualify_domain = example.com

Then add this before “dnslookup:” in the Routers section (replace 10.1.1.2 with your relays/smarthosts IP or hostname)

to_smart_host:

driver = manualroute

+domains = ! local_domains

transport = remote_smtp

route_list = "* 10.1.1.2;"

Restart exim

service exim restart

Install mailx

yum install mailx

Reply
0 Kudos
Stevester
Contributor
Contributor

Good Evening Jelloir,

I checked your script and it works nice. However there is one small little hurdle. Your $SERVERNAME variable does not get defined correctly. For example, one of my VM's name is FC-Chicago WSUS Server. When the output of your script is displayed, I get "=====REPORT FOR FC-Chicago =======" instead of

"=====REPORT FOR FC-Chicago WSUS Server========="

Thanks

Stevester

Reply
0 Kudos
Jelloir
Enthusiast
Enthusiast

This is due to the line:

SERVERNAME=$($GREP 'Copying' $server | awk '{print $5}')

Which prints the 5th field delimited by spaces and since your VM has a space in its filename only prints the first field FC-Chicago.

Try replacing it with:

SERVERNAME=$($GREP 'Copying' $server | awk '{ for (i=5; i<=NF; i++) printf("%s ", $i); printf("\n") }'

Which prints everything from field 5 to the end of the line.

Cheers

Reply
0 Kudos
Stevester
Contributor
Contributor

Great it works!!!!!!!!!!! However you forgot a trailing ) bracket to enclose the variable SERVERNAME. Now what if you would like the script to also print the integrity checks that occurs as well. I would like the script to check for those of the current date as well as printing the normal backups that is currently implemented. The reason I am asking is the I found out that with the Linux INCRON package, you can get as closest to a built in email alert as possible. With INCRON, you can implement a setup where when the operations.utx.log file is opened and then closed (IN_CLOSE_WRITE attribute), the kernel will perform an action that you specify.

Thanks

Stevester

Reply
0 Kudos
ROM13
Contributor
Contributor

Hi all,

Thanks Jelloir for your script. But it doesn't work ... maybe because i just installed vdr 1.2 ? Did log paths/files changed since 1.1 ?

I only have a vmware-root dir in /tmp with vixDiskLib-*.log files inside. Can't find any vdrbackup.log.

Here's the execution log (vdr-report.sh is your vdr-reportv2-stevester.sh)

# ./vdr-report.sh

rm: cannot remove `/tmp/vdrbackup.log': No such file or directory

ls: /tmp/vdrlog*.txt: No such file or directory

grep: /tmp/vdrbackup.log: No such file or directory

/bin/cat: /tmp/vdrbackup.log: No such file or directory

Null message body; hope that's ok

Thanks for your help !

Reply
0 Kudos
Stevester
Contributor
Contributor

Good Morning ROM13,

I had the same issue as well. Log files are been called which don't exist in the location specified. It may be simpler to GREP and use the SED command on the operations.utx file. Something of this nature: ($STRINGS -e l $BINLOG | $EGREP -i $CURRENTDATE | $SED -e:o -e's/$\[[^][]\]//g; s/$\[.\]//g' -eto |..... AWK....) should suffice. I just got in from vacation and was going to work on it, but haven't had time to yet.

Also, if you use the Linux INCRON command (you may have to install it) to detect changes on files, folders, and etc, it would make a great email notification system.

Thanks

Stevester

Reply
0 Kudos
Jelloir
Enthusiast
Enthusiast

I would need to see the output of the strings command, i,e, the log output before it it piped through the rest of the script, e.g.

strings -e l /var/vmware/datarecovery/operations_log.utx &gt; /tmp/rawvdroutput.log

We are using 1.2 and it works ok for us.

post a .txt attachment with an excerpt (just a single server will do) of the strings output and i'll look at the why nothing is generated from the logs on your servers when time allows.

Edit: I should also clarify as you appear to be confused about the log location. The logs vdrbackup.log and vdrlog*.txt are generated by the script and have nothing to do with vdr. The fact they do not exist is because the script is not creating them due to nothing going into them.

Reply
0 Kudos
ROM13
Contributor
Contributor

It's ok...

I misunderstood date format (and missread previous posts also Smiley Wink ), i just replaced 2 occurences of %-d/%-m/%Y with %-m/%-d/%Y and it's working now.

Thanks for your help !

Reply
0 Kudos
Jelloir
Enthusiast
Enthusiast

New version to resolve some issues.

VM reports were disjointed if backups ran mutiple times which made the report hard to read.

errors on backed up VM's were not always correctly formatted.

The script is less automated and relies on VM's being reported on being input as variables or arguments. This was required as per the previous comments above.

Make sure you set log start time and date the same as your VDR backup job and get your variables/arguments correct.

I have not tried using it with multiple jobs but it should work by simply using seperate script arguments where required.

All the best.

Reply
0 Kudos
woisch
Contributor
Contributor

Hi all,

how could i implement the script from Jelloir. How should i configure exim and mailx? Once the script is stored in /scripts do i needto create a cronjob for this or came there a message if the backup job is ready?

Could someone give me an example ho the output looks like with the script from Jelloir?

best regards

Reply
0 Kudos
Innuendo_
Contributor
Contributor

In der Zeit vom 11.10. bis einschließlich 15.10.2010 bin ich nicht erreichbar. Ihre Nachricht wird nicht weitergeleitet.

Herr Kiupel wird mich in dieser Zeit vertreten: m.kiupel@pc-team.de

Sie erreichen unser PC-Team unter der Rufnummer 02291 - 9267-0

Besten Dank für Ihr Verständnis und

mit freundlichen Grüßen

Klaus Ader

Reply
0 Kudos
Jelloir
Enthusiast
Enthusiast

MTA on the VDR Server

== Edit Exim's config file to add the following settings

vi /etc/exim/exim.conf

Locate the line that reads "# qualify_domain =", uncomment it and edit it to

qualify_domain = example.com

(replace with you fully qualified domain obviously)

Then add this before the “dnslookup:” section. Replace 10.1.1.2 with the address of your mail relay/smarthost.

to_smart_host:

driver = manualroute

domains = ! +local_domains

transport = remote_smtp

route_list = "* 10.1.1.2;"

== Restart exim

service exim restart

== Install mailx

yum install mailx

== The Script

Place the script at /usr/local/bin/vdr-report.sh

chmod +x /usr/local/bin/vdr-report.sh

== Setup Cron

Add a new cron entry to root's crontab

crontab -e

SHELL=/bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

#m h dom mon dow command

0 9 * * * /usr/local/bin/vdr-report.sh

Research how cron works to alter when the report is sent.

Reply
0 Kudos