Networker

Re: [Networker] Determining schedule from a script?

2003-05-20 16:36:23
Subject: Re: [Networker] Determining schedule from a script?
From: George Sinclair <George.Sinclair AT NOAA DOT GOV>
To: NETWORKER AT LISTMAIL.TEMPLE DOT EDU
Date: Tue, 20 May 2003 16:36:27 -0400
As near as I can tell, there is no quick and dirty command that you can
run that will allow you to pass in a group name and date and then have
it return the level of backup (e.g. full, incr, 5, 4, 3, etc.) that it
will run on that date, or that it already ran on that date, based on the
schedule assigned to that group. That would be nice, but NetWorker
doesn't appear to offer that capability. Instead, you have to run the
nsradmin command and do some parsing. However, because we're going to be
launching this from within a script, we surely don't want to run
nsradmin in interactive mode, so instead, we will place our commands
into an input file and pass that to the nsradmin program and then parse
the results.

First, though, let's suppose I have a group named: my_group and I want
to see everything associated with the schedule that my_group uses. Well,
I know the schedule name is my_group_sched, so in interactive mode it
would be something like this:

$ nsradmin -s server
NetWorker administration program.
Use the "help" command for help, "visual" for full-screen mode.
nsradmin> print type: nsr schedule; name: my_group_sched
                        type: NSR schedule;
                        name: my_group_sched;
                      period: Week;
                      action: "skip incr incr incr incr skip incr ";
                    override: 5  7/12/2003, 4   6/21/2003, 4
8/23/2003,
                              5    8/9/2003, full    8/30/2003,
                              incr     7/19/2003, incr     7/5/2003,
                              incr      5/17/2003, incr       6/14/2003,
                              5       6/7/2003, incr       5/31/2003,

blah-blah-blah ...

Since I never specified a "show" command, the print command is assuming
a default of "all" as in it will display all the attributes for the
schedule. There's a lot more information under the "override" section
that would normally follow, but I've chosen not to show it since it's
not really relevant to the discussion. Anyway, here's what is important.
The "action" consists of 7 values corresponding to the days of the week:
Sun - Sat. And, these are the backup levels that are to be run UNLESS
the given day is overridden. If the date is overridden, it will appear
under the "override" section. Even if the value for the override is the
same as the default, it will still appear. Any dates for which no
override value has been selected will NOT appear under the "override"
section, so you will need to know which day of the week that corresponds
to and then you can figure out what the level was or is based on the
"action". There doesn't seem to be any sane order to the values that
appear under the "override" section, but it should be easy enough to
parse it.

Now, let's suppose I only want to see the "action" and "override" values
for the given schedule. This time, we'll do it non-interactively. I
create a file named nsradmin_input.txt with the following:

. type: nsr schedule; name: my_group_sched
sh action; override
print

I then run nsradmin from my script as:

`nsradmin -i nsradmin_input.txt`

or some such thing, and it returns the following:

Current query set
                      action: "skip incr incr incr incr skip incr ";
                    override: 5  7/12/2003, 4   6/21/2003, 4
8/23/2003,
                              5    8/9/2003, full    8/30/2003,
                              incr     7/19/2003, incr     7/5/2003,
                              incr      5/17/2003, incr       6/14/2003,
blah-blah-blah ...

So, you can see, that some parsing will need to be done to determine
what level is associated with a given day. So, if I wanted to know what
level was to be run for say 07/11/2003 then I would parse for this. Of
course, I wouldn't find it, so that means that that that date is not
being overridden at this time which means that it will be one of the
values listed in the action attribute depending on which day of the week
the 11th of July is. My script would have to be able to determine this
somehow. On the other hand, if I wanted to know the level for say
07/12/2003, then it would be a level 5 as shown.

I guess the main problem here besides parsing is figuring out which day
of the week a given date is. Does anyone have a way to do that?

George



George Sinclair wrote:
>
> Hi,
>
> I'd like to be able to determine what level a given client's backup
> should have been on a given night based on the assigned schedule for the
> client's group. I need to be able to do this from a Perl script. I will
> have a file that will tell me what groups the client is a member of and
> the assigned schedule names for those groups, but this is the most I
> will be able to hard code because the schedules themselves are variable
> from one month to the next in terms of what levels are run on what days.
> Is there a command I can run in the script to determine this?
>
> Thanks.
>
> George
>
> --
> Note: To sign off this list, send a "signoff networker" command via email
> to listserv AT listmail.temple DOT edu or visit the list's Web site at
> http://listmail.temple.edu/archives/networker.html where you can
> also view and post messages to the list.
> =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

--
Note: To sign off this list, send a "signoff networker" command via email
to listserv AT listmail.temple DOT edu or visit the list's Web site at
http://listmail.temple.edu/archives/networker.html where you can
also view and post messages to the list.
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

<Prev in Thread] Current Thread [Next in Thread>