<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule">

<channel>
<title>Re: Sending emails via syslog-ng in All Things Unix</title>
<link>http://www.dslreports.com/forum/r22638449</link>
<description></description>
<language>en</language>
<pubDate>Tue, 09 Feb 2010 16:42:30 EDT</pubDate>
<lastBuildDate>Tue, 09 Feb 2010 16:42:30 EDT</lastBuildDate>

<item>
<title>Re: Sending emails via syslog-ng</title>
<link>http://www.dslreports.com/forum/remark,22665527</link>
<description><![CDATA[<A HREF="/useremail/u/934481"><b>reaky</b></A> : Dear  SirMeowmix_III<br>I tried the configuration like you sent as the following:<br><br>#=================================================================<br># Remote logging<br>source src {<br>        pipe("/proc/kmsg");<br>        unix-stream("/dev/log");<br>        tcp(ip(0.0.0.0) port(514));<br>        udp(ip(0.0.0.0) port(514));<br>};<br><br> destination maillog { program("/syslog_fifos/host_fifo" flush_lines(1));<br> };<br>filter f_host {<br>        match("172.31.250.68");<br>};<br><br>log {source(src); filter(f_host); destination(maillog); };<br>#==================================================================<br><br>But when I restart It gave me the following note :<br><br>WARNING: the match() filter without the use of the value() option is deprecated and hinders performance, please update your configuration;]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,22665527</guid>
<pubDate>Tue, 07 Jul 2009 05:31:21 EDT</pubDate>
</item>

<item>
<title>Sending emails via syslog-ng</title>
<link>http://www.dslreports.com/forum/remark,22659820</link>
<description><![CDATA[<A HREF="/useremail/u/934481"><b>reaky</b></A> : Dear SirMeowmix_III<br>           I take some of your Idea and modified it, and use the following<br>=======================================================<br>source sme {file (/var/log/syslog-ng/servers/172.31.250.68/local7.log); };<br><br>destination maillog { program ("/usr/local/bin/syslog-mail-perl" );<br><br>log {source(sme); destination(maillog); };<br>=======================================================<br><br>And the perl script like the following:<br>+++++++++++++++++++++++++++++++++++=<br>#!/usr/bin/perl -n<br># thanks to Brian Dowling for an example with security in mind.<br><br>$TO = 'reaky@domain.com';<br>$FROM = $TO;<br><br>s/^//;<br><br>open(MAIL, "|/usr/sbin/sendmail -t");<br><br>print MAIL "EOT";<br>To: $TO<br>From: $FROM<br>Subject: SME Log Alert: $_<br><br>$_<br><br>EOT<br><br>close(MAIL);<br>+++++++++++++++++++++++++++++++++++++++<br>When It tried to send emails I found that I must restart syslog every time to send the mails to sendmail, In another word it buffer the emails tell I restart syslog-ng then It forwerd it to send mail and can see it in the mail log.<br>Do you have any idea for that ?<br>Thanks]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,22659820</guid>
<pubDate>Mon, 06 Jul 2009 08:10:03 EDT</pubDate>
</item>

<item>
<title>Re: Sending emails via syslog-ng</title>
<link>http://www.dslreports.com/forum/remark,22638449</link>
<description><![CDATA[<A HREF="/useremail/u/0"><b>anon</b></A> : Snippet from syslog-ng.conf<br><textarea name="code" class="text" cols=50 rows=10>options {&#012;        #Jan 11, 2007&#012;        #Do not use DNS, too much info being sent to perform rDNS/DNS lookups!&#012;        use_fqdn(no);&#012;        use_dns(no);&#012; &#012;        #Misc&#012;        keep_hostname(yes);&#012;        long_hostnames(off);&#012;        chain_hostnames(no);&#012;        check_hostname(no);&#012; &#012;        log_msg_size(4096);&#012;        stats(60);&#012;        flush_lines(1000);&#012;        flush_timeout(30);&#012;};&#012; &#012;source src {&#012;        pipe("/proc/kmsg");&#012;        unix-stream("/dev/log");&#012;        internal();&#012;        udp();&#012;        tcp(port(514) keep-alive(yes));&#012;};&#012; &#012;destination host_fifo {&#012;        file("/syslog_fifos/host_fifo" sync(1));&#012;};&#012; &#012;filter f_host {&#012;        match("192.168.1.1");&#012;};&#012; &#012;log {&#012;        source(src);&#012;        filter(f_host);&#012;        destination(host_fifo);&#012;};&#012;</textarea><!--end code block--><br>The Perl code that does the FIFO read:<br><br><textarea name="code" class="text" cols=50 rows=10>#!/usr/bin/perl -w&#012;#&#012;#    This program is free software: you can redistribute it and/or modify&#012;#    it under the terms of the GNU General Public License as published by&#012;#    the Free Software Foundation, either version 3 of the License, or&#012;#    (at your option) any later version.&#012;#&#012;#    This program is distributed in the hope that it will be useful,&#012;#    but WITHOUT ANY WARRANTY; without even the implied warranty of&#012;#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&#012;#    GNU General Public License for more details.&#012;#&#012;#    You should have received a copy of the GNU General Public License&#012;#    along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.&#012;#&#012;# Watch FIFO and email data&#012;# SirMeowmixIII&#012;# Jul 01, 2009&#012; &#012;use Mail::Mailer;&#012;use POSIX qw(setsid);&#012; &#012;&amp;daemonize;&#012; &#012;#Loop forever.&#012;while(1){&#012;        &amp;read_fifo();&#012;        sleep(15);&#012;}&#012; &#012;sub daemonize {&#012;    chdir '/'                 or die "Can't chdir to /: $!";&#012;    open STDIN, '/dev/null'   or die "Can't read /dev/null: $!";&#012;    open STDOUT, '&gt;&gt;/dev/null' or die "Can't write to /dev/null: $!";&#012;    open STDERR, '&gt;&gt;/dev/null' or die "Can't write to /dev/null: $!";&#012;    defined(my $pid = fork)   or die "Can't fork: $!";&#012;    exit if $pid;&#012;    setsid                    or die "Can't start a new session: $!";&#012;    umask 0;&#012;}&#012; &#012;sub error_hander(){ #If an error, sleep for 15 seconds and try again instead of doing a 'die'.&#012;        print($_&#91;0&#93;);&#012;        sleep(15);&#012;        return;&#012;}&#012; &#012;sub do_alert(){&#012;        $from_address = 'sender@senderdomain.com';&#012;        $to_address = 'recipient@destination.com';&#012;        $subject = "Message Subject";&#012;        $body = $_&#91;0&#93; . "\n";&#012; &#012;        $mailer = Mail::Mailer-&gt;new();&#012;        $mailer-&gt;open({ From =&gt; $from_address,To =&gt; $to_address, Subject =&gt; $subject}) or die "Can't open: $!\n";&#012;        print $mailer $body;&#012;        $mailer-&gt;close();&#012; &#012;        print localtime(time()) . $_&#91;0&#93; . "\n";&#012;}&#012; &#012;sub read_fifo(){&#012;        #Grab the PIPE&#012;        open ISA_FIFO, "&lt; /syslog_fifos/host_fifo" || &amp;error_handler("Cannot open FIFO pipe");&#012;        while(&lt;ISA_FIFO&gt;){&#012;                &amp;do_alert($_);&#012;        }&#012;        close(ISA_FIFO);&#012;        print "*** FIFO CLOSED ***\n";&#012;        return 0;&#012;}&#012;</textarea><!--end code block-->]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,22638449</guid>
<pubDate>Wed, 01 Jul 2009 08:16:23 EDT</pubDate>
</item>

<item>
<title>Re: Sending emails via syslog-ng</title>
<link>http://www.dslreports.com/forum/remark,22638412</link>
<description><![CDATA[<A HREF="/useremail/u/934481"><b>reaky</b></A> : thatnks for you replay<br>Coulde u pleas hare this filtration and code ?<br>Thanks]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,22638412</guid>
<pubDate>Wed, 01 Jul 2009 07:54:16 EDT</pubDate>
</item>

<item>
<title>Re: Sending emails via syslog-ng</title>
<link>http://www.dslreports.com/forum/remark,22633082</link>
<description><![CDATA[<A HREF="/useremail/u/0"><b>anon</b></A> : I do this with a syslog-ng filter expression, a new destination as a FIFO, and some Perl script that reads the FIFO and uses Mail::Mailer to send an email.<br><br>I can share this code if you wish.]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,22633082</guid>
<pubDate>Tue, 30 Jun 2009 09:51:49 EDT</pubDate>
</item>

<item>
<title>Sending emails via syslog-ng</title>
<link>http://www.dslreports.com/forum/remark,22632568</link>
<description><![CDATA[<A HREF="/useremail/u/934481"><b>reaky</b></A> : Hi friends<br>         I have syslog-ng installed in RHEL5 server, I make it as CEntral log for all servers in my network, Filtered by IP<br>Now What I want to do is make it send to me an email for a specific log for one of my server, In other word when any log sent from this IP (192.168.1.1 ) For example to send me email with this new log value to myemail@mydomain.com<br>The following is the part of configuration for my syslog-ng.conf that related with remote servers.<br>=============================================<br><br>source s_remote {<br>        tcp(ip(0.0.0.0) port(514));<br>        udp(ip(0.0.0.0) port(514));<br>};<br><br>destination d_separatedbyhosts {<br>        file("/var/log/syslog-ng/servers/$HOST/$FACILITY.log" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes));<br>};<br><br>log { source(s_remote); destination(d_separatedbyhosts); };<br>===============================================<br><br>Thanks<br>Best Regards<br>Reaky]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,22632568</guid>
<pubDate>Tue, 30 Jun 2009 07:32:13 EDT</pubDate>
</item>

</channel>
</rss>
