VMWare vDR Backup HTML Report

VMWare vDR Backup HTML Report

SCRIPT:

#!/bin/bash
#Parse file
err=$(strings -e l /var/vmware/datarecovery/operations_log.utx | grep -i -B2 "error" | awk -F"$" '{print substr($2,5,21) " " substr($2, 27, 100) " " $3 " " substr($6,17,20)}' | grep c)
succ=$(strings -e l /var/vmware/datarecovery/operations_log.utx | grep -i -B1 "success" | awk -F"$" '{print substr($2,5,21) " " substr($2, 26, 100) " " substr($3,5,100)}' | grep c)
#Test String - strings -e l /var/vmware/datarecovery/operations_log.utx | grep -i -B1 "success" | awk -F"$" '{print substr($2,5,21) " " substr($2, 26, 100) " " substr($3,5,100)}' | grep c

#Mail Server Variables
domain=
host=$HOSTNAME
smtphost=yourmailhost
mailto=you@domain.com

# Compare new list of all errors to old list of all errors
#if ! diff /root/olderror.out /root/newerror.out
#then
#err=$(diff olderror.out newerror.out | grep -c ">")
#mv /root/newerror.out /root/olderror.out -f

#Send Report to Mail Server
(
sleep 1
echo "HELO $host.$domain"
sleep 1
echo "mail from:vdrreport@$domain"
sleep 1
echo "rcpt to:$mailto"
sleep 1
echo "data"
sleep 1
echo "subject:VDR-Report - $host $(date +"%Y-%m-%d %H:%M") Jobs OK: $succ, FAILED: $err"
sleep 1
echo "from:VMWare Data Recovery on "$host
sleep 1
echo "$host $(date +"%Y-%m-%d %H:%M") Jobs OK:$succ, FAILED:$err "
sleep 1
echo "##### Successful Jobs ($succ) #####"
sleep 1
strings -e l /var/vmware/datarecovery/operations_log.utx | grep -i -B1 "success" | awk -F"$" '{print substr($2,5,21) " " substr($2, 26, 100) " " substr($3,5,100)}' | grep c
sleep 1
echo "##### Failed Jobs ($err) #####"
sleep 1
echo "VDR Errors: "$err
sleep 1
echo "."
sleep 1
echo "QUIT"
) | telnet smtphost 25


 

TESTED AND WORKING:

 


#!/bin/bash

#Mail Server Variables
domain=
host=$HOSTNAME
smtphost=
mailto=

#Send Report to Mail Server
(
sleep 1
echo "HELO $host.$domain"
sleep 1
echo "mail from:vdrreport@$domain"
sleep 1
echo "rcpt to:"$mailto
sleep 1
echo "data"
sleep 1
echo "subject:VDR-Report - $host.$domain $(date +"%Y-%m-%d %H:%M")"
sleep 1
echo "from:VMWare Data Recovery Report on "$host
#sleep 1
#echo "$host $(date +"%Y-%m-%d %H:%M") Jobs OK:$succ, FAILED:$err "
sleep 1
echo "##### Failed Jobs #####"
sleep 1
succ=$(strings -e l /var/vmware/datarecovery/operations_log.utx | grep -i -B1 "success" | awk -F"$" '{print substr($2,5,21) " " substr($2, 26, 100) " " substr($3,5,100)}')
sleep 1
echo "."
sleep 1
echo "QUIT"
) | telnet $smtphost 25

 

CRON JOB: To run every Monday at 8 AM

chmod +x vDRreport.sh

crontab -e
00 8 * * 1 /root/vDRreport.sh

References:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s