how to parse oncheck output?
Posted in 1998
I've written a short script to run all of the consistency checks
recommended in chapter 31 of the Administrator's Guide:
----------------------------------------------------------------------
#!/usr/bin/perl
open DBLIST, "echo 'select name,owner,created,flags from sysdatabases'
| dbaccess sysmaster - 2>&1 |"
or die "can't open dbacess pipe: $!\\n";
while (<DBLIST>) { push @dblist, $1 if
/^(\\w+)\\s+\\S+\\s+\\d\\S+\\d\\s+\\d+\\s*$/ }
close DBLIST;
print `oncheck -cr`;
print `oncheck -ce`;
print `oncheck -cc`;
foreach $db (@dblist)
{ print `oncheck -cI $db`;
print `oncheck -cD $db`;
}
----------------------------------------------------------------------
What I'd like to do is run it from crontab and have it mail its output
to a few people. But, oncheck is really verbose! I'd like it to send
mail only if there's an actual problem that someone needs to worry
about. It would be trivial for me to change those backtick calls into
opens of pipes, and have perl parse the output to figure out if it's
worth mailing out. Unfortunately, I have no clue what to look for.
There doesn't seem to be any regular format for what oncheck spews
out, nor is the format of its messages and error indications
documented anywhere that I can find.
One possible rule might be:
Look for the word "error". Starting with the line that has the word
"error", continue until you reach a blank line. That block of text is
the entire error message for an actual problem.
If that were true, I could write my script accordingly. It seems like
a plausible rule to me, based on what I've seen of oncheck output so
far, but without documentation I just don't *know*. I don't want to
make a guess that will end up suppressing actual error messages that
we need to see, leading to a false sense of confidence. But I also
don't want to mail out the entire output every day, because people
will stop reading it.
I posted this question once before, about a year ago. I got one
followup, but it was a big .shar of a bunch of shell & sed scripts
that did a whole bunch of things not directly related to my question,
and it was written for and tested Informix 5 whereas I'm running 7.22
I don't actually want any scripts, because I want to tailor my script
to our local needs anyway, and I definitely want to keep it all in
perl. All I want is some documentation, or pointer to documentation,
or description, of all the kinds of output oncheck might produce and
how an automated script is supposed to be able to figure out what is
important to report about. Since our database is mostly fine, and has
always been so, I've never actually SEEN any real errors reported by
oncheck, so I have no idea what they would look like when they do
appear. I want to make sure my script will be able to handle anything
oncheck throws at it. For example, being told "a serious error will
aways start with the word 'ERROR:'", in and of itself, isn't helpful
because perhaps some errors give multiline output, and I'd need to
know how to identify those, and how to identify where the error
message ends.
I'm not afraid of reading manuals, but I just can't find this
information and I don't know where to look for it.
-- Cos (Ofer Inbar) -- cos@leftbank.com cos@cs.brandeis.edu
-- The Left Bank Operation -- lbo@leftbank.com http://www.leftbank.com/
It's been said that if a sysadmin does his job perfectly, he's the
fellow that people wonder what he does and why the company needs him,
until he goes on vacation. -- comp.unix.admin FAQ