<html><head><base href="x-msg://637/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello<div><div><br></div><div>we got this one done recently but it is a bit ugly but it has been working fine.</div><div>you ll have to modify some variable like $bbdisp and maybe others.</div><div><br></div><div>it has to run on the netbackup server (ours is running on solaris).</div><div><br></div><div>let me know if you have questions.</div><div><br></div><div>cheers</div><div>Nico</div><div><br></div><div><br></div><div><div>#!/usr/bin/perl -w</div><div><br></div><div>#</div><div># nlienard (with help of mward)</div><div># 2012-08-01</div><div># Retrieve netbackup status then publish it on hobbit</div><div>#</div><div><br></div><div>use Switch;</div><div>use strict;</div><div>use warnings;</div><div><br></div><div># Fields output by the command are:</div><div><br></div><div># 1 jobid               2 jobtype       3 state         4 status</div><div># 5 class               6 schedule      7 client        8 server</div><div># 9 started     10 elapsed      11 ended        12 stunit</div><div># 13 try                14 operation    15 kbytes       16 files</div><div># 17 pathlastwritten    18 percent      19 jobpid       20 owner</div><div># 21 subtype    22 classtype    23 schedule_type        24 priority</div><div># 25 group      26 masterserver 27 retentionunits       28 retentionperiod</div><div># 29 compression        30 kbyteslastwritten    31 fileslastwritten     32 trystatus</div><div># 33 trystatusdescription       34 parentjob    35 kbpersec     36 copy</div><div># 37 robot      38 vault        39 profile      40 session</div><div># 41 ejecttapes 42 srcstunit    43 srcserver    44 srcmedia</div><div># 45 dstmedia   46 stream       47 suspendable  48 resumable</div><div># 49 restartable        50 datamovement 51 snapshot     52 backupid</div><div># 53 killable   54 controllinghost</div><div><br></div><div># Hobbit variables</div><div>my $bb = "/opt/xymon/server/bin/xymon";</div><div>my $coltmon = "10.64.3.6";</div><div>my $test = "netbackup";</div><div><br></div><div>my( $jobid, $jobtype, $state, $status, $class, $schedule, $client, $server, $started, $ended, $kbytes);</div><div>my (%record, $rec);</div><div>my ($tmpfile, $self);</div><div><br></div><div>my $today = scalar localtime(time) ;</div><div>$today =~ s/\w+\s(\w+)\s+(\d+).*/$1  $2/;</div><div>my $yesterday = scalar localtime(time-86400) ;</div></div><div><br></div><div><div>$yesterday =~ s/\w+\s(\w+)\s+(\d+).*/$1  $2/;</div><div>my $yesterday2 = scalar localtime(time-172800) ;</div><div>$yesterday2 =~ s/\w+\s(\w+)\s(\d+).*/$1  $2/;</div><div><br></div><div>my $todayX = scalar localtime(time) ;</div><div>$todayX =~ s/\w+\s(\w+)\s+(\d+).*/$1 $2/;</div><div>my $yesterdayX = scalar localtime(time-86400) ;</div><div>$yesterdayX =~ s/\w+\s(\w+)\s+(\d+).*/$1 $2/;</div><div>my $yesterday2X = scalar localtime(time-172800) ;</div><div>$yesterday2X =~ s/\w+\s(\w+)\s(\d+).*/$1 $2/;</div><div><br></div><div><br></div><div>open(BPP, "/usr/openv/netbackup/bin/admincmd/bpdbjobs -all_columns 2>/dev/null |") || die "Cannot execute bpdbjobs command: $!";</div><div><br></div><div>while (<BPP>) {</div><div>        chomp;</div><div>        s/'/\'/g; # Escape any un-escaped single quotes.</div><div>        (</div><div>                $jobid,</div><div>                $jobtype,</div><div>                $state,</div><div>                $status,</div><div>                $class,</div><div>                $schedule,</div><div>                $client,</div><div>                $server,</div><div>                $started,</div><div>                undef,</div><div>                $ended,</div><div>                undef,</div><div>                undef,</div><div>                undef,</div><div>                $kbytes,</div><div>                undef</div><div>        ) = split(/,/);</div><div><br></div><div>        $record{$jobid}{jobid} = "$jobid";</div></div><div><br></div><div><div>        $record{$jobid}{jobtype} = "$jobtype";</div><div>        $record{$jobid}{state} = "$state";</div><div>        $record{$jobid}{status} = "$status";</div><div>        $record{$jobid}{class} = "$class";</div><div>        $record{$jobid}{schedule} = "$schedule";</div><div>        $record{$jobid}{client} = "$client";</div><div>        $record{$jobid}{server} = "$server";</div><div>        $record{$jobid}{started} = "$started";</div><div>        $record{$jobid}{ended} = "$ended";</div><div>        $record{$jobid}{kbytes} = "$kbytes";</div><div>}</div><div><br></div><div>close(BPP);</div><div><br></div><div>#</div><div># %record now has all the data in it.</div><div>#</div><div><br></div><div><br></div><div>my @ignore = qw(ignore_host1 ignore_host2);</div><div><br></div><div># Loop through the hash extracting entries</div><div>foreach $rec ( keys %record ) {</div><div>        # Set the hostname</div><div>        my $hostname = $record{$rec}{client};</div><div>        $hostname =~ s/(.*)\.oss.*/$1/;</div><div><br></div><div>        if (!($hostname)) {</div><div>                next;</div><div>        }</div><div><br></div><div>        if (grep { $_ eq $hostname } @ignore) {</div><div>        #if ( $hostname ~~ @ignore ) {</div><div>                next;</div><div>        }</div><div><br></div><div><br></div><div>        #print "checking " . scalar(localtime($record{$rec}{started})) . " with $yesterday and $today\n";</div><div>        #if ( (scalar(localtime($record{$rec}{started})) =~ /$yesterday/) || (scalar(localtime($record{$rec}{started})) =~ /$today/) ) {</div><div>        if ( (scalar(localtime($record{$rec}{started})) =~ /$yesterday/) || (scalar(localtime($record{$rec}{started})) =~ /$today/) || (scalar(localtime($record{$</div></div><div><div>rec}{started})) =~ /$yesterdayX/) || (scalar(localtime($record{$rec}{started})) =~ /$todayX/) ) {</div><div>                #if ($record{$rec}{class} =~ /Production/) {</div><div><br></div><div>                        # Set the color</div><div>                        my $color = "yellow";</div><div>                        my $state_color = "yellow";</div><div>                        my $msg = "&${color}This device is not correctly backuped";</div><div><br></div><div>                        my $state;</div><div>                        switch ( $record{$rec}{state} ) {</div><div>                                case 0 {  $state = "Queued";}</div><div>                                case 1 {  $state = "Active";}</div><div>                                case 2 {  $state = "Queued";}</div><div>                                case 3 {  $state = "Done";}</div><div>                                case 4 {  $state = "Suspended";}</div><div>                                case 5 {  $state = "Incomplete";}</div><div>                        }</div><div><br></div><div><br></div><div>                        # there are state and status.</div><div>                        # state is the general status</div><div>                        # status is the detail status</div><div><br></div><div>                        # state = 3 = Done = Green</div><div>                        if ( $record{$rec}{state} eq 3 ) {</div><div>                                $color = "green";</div><div>                                $state_color = "green";</div><div>                                $msg = "&${color}This device is correctly backuped";</div><div>                        }</div><div><br></div><div>                        # if state = 3 but status  != 0, then error => yellow</div><div>                        if ( $record{$rec}{status} ne 0 ) {</div><div>                                $color = "yellow";</div><div>                                $msg = "&${color}This device is backuped but with errors";</div><div>                        }</div><div><br></div><div><br></div><div><br></div><div>                        my $kbytes = "&yellow No data backuped";</div><div>                        if ($record{$rec}{kbytes}) {</div></div><div><br></div><div><div>                                $kbytes = "&green $record{$rec}{kbytes}";</div><div>                        }</div><div><br></div><div>                        my $ttl = "2d";</div><div>                        if ($record{$rec}{schedule} =~ /Weekly/ ) {</div><div>                                $ttl = "8d";</div><div>                        }</div><div><br></div><div><br></div><div>                        # build msg for hobbit</div><div>                        #my $line = "status+2d $hostname.$test $color";</div><div>                        my $line = "status+$ttl $hostname.$test $color";</div><div><br></div><div>                        $line .= "\n\t<H2>$msg</H2>\n";</div><div>                        $line .= "<table border=1>";</div><div>                        $line .= "<tr><th>State</th><td>&${state_color}" . $state . "</td></tr>";</div><div>                        $line .= "<tr><th>Status</th><td>&${color}" . $record{$rec}{status} . "</tr>";</div><div>                        $line .= "<tr><th>Jobid</th><td>" . $record{$rec}{jobid} . "</td></tr>";</div><div>                        $line .= "<tr><th>Class</th><td>" . $record{$rec}{class} . "</td></tr>";</div><div>                        $line .= "<tr><th>Schedule</th><td>" . $record{$rec}{schedule} . "</td></tr>";</div><div>                        $line .= "<tr><th>Client</th><td>" . $record{$rec}{client} . "</td></tr>";</div><div>                        $line .= "<tr><th>Server</th><td>" . $record{$rec}{server} . "</td></tr>";</div><div>                        $line .= "<tr><th>Started</th><td>" . scalar(localtime($record{$rec}{started})) . "</td></tr>";</div><div>                        $line .= "<tr><th>Ended</th><td>" . scalar(localtime($record{$rec}{started})) . "</td></tr>";</div><div>                        $line .= "<tr><th>kbytes</th><td>" . $kbytes . "</td></tr>";</div><div>                        $line .= "</table>";</div><div>                        $line .= "\nIf this check is purple, that means there is NO BACKUP anymore. Raise a ticket to BACKUP Team";</div><div><br></div><div>                        # debug</div><div>                        #print "\nPublishing status for $hostname to hobbit $bbdisp\n\n";</div><div><br></div><div><br></div><div><br></div><div>                        # publish status to hobbit central</div><div>                        #system "$bb $bbdisp \"$line\"";</div><div><br></div><div>                        # publish status to hobbit local</div><div>                        my $bbdisp  = `grep -i "$hostname " ~xymon/server/etc/hosts.d/LOCALDCS/* |cut -d/ -f9 |cut -d: -f1 | head -1`;</div><div>                        #print "debug1 bbdisp:[$bbdisp]\n";</div></div><div><br></div><div><div>                        chomp($bbdisp);</div><div>                        #print "debug2 bbdisp:[$bbdisp]\n";</div><div><br></div><div>                        if ($bbdisp) {</div><div>                                print "\nPublishing status for $hostname to hobbit $bbdisp";</div><div>                                #print "\n$bb $bbdisp \"$line\"";</div><div>                                #publish status to hobbit central</div><div>                                system "$bb $coltmon \"$line\"";</div><div>                                # publish status to hobbit local</div><div>                                system "$bb $bbdisp \"$line\"";</div><div>                        #} else {</div><div>                                #print "\nNOT Publishing status for $hostname to hobbit $bbdisp\n\n";</div><div>                        }</div><div><br></div><div>                        # debug</div><div>                        #print "jobid: ", $record{$rec}{jobid}, "\n";</div><div>                        #print "\tjobtype: ", $record{$rec}{jobtype}, "\n";</div><div>                        #print "\tstate: ", $record{$rec}{state}, "\n";</div><div>                        #print "\tstatus: ", $record{$rec}{status}, "\n";</div><div>                        #print "\tclass: ", $record{$rec}{class}, "\n";</div><div>                        #print "\tschedule: ", $record{$rec}{schedule}, "\n";</div><div>                        #print "\tclient: ", $record{$rec}{client}, "\n";</div><div>                        #print "\tstarted: ", scalar(localtime($record{$rec}{started})), "\n";</div><div>                        #print "\tended: ", scalar(localtime($record{$rec}{ended})), "\n";</div><div>                        #print "\tkbytes: ", $record{$rec}{kbytes}, "\n";</div><div>                }</div><div>        #}</div><div>}</div></div><div><br></div><div><br><div><div>Le 25 oct. 2012 à 20:01, KING, KEVIN a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div bgcolor="white" lang="EN-US" link="blue" vlink="purple"><div class="WordSection1" style="page: WordSection1; "><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; color: black; "><span style="font-size: 11pt; font-family: Arial, sans-serif; color: rgb(31, 73, 125); ">Ages ago I wrote a package for netbackup on the Big Brother system. It tacked a bunch of stuff and told you when the backup tapes could recycled and such. But all our stuff was on Sun equipment. I think your Idea of loading the binaries on a nix box may be a good way. Let me see if I can find my work. It used to be on deadcat long time ago.<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; color: black; "><span style="font-size: 11pt; font-family: Arial, sans-serif; color: rgb(31, 73, 125); "><o:p> </o:p></span></div><div style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; border-left-style: solid; border-left-color: blue; border-left-width: 1.5pt; padding-top: 0in; padding-right: 0in; padding-bottom: 0in; padding-left: 4pt; position: static; z-index: auto; "><div><div style="border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-top-style: solid; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; padding-top: 3pt; padding-right: 0in; padding-bottom: 0in; padding-left: 0in; "><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; color: black; "><b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; color: windowtext; ">From:</span></b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; color: windowtext; "><span class="Apple-converted-space"> </span><a href="mailto:xymon-bounces@xymon.com" style="color: blue; text-decoration: underline; ">xymon-bounces@xymon.com</a><span class="Apple-converted-space"> </span>[mailto:xymon-bounces@xymon.com]<span class="Apple-converted-space"> </span><b>On Behalf Of<span class="Apple-converted-space"> </span></b>Ricardo Stella<br><b>Sent:</b><span class="Apple-converted-space"> </span>Thursday, October 25, 2012 11:14 AM<br><b>To:</b><span class="Apple-converted-space"> </span><a href="mailto:xymon@xymon.com" style="color: blue; text-decoration: underline; ">xymon@xymon.com</a><br><b>Subject:</b><span class="Apple-converted-space"> </span>[Xymon] Netbackup client status script?<o:p></o:p></span></div></div></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; color: black; "><o:p> </o:p></div><p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 12pt; font-size: 12pt; font-family: 'Times New Roman', serif; color: black; "><br>We are finally migrating out of Tivoli to Symantec's Netbackup.  We currently have a backup tab for each client which would report some stats - number of files, number of bytes, and status.<br><br>Looking at doing something similar, however, it seems that most of the status commands are only available to be run on the netbackup master or media servers.<span class="Apple-converted-space"> </span><br><br>I've found the following nagios script: <span class="Apple-converted-space"> </span><a href="http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=2566&cf_id=24" style="color: blue; text-decoration: underline; ">http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=2566&cf_id=24</a><br><br>But in order not to reinvent the wheel, does anyone have something similar?  Further, our master and media servers are running windows, which makes scripting a little more challenging.<br><br>If not, if I install the media server bits on a linux box (without registering it on the netbackup domain) would this be enough to query the DB and produce reports?  If so, perl or bash would do it.<br><br>Thanks in advance...<o:p></o:p></p><div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; color: black; ">--<o:p></o:p></div><div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; color: black; "><span style="color: gray; ">°(((<span class="Apple-converted-space"> </span></span><u>=<span class="Apple-converted-space"> </span></u><span style="color: gray; ">((<span class="Apple-converted-space"> </span></span><u>===°°°<span class="Apple-converted-space"> </span></u><span style="color: gray; ">(((<span class="Apple-converted-space"> </span></span><u><span style="color: red; ">================================================</span></u><o:p></o:p></div></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; color: black; "><o:p> </o:p></div></div></div></div>_______________________________________________<br>Xymon mailing list<br><a href="mailto:Xymon@xymon.com" style="color: blue; text-decoration: underline; ">Xymon@xymon.com</a><br><a href="http://lists.xymon.com/mailman/listinfo/xymon" style="color: blue; text-decoration: underline; ">http://lists.xymon.com/mailman/listinfo/xymon</a></div></blockquote></div><br></div></div></body></html>