Networker

Re: [Networker] I need a report by schedule ...

2008-04-11 14:41:09
Subject: Re: [Networker] I need a report by schedule ...
From: Tim Mooney <Tim.Mooney AT NDSU DOT EDU>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Fri, 11 Apr 2008 13:38:39 -0500
In regard to: [Networker] I need a report by schedule ..., MIchael Leone...:

I'd like to run a report (mminfo, preferrably) that lists my groups by
schedule, so I can see which are on the "Full Every Day Skip Sat Sun" and
which are on "Sat Only", etc. But I don't seem to see a way to list out
the schedule of a group.

That's not stored in the media database, so mminfo won't tell you about
it.

Am I just missing that, in the query criteria?

Here's what I use, on our Linux NetWorker server, for that exact purpose.
If you have ActiveState perl on your Windows box, this should work
directly from a DOS box.



#!/usr/bin/perl -w

use strict;
use POSIX qw(tmpnam);
if ($#ARGV < 0) {
        print STDERR "$0: usage: nsr_schedprint_by_group groupname\n";
        exit(1);
}

use vars qw($line $current_client $current_group $tmpfile $nsradmin_cmd
        $current_schedule);

$nsradmin_cmd = '/usr/sbin/nsradmin';

#
# TVM: feed the following to nsradmin.
#
$tmpfile = POSIX::tmpnam();

open(QFILE, ">$tmpfile") or die "Can't create temporary file $tmpfile: $!\n";

print QFILE 'option Dynamic', "\n";
print QFILE 'option Hidden', "\n";
print QFILE '. type: NSR Client', "\n";
print QFILE 'show Group; Name; Schedule', "\n";
print QFILE 'print', "\n";
close(QFILE) or die "close failed for $tmpfile: $!\n";

#
# Now run nsradmin with this query.
#
open(NSRADMIN, "$nsradmin_cmd -i $tmpfile |") or
        die "Can't pipe from nsradmin: $!\n";

while (defined($line=<NSRADMIN>)) {

        chomp($line);

        if ($line =~ /^\s*name: (.*);\s*$/) {
                $current_client = $1;
        }

        if ($line =~ /^\s*schedule: "(.*)";\s*$/) {
                $current_schedule = $1;
        } elsif ($line =~ /^\s*schedule: (.*);\s*$/) {
                $current_schedule = $1;
        }

        if ($line =~ /^\s*group: (.*);\s*$/) {
                $current_group = $1;
        }

        if ($line =~ /^\s*$/) {
                if (defined($current_group) and defined($current_client)
                        and defined($current_schedule)) {
                        if ($current_group eq $ARGV[0]) {
                                printf "%-40.40s %s\n", "$current_client",
                                        "$current_schedule";
                        }

                        undef($current_client);
                        undef($current_group);
                        undef($current_schedule);
                }
        }
}

close(NSRADMIN) or
        print STDERR "$0: $nsradmin_cmd returned $?: $!\n";
#unlink($tmpfile);



NW 7.4.1, Win2003.



--
Tim Mooney                                        Tim.Mooney AT ndsu DOT edu
Information Technology Services                   (701) 231-1076 (Voice)
Room 242-J6, IACC Building                        (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164

To sign off this list, send email to listserv AT listserv.temple DOT edu and type 
"signoff networker" in the body of the email. Please write to networker-request 
AT listserv.temple DOT edu if you have any problems with this list. You can access the 
archives at http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER