NSRADMIN scripting to determine datazone passphrase
Hi,
I'm trying to develop a script that will check all of our organisations various NetWorker Storage Nodes and return what datazone passphrase the node is using.
The script I have developed so far consists of a .vbs script that generates an import file to be passed to the nsradmin command and the output from this command to be piped to an export file.
The command therefore looks like this:
nsradmin -i import.txt > export.txt
The import file consists of multiple commands; one for each node in organisation; and they are formatted as below:
server
show datazone pass phrase print type: nsr
quit
Where node name is the name of the individual node bein quried, then there is a single quit command at the end of the import file.
This generates output as per below:
Bound to:
hostname: ; ONC program number: 390109; ONC version number: 2; resource identifier: 0(0); datazone pass phrase: password;
Where password is the current pass phrase for the node.
This all works properly until a server is unavailable or not contactable i.e. network issues, powered off, etc. The nsradmin command in this instance then returns the pass phrase from the last node it successfully queried from the import file; this is a major issue.
However if you run the same command individually to that server direct from command line and don't use an import file it returns an error "Can't bind to server" or similar.
So the two questions are 1) why the discrepency in behaviour between running the command individually and as part of a improt file and 2) is there any option to switch on error checking on the nsradmin command?
All assistance gratefully received as this is causing major headaches.
I suspect the discrepancy in behaviour may be something to do with the running of nsradmin in online mode or in offline mode in the two scenarios. If I were you, I'd do a connection check at the start of the script on each of the machines and develop a list of ok hosts. Then run the nsradmin command against each host on the list.
I had considered something along these lines, initially thinking that a simple ping test to each node might do, but then determined I would also need to ensure that the networker services are running, that they can be contacted i.e. no firewall blocking.
I was therefore hoping to solve the underlying issue of why / how the nsradmin command appears to be caching the last node that a command ran on rather than return the "can't bind to server" message that it returns when run directly from command line.
Is there a way of clearing out the results between queries, for example,
server abc
show datazone pass phrase print type: nsr
[ clear query ]
server def
show datazone pass phrase print type: nsr
[ clear query ]
server xyz
show datazone pass phrase print type: nsr
[ clear query ]
quit
If not may have to look at changing or abandoning use of import file.
Why would your storage nodes have different datazone pass phrases? I thought the pass phrase was per datazone.
If you were to test the connectivity, then rpcinfo would be better than ping, but I understand why you don't want to do that. If you suspect that nsradmin is caching results, then you could try running the nsradmin command as a single line from your script like this:
Unfortunately rightly or wrongly we do have several datazones each with a storage node backing up that zone.
We only use a centralised Enterprise management console to administer and monitor the organisations backups across these zones.
So to set or check a passphrase we woudl still need to manually select each node listed and launch networker console and the networker management console.and then click Properties and check under configuration tab.
The script was intended to avoid this process by automating a check for each node and confirming the password and email us a summary, so that if it has been changed for any reason we have time to correct it before that evening's backups run.
Try to use echo instead of printf... I admit that on Windows it might be different as I use UNIX, but at least printf part I'm sure can be replaced with echo command.
I have just tried several variations of using echo to pipe the query to the NSRADMIN command and in turn direct the output to a text file but I cannot see any way on a windows o/s to replicate the printf functionality.
For instance:
echo "print datazone pass phrase \n print type : NSR \n" | nsradmin -i - -s test
returns: -
unknown command: "show"
Just to reiterate what I am trying to achieve ...
We have for arguments sake 10 sites.
Each site hosts a backup server which backs up itself and for arguments sake 10 others clients.
One of the 10 servers is used as our Enterprise NetWorker Management Console; so listed under our orgnisation in this NMC we see our 10 servers.
Each server listed in this manner has it's own datazone pass phrase.
We need a way to automatically interogate each server in turn to retrieve the current pass phrase so that we can ensure it is correct, we want to do this via use of a script that can be schedule via Windows Task Scheduler on the NMC machine, which has access through any firewalls, security, etc o all other servers.
coganb
736 Posts
814
0
Posted August 30th, 2011 07:00
Hi,
I suspect the discrepancy in behaviour may be something to do with the running of nsradmin in online mode or in offline mode in the two scenarios. If I were you, I'd do a connection check at the start of the script on each of the machines and develop a list of ok hosts. Then run the nsradmin command against each host on the list.
-Bobby