[펌] EMC Networker: export list of clients to csv file

2012. 5. 17. 08:28

EMC Networker: export list of clients to csv file

1/ Presentation
For some reasons, mainly reporting/quality ones &#59;), one might have to export a list of the clients currently backed up by a Networker server.

When it comes to access the Networker configuration from the command lines a few tools appear to be very useful:

  • mminfo
  • nsradmin

among others. Therefore you are invited to have a look at the man pages of these tools.

2/ The request one can face
In order to comply with some reporting/quality policies, one might want to get the list of Networker clients currently in use, with their DescriptionGroupsSave setBrowse Policy andRetention Policy.
The nsradmin tool will then be used.
Let’s see how the nsradmin script looks like:

[root@nwserver ~]# cat /tmp/clientlist.cmd
. type: nsr client;scheduled backup: Enabled
show name;group;comment;"save set";"browse policy";"retention policy"
print
root@nwserver:~#

Running this script leads to the result one might expect, displaying every enabled clients, with their namegroupcomment/descriptionsave set and browse and retention policies. But the format of the output is not quite easy to work with when building reports (integration in an Excel spreadsheet for instance).
Let’s see an example:

[root@nwserver ~]# nsradmin -i /tmp/clientlist.cmd
[...]
                       name: gw.domain.com;
                     comment: Gateway main;
               browse policy: Year;
            retention policy: 10 ans;
                       group: FULL 1st quarter;
                    save set: All;

                        name: logs.domain.com;
                     comment: Logs server;
               browse policy: Year;
            retention policy: 3 ans;
                       group: Full Q2 Q3 Q4;
                    save set: All;
[...]

3/ Building a CSV format report from these data
In order to make these data easily workable, a Perl script is being used, translating this raw output from nsradmin to a CSV format.

You can fin the script here

Have a look at the content of this script as you might want to modify some parameters:

$nsradmin_cmd = "/nsr/sbin/nsradmin";
$tmp_cmd_file = "/tmp/clientlist.cmd";
$tmp_csv_file = "/tmp/clientlist.csv";

where tmp_csv_file is the CSV output file.

The script is quite simple. It is simply using a hash of hashes to parse the output from thensradmin script:

%result = ( "_name" => {
                comment => "Description",
                groups => {
                        group   => "Backup Group",
                        saveset => "Save set",
                        brpol   => "Browse Policy",
                        retpol  => "Retention Policy"
                        },
                },
);

This part of the script initializes the hash of hashes with entries that stand for the header of the resulting table.
Then the hash of hashes is built using a for loop:

$svrname="";
$savegrp="";
$grpidx=0;
for $rawlist_el(@rawlist) {
        $field = substr($rawlist_el,0,28);
        $field =~ s/^\s+|\s+$//g;
        chomp $field;
        $data = substr($rawlist_el,30);
        chomp $data;
        chop $data;
        switch ($field) {
                case "name"     { $svrname = $data; $grpidx++; }
                case "comment"  { $result{"$svrname"}{"comment"} = "$data"; }
                case "group"    { 
                       $result{"$svrname"}{"groups$grpidx"}{"group"} = "$data "; }
                case "save set" {
                       $result{"$svrname"}{"groups$grpidx"}{"saveset"} .= "$data "; }
                case "browse policy"    { 
                       $result{"$svrname"}{"groups$grpidx"}{"brpol"} .= "$data "; }
                case "retention policy" { 
                       $result{"$svrname"}{"groups$grpidx"}{"retpol"} .= "$data "; }
                case "" { 
                       $result{"$svrname"}{"groups$grpidx"}{"saveset"} .= "$data "; }
        }
}

An index (grpidx) is used as a client can belong to multiple groups.
The values 28 and 30 might be adjusted but are a match on the server that I’m working with.
They are corresponding to the number of char used for the first field in the nsradmin output.

4/ Use of the output
Once the CSV file has been generated, it can be imported in Excel or in any Spreadsheet tool, and can be easily manipulated to generate reports.

Enjoy…

밥짓는아이 테크노트/Linux, Unix