cancel
Showing results for 
Search instead for 
Did you mean: 

NetBackup Appliance send mail command line syntax

KeirL
Level 6
Partner

Hi all

Does anyone know a command line to send an email directly from a NetBackup Appliance (5230 running 2.5.4)? If this works at all I guess it will involve going into maintenance and elevating to SU. I've configured opscentre and set up the SMTP server within the appliance and this all works fine. But I was hoping to run a daily report to show the 'media written' for last nights backups - so I can easily identify the tapes to remove from the library.

I think this report is only available with Opscentre analytics and I don't want to buy a licence just to get such a fundamental report to tell me which tapes NetBackup used. I can run the report manually from within the NBU admin console and run a bpimagelist -U but wouls like to set up some kind of cron job to email this report everyday.

Am I missing something or have Symantec recently prevented customers from emailing what I'd consider a vital daily report unless they buy the Opscentre Analytics licence?

kind regards

Keir 

1 ACCEPTED SOLUTION

Accepted Solutions

Andrew_Madsen
Level 6
Partner

This is a short script I have for sending the nbstluitil report output to me. I then put it in a cron job to run every day. The important things to remember:

1. You need the path to the binary you are using.

2. You need to specify the path for output

If you want you can attach the file. I chose to cat it to mailx because I hate opening attachments and the output is not so big.

#!/bin/bash

NOW=$(date +"%m%d%y-%H%M")

FILE="/var/tmp/slp/nbstlutil-report$NOW.txt"

/usr/openv/netbackup/bin/admincmd/nbstlutil report > $FILE

cat $FILE|mailx -r put.your.sender.here@whatever.com -s "SLP Backlog Report" recip.one@domain.com recip.two@domain.co

 

View solution in original post

16 REPLIES 16

Marianne
Level 6
Partner    VIP    Accredited Certified

You can try normal OS 'mailx' command.

(I cannot answer your Opscentre question.)

Andrew_Madsen
Level 6
Partner

Were you ever able to main the report from OpsCenter? if so then open a ticket with Symantec to get that fixed. If not you have never been able to mail the report from the appliance with it configured the way it comes from the factory. You have to go into Maintenance and then set up a cron job to mail you the report. We do that quite regularly especially when we have space issues.

One thing to keep in mind when you upgrade to 2.6.0.1 you may lose that function unit you re add it. since the 2.6.0.1 is an OS upgrade as well as a NetBackup upgrade.

Mark_Solutions
Level 6
Partner Accredited Certified

This tech note outlines how sendmail is used on appliance which may help you.

http://www.symantec.com/business/support/index?page=content&pmv=print&impressions=&viewlocale=&id=TE...

Of course if you have any Windows Media Server / Admin Console you could also use blat from one of those to run the report.

In OpsCenter there is the Media Utilisation report which includes assigned media (so used media) which can be filtered to reflect a period of 1 day - perhaps making a new report based on this template would give you what you need?

KeirL
Level 6
Partner

Thanks everyone for your input.

Andrew - I think you've pretty much hit my requirement when you say that I need to go into maintenance and use a cron job. This isn't something I had working before so I'm not looking to fix an issue but merely set this up from scratch.

Can you help me with the syntax - perhaps the command line you use?

eg is the follwing close?

#bpimagelist -A hoursago=24 > media_written_report.txt

#sendmail <username@domaonname.com> -a  media_written_report.txt

Cheers

K

Andrew_Madsen
Level 6
Partner

This is a short script I have for sending the nbstluitil report output to me. I then put it in a cron job to run every day. The important things to remember:

1. You need the path to the binary you are using.

2. You need to specify the path for output

If you want you can attach the file. I chose to cat it to mailx because I hate opening attachments and the output is not so big.

#!/bin/bash

NOW=$(date +"%m%d%y-%H%M")

FILE="/var/tmp/slp/nbstlutil-report$NOW.txt"

/usr/openv/netbackup/bin/admincmd/nbstlutil report > $FILE

cat $FILE|mailx -r put.your.sender.here@whatever.com -s "SLP Backlog Report" recip.one@domain.com recip.two@domain.co

 

KeirL
Level 6
Partner

Thanks Andrew

I'll try that when I next get a chance (today or tomorrow) and let you know how I get on

cheers

KeirL
Level 6
Partner

Hi Andrew

I think I'm still missing something.

Do I need to manually configure anything within the appliance to tell it where my SMTP server is?

perhaps in /etc/postfix/main.cf ?

I'm not getting any emails with the commands I'm trying - even though I think the commands are good. When I look in /var/log/mail.info I can see attempts to connect directly to the internet with these messages and not via our internal SMTP server. I've set the SMTP server info via the Clish but can't find any conf file that  can check to make sure the settings have been accepted.

cheers again

 

KeirL
Level 6
Partner

That was it - edited the main.cf to add the relay host 

all working ok now :o)

KeirL
Level 6
Partner

Sorry - but I have a quick follow up on this.

I feel this is more of a Linux question than NetBackup but I have created the script (with help from Andrew - thanks!), which works fine when I execute the script manually. Below is the script

#!/bin/bash

DATE=$(date +%m%d%y)

FILE="/usr/openv/netbackup/reports/media_written_$DATE.txt"

./bpimagelist -A -media -hoursago = 24 > $FILE

cd /usr/openv/netbackup/reports

cat $FILE|mailx -r put.your.sender.here@whatever.com -s "Media Written Report $DATE" recip.one@domain.com  recip.two@domain.com

This works fine if I just execute the script and the email is recieved with the media written details as the email body. However, when I put this into the crontab and schedule the script I only get an email with no text. I've also noticed that the media_written_$DATE.txt file is also empty. Is this a permissions thing that cron doesn't have the permissions to execute the bpimagelist command and hence the txt file is empty?

kind regards

KL

Mark_Solutions
Level 6
Partner Accredited Certified

You need to put it all into a script file (perl maybe) and then call that from the crontab

It does other NBU things from there so it should be ok as long as the script has the correct rights

The other crontab entries should give an idea of the format

KeirL
Level 6
Partner

Hi Mark

I'm not sure I follow - sorry!

I have created a script file called media_written.sh with all the lines from my previous post in it.

From a command line if I simply run 'media_written.sh' and everything works as I want.

I've run crontab -e to edit the cron tab and put in a line 

0 12 * * 1-5 /usr/openv/netbackup/bin/admincmd/media_written.sh

so this runs at midday every weekday.....

And it does run as expected but this time the email i recieve as no result from the bpiamgelist output. Its just a blank email.

So I think the whatever user runs the script (i thought it was always root) doesn't have permsissions to run bpimagelist....

cheers

Mark_Solutions
Level 6
Partner Accredited Certified

Have you looked to see if the output file is actually blank that was created on the appliance as it may just not be able to send that file in the way you have it setup

The system also seems to use perl (.pl) scripts

It may also be other variables that need to be passed to crontab - if you look at the existing crontab entry for the call home script it adds lots of things before setting off the script (and after) so it seems to need to pass more to crontab for it all to work

It sets up paths etc before going to the perl directory then specifies the scripts folder before actually running the script

So you may want to put you script in the /opt/NBUAppliance/scrips/ directory and then have your line something like:

0 12 * * 1-5 PATH=/opt/VRTSperl/bin:/sbin:/usr/openv/netbackup/admincmd:$PATH; export PATH; /opt/NBUAppliance/bin/perl -I/opt/NBUAppliance/scripts/ /opt/NBUAppliance/scripts//media_written.pl

Not sure about the "> /dev/null 2>&1" on the end

Note the double // before the script name too - not sure if that is required

Hoep this helps - i am not particularly a Unix person!

 

KeirL
Level 6
Partner

Thanks Mark

I'll try that in the morning.

Yes - the output file is blank, so if definitely seems to be assoocated with cron not being able to run the command to populate the output file rather than not being able to email the output.

I'm not a UNIX person either and thought Cron was just a simple way to call a script at a particular time of the day  - but I suspect it's more involved than that.

cheers

Andrew_Madsen
Level 6
Partner

KL,

 

You need to put the path to the bpimagelist /usr/openv/netbackup/bin/admincmd/bpimagelist not using the local directory that the script is launched from. cron operates from the user's home directory as base in this case /root so the command "./bpimagelist" makes the script look for /root/bpimagelist. Try changing ./bpimagelist to /usr/openv/netbackup/bin/admincmd/bpimagelist and see what you get.

KeirL
Level 6
Partner

Thanks Andrew - that makes sense

I'll try that and update this with the results.

Thanks both

KeirL
Level 6
Partner

Hi

Thanks Andrew - putting the full path to the bpimagelist binary has worked.

many thanks