[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: filter utility to send cron e-mail only if unexpected output



On Mon, May 11, 2009 at 12:07:18PM -0400, Barclay, Daniel wrote:
> Boyd Stephen Smith Jr. wrote:
> > In <4A01AC7B.4010101@fgm.com>, Barclay, Daniel wrote:
> >> Does Debian have any utility to address the following situation?
> > 
> > Not that I know of.
> > 
> >> I have some scripts that I run both manually and as cron jobs.  The
> >> scripts generate stdout/stderr output reporting what they're doing.
> >>
[snip]

> 
> >> I started to write a wrapper script to take a command to execute and a
> >> file of regular expressions defining expected output lines ...
> ...
> > If you can't / won't fix your scripts, Here's a start on that wrapper:
> 
> Yes, I have a start.

I have a script that checks for ppp session outages through syslog, I
only want to be notified of changes, i save output and then diff it with
new output.  You could use something similiar, have a template of what
you don't want and filter it out, basically you need to post process
your output


#!/bin/bash


OLDF="/var/tmp/pppsession.old"
NEWF="/var/tmp/pppsession.new"


[ ! -e  "$OLDF" ] && > "$OLDF"

egrep "sydrt.. *ppp.*Connect.time" /var/log/syslog{.1,} > "$NEWF"


if ! diff  "$OLDF" "$NEWF"
then
        echo "-----------"
        mv "$NEWF" "$OLDF"
        cat "$OLDF"
fi

exit 0


> 
> 
> 
> Daniel

Attachment: signature.asc
Description: Digital signature


Reply to: