--=====================_346749375==.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed
Here is a Perl function that parses this output neatly. For each line of
bpdbjobs output, pass it into parse_bpdbjobs() and you will
get back a Perl hash of key / value pairs.
--PLB
use Text::ParseWords;
##
## parse_bpdbjobs()
##
## This function is derived from the following Veritas command:
##
## /usr/openv/netbackup/bin/admincmd/bpdbjobs
##
## --PLB 12/19/2001
##
## This function is Copyright (C) 2002 Peter L. Buschman.
## ( Derived from the NBUX Toolkit. )
##
sub parse_bpdbjobs {
$_ = shift;
my $tmpfile;
chomp;
s/'/\\'/g; # Escape any un-escaped single quotes.
##
## jobid,jobtype,state,status,class,schedule, client, server, started,
elapsed,
## ended, stunit, try, operation, kbytes, files, pathlastwritten, percent,
## jobpid, owner, subtype, classtype, schedule_type, priority, group,
## masterserver, retentionunits, retentionperiod, compression,
## kbyteslastwritten, fileslastwritten, filelistcount, [files]..., trycount,
## [trypid, trystunit, tryserver, trystarted, tryelapsed, tryended,
trystatus,
## trystatusdescription, trystatuscount, [trystatuslines]...,
trybyteswritten,
## tryfileswritten]
##
my(
$jobid,
$jobtype,
$state,
$status,
$class,
$schedule,
$client,
$server,
$started,
$elapsed,
$ended,
$stunit,
$try,
$operation,
$kbytes,
$files,
$pathlastwritten,
$percent,
$jobpid,
$owner,
$subtype,
$classtype,
$schedule_type,
$priority,
$group,
$masterserver,
$retentionunits,
$retentionperiod,
$compression,
$kbyteslastwritten,
$fileslastwritten,
@files_and_tries,
) = parse_line(",", 0, $_);
for( $jobtype ) {
/0/ and do { $jobtype = "backup" ; last };
/1/ and do { $jobtype = "archive" ; last };
/2/ and do { $jobtype = "restore" ; last };
}
for( $state ) {
/0/ and do { $state = "queued" ; last };
/1/ and do { $state = "active" ; last };
/2/ and do { $state = "re-queued" ; last };
/3/ and do { $state = "done" ; last };
}
my($filelistcount) = shift(@files_and_tries);
my(@files);
for(1..$filelistcount) {
# Skip leading and trailing whitespace
$tmpfile = shift @files_and_tries;
$tmpfile =~ s/^\s*//;
$tmpfile =~ s/\s*$//;
push( @files, $tmpfile );
}
my($specifiedfiles) = join(", ", @files);
my($trycount) = shift(@files_and_tries);
my(%tries,$trynum);
foreach $trynum (1..$trycount) {
my($trypid) = shift(@files_and_tries);
my($trystunit) = shift(@files_and_tries);
my($tryserver) = shift(@files_and_tries);
my($trystarted) = shift(@files_and_tries);
my($tryelapsed) = shift(@files_and_tries);
my($tryended) = shift(@files_and_tries);
my($trystatus) = shift(@files_and_tries);
my($trystatusdescription) = shift(@files_and_tries);
my($trystatuscount) = shift(@files_and_tries);
my(@trystatuslines);
for(1..$trystatuscount) {
push(@trystatuslines, shift(@files_and_tries) );
}
my($trystatuslines) = join("\n", @trystatuslines);
my($trykbyteswritten) = shift(@files_and_tries);
my($tryfileswritten) = shift(@files_and_tries);
%tries = (
%tries,
"try_${trynum}_pid" => "$trypid",
"try_${trynum}_stunit" => "$trystunit",
"try_${trynum}_server" => "$tryserver",
"try_${trynum}_started" => "$trystarted",
"try_${trynum}_elapsed" => "$tryelapsed",
"try_${trynum}_ended" => "$tryended",
"try_${trynum}_status" => "$trystatus",
"try_${trynum}_statusdescription" => "$trystatusdescription",
"try_${trynum}_statuscount" => "$trystatuscount",
"try_${trynum}_statuslines" => "$trystatuslines",
"try_${trynum}_kbyteswritten" => "$trykbyteswritten",
"try_${trynum}_fileswritten" => "$tryfileswritten",
);
}
my($record) = {
jobid=> "$jobid",
jobtype=> "$jobtype",
state=> "$state",
status=> "$status",
class=> "$class",
schedule=> "$schedule",
client=> "$client",
server=> "$server",
started=> "$started",
elapsed=> "$elapsed",
ended=> "$ended",
stunit=> "$stunit",
try=> "$try",
operation=> "$operation",
kbytes=> "$kbytes",
files=> "$specifiedfiles",
path=> "$pathlastwritten",
percent=> "$percent",
jobpid=> "$jobpid",
owner=> "$owner",
subtype=> "$subtype",
classtype=> "$classtype",
schedule_type=> "$schedule_type",
priority=> "$priority",
group=> "$group",
masterserver=> "$masterserver",
retentionunits=> "$retentionunits",
retentionperiod=> "$retentionperiod",
compression=> "$compression",
kbyteslastwritten=> "$kbyteslastwritten",
fileslastwritten=> "$fileslastwritten",
filelistcount=> "$filelistcount",
files=> "$specifiedfiles",
trycount=> "$trycount",
};
%$record = (%$record, %tries);
return %$record;
}
At 09:46 AM 11/10/2003 -0700, Donaldson, Mark wrote:
>Storage Mountain's FAQ
>(<http://www.storagemountain.com>http://www.storagemountain.com) has a
>nice writeup about this output. The tricky thing to deal with is that the
>field count per line differs by job.
>
>-M
>-----Original Message-----
>From: Nick Lefebvre [mailto:nick AT solnet.com DOT au]
>Sent: Sunday, November 09, 2003 9:02 PM
>To: veritas-bu AT mailman.eng.auburn DOT edu
>Subject: [Veritas-bu] bpdbjobs script
>
>Hi,
>
>
>
>I am running the following command:
>
>
>
># ./bpdbjobs report all_columns
>
>
>
>The output is messy.
>
>
>
>I was wondering whether anyone would have a script to turn this into
>something that makes sense?
>
>
>
>Thanks for your help.
>
>
>
>Cheers,
>
>
>
>Nick
--=====================_346749375==.ALT
Content-Type: text/html; charset="us-ascii"
<html>
<body>
<br>
Here is a Perl function that parses this output neatly. For each
line of bpdbjobs output, pass it into parse_bpdbjobs() and you will<br>
get back a Perl hash of key / value pairs.<br><br>
--PLB<br><br>
<tt>use Text::ParseWords;<br><br>
##<br>
## parse_bpdbjobs()<br>
##<br>
## This function is derived from the following Veritas command:<br>
##<br>
## /usr/openv/netbackup/bin/admincmd/bpdbjobs<br>
##<br>
## --PLB 12/19/2001<br>
##<br>
## This function is Copyright (C) 2002 Peter L. Buschman.<br>
## ( Derived from the NBUX Toolkit. )<br>
##<br>
sub parse_bpdbjobs {<br>
$_ = shift;<br>
my $tmpfile;<br>
chomp;<br>
s/'/\\'/g; # Escape any un-escaped single quotes.<br>
##<br>
## jobid,jobtype,state,status,class,schedule, client, server,
started, elapsed,<br>
## ended, stunit, try, operation, kbytes, files, pathlastwritten,
percent,<br>
## jobpid, owner, subtype, classtype, schedule_type, priority,
group,<br>
## masterserver, retentionunits, retentionperiod,
compression,<br>
## kbyteslastwritten, fileslastwritten, filelistcount, [files]...,
trycount,<br>
## [trypid, trystunit, tryserver, trystarted, tryelapsed,
tryended, trystatus,<br>
## trystatusdescription, trystatuscount, [trystatuslines]...,
trybyteswritten,<br>
## tryfileswritten]<br>
##<br>
my(<br>
$jobid,<br>
$jobtype,<br>
$state,<br>
$status,<br>
$class,<br>
$schedule,<br>
$client,<br>
$server,<br>
$started,<br>
$elapsed,<br>
$ended,<br>
$stunit,<br>
$try,<br>
$operation,<br>
$kbytes,<br>
$files,<br>
$pathlastwritten,<br>
$percent,<br>
$jobpid,<br>
$owner,<br>
$subtype,<br>
$classtype,<br>
$schedule_type,<br>
$priority,<br>
$group,<br>
$masterserver,<br>
$retentionunits,<br>
$retentionperiod,<br>
$compression,<br>
$kbyteslastwritten,<br>
$fileslastwritten,<br>
@files_and_tries,<br>
) = parse_line(",", 0, $_);<br>
for( $jobtype ) {<br>
/0/ and do { $jobtype =
"backup" ; last };<br>
/1/ and do { $jobtype =
"archive" ; last };<br>
/2/ and do { $jobtype =
"restore" ; last };<br>
}<br>
for( $state ) {<br>
/0/ and do { $state =
"queued" ; last };<br>
/1/ and do { $state =
"active" ; last };<br>
/2/ and do { $state =
"re-queued" ; last };<br>
/3/ and do { $state =
"done" ; last
};<br>
}<br>
my($filelistcount)
= shift(@files_and_tries); <br>
my(@files);<br>
for(1..$filelistcount) {<br>
# Skip leading and trailing
whitespace<br>
$tmpfile = shift @files_and_tries;<br>
$tmpfile =~ s/^\s*//;<br>
$tmpfile =~ s/\s*$//;<br>
push( @files, $tmpfile );<br>
}<br>
my($specifiedfiles) = join(", ",
@files);<br>
my($trycount)
= shift(@files_and_tries);<br>
my(%tries,$trynum);<br>
foreach $trynum (1..$trycount) {<br>
my($trypid)
= shift(@files_and_tries);<br>
my($trystunit)
= shift(@files_and_tries);<br>
my($tryserver)
= shift(@files_and_tries);<br>
my($trystarted)
= shift(@files_and_tries);<br>
my($tryelapsed)
= shift(@files_and_tries);<br>
my($tryended)
= shift(@files_and_tries);<br>
my($trystatus)
= shift(@files_and_tries);<br>
my($trystatusdescription) =
shift(@files_and_tries);<br>
my($trystatuscount)
= shift(@files_and_tries);<br>
my(@trystatuslines);<br>
for(1..$trystatuscount) {<br>
push(@trystatuslines,
shift(@files_and_tries) );<br>
}<br>
my($trystatuslines) = join("\n",
@trystatuslines);<br>
my($trykbyteswritten) =
shift(@files_and_tries);<br>
my($tryfileswritten) =
shift(@files_and_tries);<br>
%tries = (<br>
%tries,<br>
"try_${trynum}_pid"
=> "$trypid",<br>
"try_${trynum}_stunit"
=> "$trystunit",<br>
"try_${trynum}_server"
=> "$tryserver",<br>
"try_${trynum}_started"
=> "$trystarted",<br>
"try_${trynum}_elapsed"
=> "$tryelapsed",<br>
"try_${trynum}_ended"
=> "$tryended",<br>
"try_${trynum}_status"
=> "$trystatus",<br>
"try_${trynum}_statusdescription" =>
"$trystatusdescription",<br>
"try_${trynum}_statuscount"
=> "$trystatuscount",<br>
"try_${trynum}_statuslines"
=> "$trystatuslines",<br>
"try_${trynum}_kbyteswritten" =>
"$trykbyteswritten",<br>
"try_${trynum}_fileswritten"
=> "$tryfileswritten",<br>
);<br>
}<br>
my($record) = {<br>
jobid=>
"$jobid",<br>
jobtype=>
"$jobtype",<br>
state=>
"$state",<br>
status=>
"$status",<br>
class=>
"$class",<br>
schedule=>
"$schedule",<br>
client=>
"$client",<br>
server=>
"$server",<br>
started=>
"$started",<br>
elapsed=>
"$elapsed",<br>
ended=>
"$ended",<br>
stunit=>
"$stunit",<br>
try=>
"$try",<br>
operation=>
"$operation",<br>
kbytes=>
"$kbytes",<br>
files=>
"$specifiedfiles",<br>
path=>
"$pathlastwritten",<br>
percent=>
"$percent",<br>
jobpid=>
"$jobpid",<br>
owner=>
"$owner",<br>
subtype=>
"$subtype",<br>
classtype=>
"$classtype",<br>
schedule_type=>
"$schedule_type",<br>
priority=>
"$priority",<br>
group=>
"$group",<br>
masterserver=>
"$masterserver",<br>
retentionunits=>
"$retentionunits",<br>
retentionperiod=>
"$retentionperiod",<br>
compression=>
"$compression",<br>
kbyteslastwritten=>
"$kbyteslastwritten",<br>
fileslastwritten=>
"$fileslastwritten",<br>
filelistcount=>
"$filelistcount",<br>
files=>
"$specifiedfiles",<br>
trycount=>
"$trycount",<br>
};<br>
%$record = (%$record, %tries);<br>
return %$record;<br>
}<br><br>
<br>
</tt>At 09:46 AM 11/10/2003 -0700, Donaldson, Mark wrote:<br>
<blockquote type=cite class=cite cite><font face="arial" size=2
color="#0000FF">Storage
Mountain's FAQ
(<a href="http://www.storagemountain.com">http://www.storagemountain.com</a>)
has a nice writeup about this output. The tricky thing to deal with
is that the field count per line differs by job.</font><br>
<br>
<font face="arial" size=2 color="#0000FF">-M</font><br>
<dl>
<dd><font face="tahoma" size=2>-----Original Message-----<br>
<dd>From:</b> Nick Lefebvre
[<a href="mailto:nick AT solnet.com DOT au" eudora="autourl">mailto:nick AT
solnet.com DOT au</a>]<br>
<dd>Sent:</b> Sunday, November 09, 2003 9:02 PM<br>
<dd>To:</b> veritas-bu AT mailman.eng.auburn DOT edu<br>
<dd>Subject:</b> [Veritas-bu] bpdbjobs script<br><br>
</font>
<dd><font face="arial" size=2>Hi,<br>
</font><br>
<dd> <br><br>
<dd><font face="arial" size=2>I am running the following command:<br>
</font><br>
<dd> <br><br>
<dd><font face="arial" size=2># ./bpdbjobs report all_columns<br>
</font><br>
<dd> <br><br>
<dd><font face="arial" size=2>The output is messy.<br>
</font><br>
<dd> <br><br>
<dd><font face="arial" size=2>I was wondering whether anyone would have a
script to turn this into something that makes sense?<br>
</font><br>
<dd> <br><br>
<dd><font face="arial" size=2>Thanks for your help.<br>
</font><br>
<dd> <br><br>
<dd><font face="arial" size=2>Cheers,<br>
</font><br>
<dd> <br><br>
<dd><font face="arial" size=2>Nick<br>
</font>
</dl></blockquote></body>
</html>
--=====================_346749375==.ALT--
|