2 Bronze

A different way to create and email avamar reports.

A different way  to create and email avamar reports.

Hello All,

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 ,

  1. Windows Server ( I did this in my customer env. And they mostly have windows. I used win 2008 server)
  2. We need winscp ( If you are not already  have)
  3. Winrar (again if you are not already have)

First i connect avamar with winscp. Then ,

I save the session information ,1.png

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.

  1. My first script is created with winscp commands,

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=%time:~0,2%

    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%

cd e:\Reports

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.

Ahmet Keçeciler

4 Replies
2 Iron

Re: A different way to create and email avamar reports.

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.

0 Kudos
1 Nickel

Re: A different way to create and email avamar reports.

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:


import pdb

import psycopg2

from smtplib import SMTP

import datetime


def sendreport(message_text):

    smtp = SMTP()

    smtp.connect('smtp.server.local', 25)

    from_addr = "Avamar grid <xxxx@.local>"

    to_addr = "admin@local.net"

    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[4] == 30000):

            result='Completed with succes.'

        elif (row[4] == 30005):

            result='Completed with exceptions.'

        elif (row[4] == 30999):

            result='Backup in error!'

        print "Serveur: " + row[0] + "  Resultat: " + result

        message_text += "\n" + row[0] + "\t\t" + result

    print "msg: \n" + message_text


        print "Not Working"


0 Kudos
4 Beryllium

Re: A different way to create and email avamar reports.

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.

0 Kudos
2 Bronze

Re: A different way to create and email avamar reports.


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)

0 Kudos