Hey there,
Many of you who use FeedBurner (or whatever smaller, productive, company Google's bought out this week ;) to get blog posts by email have probably already gotten this post even before I finished writing it. I made the cardinal sin of hitting the enter key while I wrote this post online :P I apologize for your (quite understandable) previous confusion ;)
Today's post will be short and sweet, since it's getting late in the day and I'm still working and I don't think I get to sleep in tomorrow either... With that in mind, I tried to make this post heavier on content and have been working on it (on and off) all day. Again, I also apologize for the quality of the video attached to this post, which shows the output of the script. It's very very slow and does not accurately reflect the refresh rate of the PuTTY terminal I was running the program on ;) I had to download 3 or 4 different video processing "portable apps" so that I could try and put something together. I'm not "allowed" to install anything anywhere except for my desktop (and I'm not really sure if that's 100% kosher, which is why those programs are no longer installed) and I had to take what I could get.
Today's Bash script is my first attempt at rewriting one of those oldies-but-goodies that got away. A few years ago, I wrote a TUI Activity Monitor for Veritas NetBackup (In Perl, not like this one in Bash), since that was the only thing I ever used the GUI for. Somehow, over the years, I misplaced the CD (or maybe floppy ;) that I had it saved on and I've finally come to peace with the fact that I'll probably never ever find it again.
This script is much less glitzy than the old one, but it's a good starting point, and I hope a few people (aside from me ;) find it useful. It's a very simple program to run, since it only takes one optional variable (The refresh rate in seconds - defaulted at 10) and, as yet, does not have any special functionality built in. And, yes, you should read that as "The output formatting is God Awful!" :)
Check out the video below to watch a few backup jobs, and a catalog job, run in slooooooooooooooooooo-mo ;) Then grab the script and put it to good use. If you can make it better (I know I can, so there must be thousands of you out there who can, too :), feel free to improve upon it before I get around to that. I try to stay away from exporting Java GUI's over X-Windows as often as I possibly can (especially when working on systems overseas or across-country), and I've been meaning to rewrite this script for a long long time.
If this video makes you feel drowsy, download it and play it at double speed in the player of your choice. For some reason, it recorded at half speed and I ran out of time to try and figure out why ;)
And here's the script. Enjoy it and abuse it in good health :)
This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
, Mike #!/bin/bash
#
# nbuvtam - v1 of the netbackup vt activity monitor
#
# 2009 - Mike Golvach - eggi@comcast.net
#
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
#
trap 'exit 0' 2
perl=`which perl`
if [ ! -z $1 ]
then
refresh=$1
else
refresh=10
fi
function local_time()
{
regular_time=$(perl -e "print scalar(localtime($1))")
echo -n "$regular_time"
}
jobtype_array=(backup archive restore verify duplicate import catalogue_backup vault label erase tape_request clean format_tape physical_inventory qualification)
state_array=(queued active wait_for_retry done)
operation_array=(mount position connect write vault_initialize vault_duplication vault_duplication_complete vault_catalog_backup vault_eject report duplicate import verify restore catalog_backup vault label erase)
subtype_array=(immediate scheduled user_initiated quick_erase long_erase)
schedule_type_array=(full incr user_backup user_archive cumulative_incr)
tput clear
OLDIFS=$IFS
IFS=","
while :
do
tput clear
echo "======================================================================="
echo "THE TOTALLY LAME VERITAS NETBACKUP COMMAND LINE ACTIVITY MONITOR"
echo "V0.0000000001-alpha - Ctl-C to Quit"
echo "======================================================================="
echo "jobid type state state_details status policy schedule client media_server start_time elapsed_time end_time storage_unit attempt operation kilobytes files pathname percent_complete job_pid owner master"
echo "======================================================================="
echo "======================================================================="
while read jobid jobtype state status policy schedule client server started elapsed ended storage_unit attempt operation kilobytes number_of_files path_last_written percent jobpid owner subtype classtype scheduled_type priority group master_server retention_unit retention_period compression kb_last_written files_last_written file_list_count files the_rest
do
start_time=$(local_time $started)
end_time=$(local_time $ended)
elapsed=$(echo $elapsed|sed 's/^0*//g')
hours=$((elapsed / 3600))
elapsed=$((elapsed % 3600))
minutes=$((elapsed / 60))
elapsed=$((elapsed % 60))
if [[ $hours -lt 10 ]]
then
hours="0$hours"
fi
if [[ $minutes -lt 10 ]]
then
minutes="0$minutes"
fi
if [[ $elapsed -lt 10 ]]
then
elapsed="0$elapsed"
fi
echo "$jobid ${jobtype_array[${jobtype}]} ${state_array[${state}]} ${operation_array[${operation}]} $policy ${schedule_type_array[${schedule}]} $client $server $start_time $elapsed_time $end_time $storage_unit $attempt $operation $kilobytes $number_of_files $path_last_written ${percent}% $jobpid $owner $master_server"
echo "---------------------------------------------------------------"
done <<< "`/usr/openv/netbackup/bin/admincmd/bpdbjobs -all_columns|head -5`"
sleep $refresh
done
Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.