Sending a log line via e-mail
Hi! I try it (based on the documentation), but it isn't working. The destination line look like this: destination d_ups { program("mail -s UPSlog acsehi@qsoft.hu"); }; the syslog-ng try to send the line(s), but the bsd mailer waits something. If I try it in command line (with pipe-line), the command works perfectly. The environment: Debian 3.0r2, Kernel: 2.4.18, syslog-ng: 1.5.15. Sincerelly, András, Csehi Csehi András acsehi@freemail.hu, acsehi@qsoft.hu (1) 209-6651, (20) 410-5343
Csehi Andras <acsehi@qsoft.hu> - Wed, Oct 27, 2004:
destination d_ups { program("mail -s UPSlog acsehi@qsoft.hu"); };
program() destination launches a program when syslog-ng starts and sends the log lines on its stdin. the program is not launched for each line. you can write a shell script or an awk / perl program to read stdin and call mail for each line, this would translate in shell to: while read line; do echo "$line" | mail -s UPSlog acsehi@qsoft.hu; done -- Loïc Minier <lool@dooz.org>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Andras, I wirte the Loglines that have to be mailed to a own logfile and then put this line to your crontab */1 * * * * root test -s /var/log/logfile && \ $(mail -s "Message from Logserver" emailuser@domain.de \ < /var/log/logfile ; cat /dev/null > /var/log/logfile) So every minute a email will be send if the File "/var/log/logfile" is greater than zero bytes, otherwise no email will be send. And the other nice thing is, you can say cron only to look every 15 minuts for the size of the file. - -- Mit freundlichen Grüßen / With regards Stefan Schluppeck Bauer Publishinggroup - Brieffach 6200 - Burchard.11 - D-20077 Hamburg Publishing Support Center - Server & Development - Stefan Schluppeck Fon:+49-40-3019-5519 - Fax:+49-40-3019-5668 - eMail:sschluppeck@hbv.de ~ <°)))))>< ><)))))°> <°)))))>< ><)))))°> <°)))))>< ><)))))°> PGP-Fingerabdruck = 7DC1 E4B4 056C 5380 8C68 4B5F 5E87 227D 5632 E45F Key-ID = 81B7CD29 Csehi Andras wrote: | Hi! | | I try it (based on the documentation), but it isn't working. The destination | line look like this: | | destination d_ups { program("mail -s UPSlog acsehi@qsoft.hu"); }; | | the syslog-ng try to send the line(s), but the bsd mailer waits something. If I | try it in command line (with pipe-line), the command works perfectly. | | The environment: Debian 3.0r2, Kernel: 2.4.18, syslog-ng: 1.5.15. | | Sincerelly, | András, Csehi | Csehi András | acsehi@freemail.hu, acsehi@qsoft.hu | (1) 209-6651, (20) 410-5343 | | | _______________________________________________ | syslog-ng maillist - syslog-ng@lists.balabit.hu | https://lists.balabit.hu/mailman/listinfo/syslog-ng | Frequently asked questions at http://www.campin.net/syslog-ng/faq.html | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBf4gOXocifVYy5F8RAuPsAJ9mW8RUgMZoqOemrfq8U8FpMlJidQCffq53 O6Si2AjAsue+GMerFRUuwSI= =Va4Y -----END PGP SIGNATURE-----
Thanks for the detailed answers, it's working now :) Our most important (UPS log) logs are on the way to my mobile :) Thanks again: András Csehi Csehi András acsehi@freemail.hu, acsehi@qsoft.hu (1) 209-6651, (20) 410-5343
When you resort to cron jobs to mail lines from log files, you may as well use a log reporting utility. I'd recommend Logmuncher, but LogSentry's still around somewhere, I've heard good things about Swatch too. Russell On Wed, Oct 27, 2004 at 01:35:42PM +0200, Stefan Schluppeck wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi Andras,
I wirte the Loglines that have to be mailed to a own logfile and then put this line to your crontab
*/1 * * * * root test -s /var/log/logfile && \ $(mail -s "Message from Logserver" emailuser@domain.de \ < /var/log/logfile ; cat /dev/null > /var/log/logfile)
So every minute a email will be send if the File "/var/log/logfile" is greater than zero bytes, otherwise no email will be send.
And the other nice thing is, you can say cron only to look every 15 minuts for the size of the file.
- -- Mit freundlichen Gr??en / With regards
Stefan Schluppeck
Bauer Publishinggroup - Brieffach 6200 - Burchard.11 - D-20077 Hamburg Publishing Support Center - Server & Development - Stefan Schluppeck Fon:+49-40-3019-5519 - Fax:+49-40-3019-5668 - eMail:sschluppeck@hbv.de
~ <?)))))>< ><)))))?> <?)))))>< ><)))))?> <?)))))>< ><)))))?>
PGP-Fingerabdruck = 7DC1 E4B4 056C 5380 8C68 4B5F 5E87 227D 5632 E45F Key-ID = 81B7CD29
Csehi Andras wrote: | Hi! | | I try it (based on the documentation), but it isn't working. The destination | line look like this: | | destination d_ups { program("mail -s UPSlog acsehi@qsoft.hu"); }; | | the syslog-ng try to send the line(s), but the bsd mailer waits something. If I | try it in command line (with pipe-line), the command works perfectly. | | The environment: Debian 3.0r2, Kernel: 2.4.18, syslog-ng: 1.5.15. | | Sincerelly, | Andr?s, Csehi | Csehi Andr?s | acsehi@freemail.hu, acsehi@qsoft.hu | (1) 209-6651, (20) 410-5343 | | | _______________________________________________ | syslog-ng maillist - syslog-ng@lists.balabit.hu | https://lists.balabit.hu/mailman/listinfo/syslog-ng | Frequently asked questions at http://www.campin.net/syslog-ng/faq.html | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFBf4gOXocifVYy5F8RAuPsAJ9mW8RUgMZoqOemrfq8U8FpMlJidQCffq53 O6Si2AjAsue+GMerFRUuwSI= =Va4Y -----END PGP SIGNATURE-----
participants (4)
-
Csehi Andras
-
Loïc Minier
-
Russell Adams
-
Stefan Schluppeck