Reporting in avamar always in my nightmares. I usually use avamar cli mccli and some other tools on avamar. But an automated emaling always has been problem for me . Today i tried somtehing else and wolla it worked perfectly .Now i want to share this with you.
First we need some tools for this . I belive that almost all of us familiar with them.
Here we go ,
First i connect avamar with winscp. Then ,
Warning : This action may have security issues. So do it with your own risk.
After that i create some scripts . I will try to explain them below. Basically i create 3 windows batch you can merge them or split whatever you want.
In first line i am changing folder to be able to run winscp commands,
cd "c:\Program Files (x86)\WinSCP"
winscp /console /command "open avamar" "call /usr/local/avamar/bin/./replcnt.sh > /home/Reports/replication_log.txt"
In above line winscp conencts the avamar with saved user name and password. After connected it runs “call”command and the replication report script.
winscp /console /command "open avamar" "call capacity.sh > /home/Reports/capacity_log.txt" "exit"
I added the the what ever i need.
winscp /console /command "open avamar" "call status.dpn > /home/Reports/status_dpn.txt" "exit"
winscp /console /command "open avamar" "call dpnctl status > /home/Reports/dpnctl_status.txt" "exit"
winscp /console /command "open avamar" "cd /home/Reports" "get *.txt E:\Reports\ " "exit"
and the last line is connecting avamar and goes to my report folder and copying all txt files to my windows server.
And here is the output files
Ok good now we have our reports on our windows server what is next ?
I need to keep them with date format so here is second batch . It renames our files with date format.
set HR=%Hr: =0%
set HR=%HR: =%
rename e:\Reports\capacity_log.txt capacity_log_results_%date:~10,4%-%date:~4,2%-%date:~7,2%_%HR%%time:~3,2%.txt
rename e:\Reports\dpnctl_status.txt dpnctl_results_%date:~10,4%-%date:~4,2%-%date:~7,2%_%HR%%time:~3,2%.txt
rename e:\Reports\status_dpn.txt status_results_%date:~10,4%-%date:~4,2%-%date:~7,2%_%HR%%time:~3,2%.txt
rename e:\Reports\replication_log.txt replication_log_results_%date:~10,4%-%date:~4,2%-%date:~7,2%_%HR%%time:~3,2%.txt
And here is the output.
Now we have reports that renamed with dates.
And this time i need to zipped these files. This time i use winrar. This is the third batch file.
First i set home env. For winrar then change the directory to my reports directory
set path="C:\Program Files\WinRAR\";%path%
rar a -r e:\Reports\reports.rar E:\reports\*.txt e:\Reports\Reports.rar
Its all done . Now we just need to schedule these batch files with windows task scheduler.
And email them again with task scheduler.
And it works .
I hope it is usefull for everybody who uses Avamar. Have nice works.
This is great info. appreciate the detail.
However, why could you not have performed these various commands and renaming etc. on the Utility node then email them directly from it?
The process could be scheduled using the Linux CRON.
This would eliminate the need to interact with a Windows host but if for some reason they are actually needed on Windows a single winscp could be used to retrieve it.
Interesting thread for sure, as reports ARE a nightmare as soon as you need something a little custom.
The way I do it is, I wrote a script that interrogate the postgress database (you'll need to be creative with SQL queries here), and email the results to the concerned administrators.
Here is a prototype in python that fetch MSSQL plugin backups exceptions. Warning, this is very ALPHA, non-optimized and ugly code, but hopefully you'll get the idea:
from smtplib import SMTP
smtp = SMTP()
from_addr = "Avamar grid <xxxx@.local>"
to_addr = "email@example.com"
subj = "Avamar SQL Backup Exceptions"
date = datetime.datetime.now().strftime( "%d/%m/%Y %H:%M" )
msg = "From: %s\nTo: %s\nSubject: %s\nDate: %s\n\n%s" % ( from_addr, to_addr, subj, date, message_text )
smtp.sendmail(from_addr, to_addr, msg)
conn = psycopg2.connect('host=avamar_utility_node_ip port=5555 dbname=mcdb user=viewuser password=viewuser1')
print "Connected to Database"
print "No Connection"
#cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
cur = conn.cursor()
cur.execute("select client_name,domain,recorded_date,plugin_name,status_code FROM v_activities WHERE recorded_date_time > current_timestamp - interval '24 hours' AND plugin_name='Windows SQL'")
rows = cur.fetchall()
message_text = '\nServeur\t\t\t\tResultat'
message_text += '\n--------\t\t\t\t\t--------'
for row in rows:
if (row == 30000):
result='Completed with succes.'
elif (row == 30005):
result='Completed with exceptions.'
elif (row == 30999):
result='Backup in error!'
print "Serveur: " + row + " Resultat: " + result
message_text += "\n" + row + "\t\t" + result
print "msg: \n" + message_text
print "Not Working"
why could you not have performed these various commands and renaming etc. on the Utility node then email them directly from it?
As an intermediate option, have you looked into "plink" or its more GUI-friendly cousin TortoisePlink.exe? The plink utility can be used to run SSH commands on remote hosts and it's a lot more lightweight than WinSCP.
For the security conscious, I would recommend setting up passwordless authentication from the Windows host to the utility node. While this is not officially supported, it does work and it's far more secure than saving login credentials. This does require you to keep the private key secured.
First off all thank you for your replies .
I actually did this for my customers who are not familiar with linux systems. And all af them want to control this system without trying to use avamar cli or linux bash. So why i did it with using windows instead of linux. Also Other comments are absuletly true about saving connection credantials. Our customers in my country are needs diffirent things, they want to some reports with email but but dont want struggle and learn new things. So this is my easiest way to do this. With this way they can control scripts schedules without interacting with avamar. Because of that i renamed the article " Different Way ..." I know there is a alot of way to accomplish that what we want ... Also my best concept is K.I.S ( Keep It Simple)