[syslog-ng]Sending Email via syslog-ng

syslog-ng@lists.balabit.hu syslog-ng@lists.balabit.hu
Tue, 10 Feb 2004 14:37:53 +0100


This is a multipart message in MIME format.
--=_alternative 004AE5C4C1256E36_=
Content-Type: text/plain; charset="us-ascii"

Hi,

im trying to send email with syslog-ng, i have configurations
like this:

destination ruf_mich_an { program("/usr/local/sbin/log_to_mail.pl"); };
filter ruf_mich_an2 { facility(cron); };
log { source(net); filter(ruf_mich_an2); destination(ruf_mich_an); };

or things like:

destination d_cachos_dns_ldap_errors2 {
        program("/usr/local/sbin/log_to_mail.pl");
};

filter f_cachos_dns_error { match("Connection refused on DNS lookup to"); 
};

log { source(net); filter(f_cachos_dns_error); 
destination(d_cachos_dns_ldap_errors2); };


But there comes no mail, that perl script (see below) works correkt
on the Console (takes input for the body from stdin).

But, when i restart syslog-ng, i become 4 Mails, but with only
"761" inside...

Is there any "buffer" available? Means: will i receive a Mail
for _every_ LogEntry, or can i say, all logentries in a defined
time (minute or so). But i also can do that in the Mail Script.

#####################################################

#!/usr/bin/perl
#s/^<[\d]{1,2}>//;
use Socket;
$proto   = getprotobyname('tcp');
$port    = 25;
$address = 192.168.3.12;
socket(Socket_Handle, PF_INET, SOCK_STREAM, $proto);

$sin = sockaddr_in($port,$address);
connect(Socket_Handle,$sin) || die ("Failed $!:");
select(Socket_Handle);
$|=1;
select(STDOUT);

print Socket_Handle "ehlo test\n";
print Socket_Handle "mail from: me\@myhouse.net\n";
print Socket_Handle "rcpt to: irgendwer\@myhouse.net\n";
print Socket_Handle "data\n";
print Socket_Handle "subject: $_\n\n";

print Socket_Handle "$_\r\n";
print Socket_Handle ".\r\n";
print Socket_Handle "quit\n";

while(<Socket_Handle>) {
        print $_;
}

close(Socket_Handle);
--=_alternative 004AE5C4C1256E36_=
Content-Type: text/html; charset="us-ascii"


<br><font size=2 face="sans-serif">Hi,</font>
<br>
<br><font size=2 face="sans-serif">im trying to send email with syslog-ng, i have configurations</font>
<br><font size=2 face="sans-serif">like this:</font>
<br>
<br><font size=2 face="sans-serif">destination ruf_mich_an { program(&quot;/usr/local/sbin/log_to_mail.pl&quot;); };</font>
<br><font size=2 face="sans-serif">filter ruf_mich_an2 { facility(cron); };</font>
<br><font size=2 face="sans-serif">log { source(net); filter(ruf_mich_an2); destination(ruf_mich_an); };</font>
<br>
<br><font size=2 face="sans-serif">or things like:</font>
<br>
<br><font size=2 face="sans-serif">destination d_cachos_dns_ldap_errors2 {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; program(&quot;/usr/local/sbin/log_to_mail.pl&quot;);</font>
<br><font size=2 face="sans-serif">};</font>
<br>
<br><font size=2 face="sans-serif">filter f_cachos_dns_error { match(&quot;Connection refused on DNS lookup to&quot;); };</font>
<br>
<br><font size=2 face="sans-serif">log { source(net); filter(f_cachos_dns_error); destination(d_cachos_dns_ldap_errors2); };</font>
<br>
<br>
<br><font size=2 face="sans-serif">But there comes no mail, that perl script (see below) works correkt</font>
<br><font size=2 face="sans-serif">on the Console (takes input for the body from stdin).</font>
<br>
<br><font size=2 face="sans-serif">But, when i restart syslog-ng, i become 4 Mails, but with only</font>
<br><font size=2 face="sans-serif">&quot;761&quot; inside...</font>
<br>
<br><font size=2 face="sans-serif">Is there any &quot;buffer&quot; available? Means: will i receive a Mail</font>
<br><font size=2 face="sans-serif">for _every_ LogEntry, or can i say, all logentries in a defined</font>
<br><font size=2 face="sans-serif">time (minute or so). But i also can do that in the Mail Script.</font>
<br>
<br><font size=2 face="sans-serif">#####################################################</font>
<br>
<br><font size=2 face="sans-serif">#!/usr/bin/perl</font>
<br><font size=2 face="sans-serif">#s/^&lt;[\d]{1,2}&gt;//;</font>
<br><font size=2 face="sans-serif">use Socket;</font>
<br><font size=2 face="sans-serif">$proto &nbsp; = getprotobyname('tcp');</font>
<br><font size=2 face="sans-serif">$port &nbsp; &nbsp;= 25;</font>
<br><font size=2 face="sans-serif">$address = 192.168.3.12;</font>
<br><font size=2 face="sans-serif">socket(Socket_Handle, PF_INET, SOCK_STREAM, $proto);</font>
<br>
<br><font size=2 face="sans-serif">$sin = sockaddr_in($port,$address);</font>
<br><font size=2 face="sans-serif">connect(Socket_Handle,$sin) || die (&quot;Failed $!:&quot;);</font>
<br><font size=2 face="sans-serif">select(Socket_Handle);</font>
<br><font size=2 face="sans-serif">$|=1;</font>
<br><font size=2 face="sans-serif">select(STDOUT);</font>
<br>
<br><font size=2 face="sans-serif">print Socket_Handle &quot;ehlo test\n&quot;;</font>
<br><font size=2 face="sans-serif">print Socket_Handle &quot;mail from: me\@myhouse.net\n&quot;;</font>
<br><font size=2 face="sans-serif">print Socket_Handle &quot;rcpt to: irgendwer\@myhouse.net\n&quot;;</font>
<br><font size=2 face="sans-serif">print Socket_Handle &quot;data\n&quot;;</font>
<br><font size=2 face="sans-serif">print Socket_Handle &quot;subject: $_\n\n&quot;;</font>
<br>
<br><font size=2 face="sans-serif">print Socket_Handle &quot;$_\r\n&quot;;</font>
<br><font size=2 face="sans-serif">print Socket_Handle &quot;.\r\n&quot;;</font>
<br><font size=2 face="sans-serif">print Socket_Handle &quot;quit\n&quot;;</font>
<br>
<br><font size=2 face="sans-serif">while(&lt;Socket_Handle&gt;) {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; print $_;</font>
<br><font size=2 face="sans-serif">}</font>
<br>
<br><font size=2 face="sans-serif">close(Socket_Handle);</font>
--=_alternative 004AE5C4C1256E36_=--