#!/bin/ksh ## ## Creates three !bang delimited files in /tmp which are combined to create ## a master list of all Legato clients which is sent to stdout. The master ## list columns are: client name, schedule, group, save set, group start time, ## and daily backup level (seven columns Sun thru Sat). ## ## The script is setup only to work on clients with a weekly backup rotation. ## The script puts only one group and one save set per line in the final output. ## Thus if your client configuration has five databases all listed in one ## client (i.e. five save sets) being backed up twice daily (i.e. two groups) ## the final output will have ten lines for this client. ## ## I created this script to allow all this data to be easily brought into a ## spreadsheet, massaged, beautified, and presented to the muckity-mucks. ## ## ## The first line of the script should produce output similar to: # # NetWorker administration program. # Use the "help" command for help, "visual" for full-screen mode. # nsradmin> nsradmin> name: server1; # schedule: Wed; # group: Wed; # save set: All; # # name: server2; # schedule: Sat; # group: Sat; # save set: All; # ## and in this exact order*, which my system does each time auto-magically. ## Test your system first to see if yours behaves like mine, if it doesn't ## some mods will be necessary. There are some assumptions in my script ## but with little (hopefully) or some (probably) mods it should work for ## you. ## ## *NOTE: If your group or schedule names contain spaces use perlmassage.sh ## which can be downloaded from: # http://www.arizonaed.com/unix/perlmassage.sh # http://www.arizonaed.com/unix/perlmassage.txt ## ## ## Ed Arizona 11-Feb-2004 ## (echo "show group; save set; name; schedule \nprint type: nsr client\n\nquit\n") | nsradmin | egrep -iv "networker|visual" | sed -e 's/nsradmin>//g'\ -e 's/^$/!/g'\ -e 's/^[ ]*"SYSTEM/save set: "SYSTEM/g'\ -e 's/ //g'\ -e 's/ //'\ #this is a tab, not spaces--remove this comment too -e 's/"//g'\ -e 's/ //g'\ -e 's/:/=/' | perl -le ' while ( <> ) { chomp; ($key,$value)=split /=/; $record{$key}=$value; if ( $key =~ /save/ ) { @GROUPS=split /,/, $record{group}; @SAVESETS=split /,/, $record{saveset}; $num=0; foreach (@GROUPS) { $REC[++$num]="$record{name}!$record{schedule}!$_"; foreach (@SAVESETS) { printf "%s!%s\n",$REC[$num],$_; } } } } ' | sed 's/;//g' | sort > /tmp/servers (echo "show name; comment; action\nprint type: nsr schedule; period: Week\n\nquit\n") | nsradmin | awk ' BEGIN { getline; getline; } $0 ~ /^$/ { print; next; } { printf "%s!",$0; } END { print }' | sed -e 's/nsradmin>//g'\ -e 's/ //g'\ -e 's/ //'\ #this is a tab, not spaces--remove this comment too -e 's/name: //'\ -e 's/comment: //'\ -e 's/action: //'\ -e 's/"//g'\ -e 's/;//g' | sort > /tmp/schedules (echo "show name; start time \nprint type: nsr group \n\nquit\n") | nsradmin | awk ' BEGIN { getline; getline; } $0 ~ /^$/ { print; next; } { printf "%s!",$0; } END { print }' | sed -e 's/nsradmin>//g'\ -e 's/ //g'\ -e 's/ //'\ #this is a tab, not spaces--remove this comment too -e 's/name: //'\ -e 's/start time: //'\ -e 's/"//g'\ -e 's/;//g' | sort > /tmp/groups ### Use three output files, servers, schedules, and groups ### to create final output for input into a spreadsheet for i in `cat /tmp/servers` do schedule="" group="no group" sch=`echo $i | cut -d! -f2` if [ "$sch" != "" ]; then schedule=`grep -i ${sch}! /tmp/schedules | cut -d! -f3 | sed 's/ /!/g'` fi gr=`echo $i | cut -d! -f3` if [ "$gr" != "" ]; then group=`grep -i ${gr}! /tmp/groups | cut -d! -f2` fi echo ${i}!${group}!${schedule} done