[ic] errors by email

Mike Heins mike at perusion.com
Mon Jul 28 10:00:45 EDT 2003


Quoting Xavier GILLET (xavier.gillet.perso at wanadoo.fr):
> Hi,
> 
> How can I do to receive by email each error recorded in the log ?

You can't do it for the catalog error log, but for the system error.log
Interchange has syslog() capability.

	Syslog command logger

You can use syslog(8) to direct messages to specific machines, and
you can send them to a fifo as Stefan suggested. But if you change
the command, you could mail it yourself. This is NOT recommended,
but here goes.

You set up this script and call it /usr/local/bin/mailerror:

#!/usr/bin/perl

    use Getopt::Std;

    my $flags = join " ", @ARGV;

    use vars qw/$opt_p $opt_t $opt_u/;

    getopts('p:t:u:');

    my $subject = "Interchange error: $flags";
    my $to = $opt_t || 'root';
	my $from = 'interch at localhost';

    undef $/;

    my $body = <>;

    my $msg = <<EOF;
Subject: $subject
To: $to
From: Interchange error mailer <$from>

$body
EOF

    open MAIL, "| /usr/sbin/sendmail -t" or die "Cannot fork: $!\n";
    print MAIL $msg;
    close MAIL;

__END__

And put this in interchange.cfg:

	Syslog  command  /usr/local/bin/mailerror
	Syslog  tag      xavier at somwhere.com

It should work.
-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike at perusion.com>

Research is what I'm doing when I don't know what I'm doing.
-- Wernher Von Braun


More information about the interchange-users mailing list