parsing oncheck output
Posted in 1997
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.
Can anyone help?
-- 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