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);
On 2004-02-10T14:37:53+0100, Wilhelm.Greiner@vaps.de wrote:
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); };
After restarting syslog-ng with this config, verify that your program is running with ps. It looks like you assumed an exec/fork per event, however the protocol appears to be one event per line. That is, you need logic to decide when you send a chunk of data. I attached the program that I currently use, it is more complicated as I try to both minimize the number of emails sent and the latency in getting them. It dies once in a while, probably because of a unhandled signal, but I need to rewrite it in C++ one of these days. That said, it works quite well. /Allan -- Allan Wind P.O. Box 2022 Woburn, MA 01888-0022 USA
Your script needs to be in a loop like: while (<>) { if (match) { sendmail; } } Wilhelm.Greiner@vaps.de wrote:
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);
participants (3)
-
Aaron Jackson
-
allanwind@lifeintegrity.com
-
Wilhelm.Greiner@vaps.de