tag:blogger.com,1999:blog-249169652009-07-08T09:47:09.909+02:00Bazsi's blogBazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.comBlogger75125tag:blogger.com,1999:blog-24916965.post-5359279336276187942009-07-08T09:43:00.002+02:002009-07-08T09:47:10.010+02:00syslog-ng rewrite use case: dpkg logsOne of my collegues (Péter Höltzl, he does all our trainings) has created a <a href="http://peter.blogs.balabit.com/2009/07/one-small-syslog-ng-trick-dpkg-messages.html">nice detailed example</a> on how to use the <a href="http://wwwen.balabit/dl/html/syslog-ng-admin-guide_en.html/ch03s08.html">parser/rewrite framework</a> to pull in yet another application into syslog: dpkg, the Debian package manager.<br /><br />If you are interested in what rewrite/parser can do for you, but didn't have the time to find out, the<a href="http://peter.blogs.balabit.com/2009/07/one-small-syslog-ng-trick-dpkg-messages.html"> blog post is worth a read</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-535927933627618794?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-5634579080465087102009-06-19T06:54:00.003+02:002009-06-19T09:09:22.747+02:00syslog-ng pipelinesThe other day someone wanted a special syslog-ng macro that would expand into digit changing every 5 seconds (e.g. R_UNIXTIME % 5) and although I couldn't give an exact solution to his problem, I've came up with this configuration snippet:<br /><br /><span style="font-family:courier new;">rewrite p_date_to_values { </span><br /><span style="font-family:courier new;"> set("$R_DATE", value("rdate"));</span><br /><span style="font-family:courier new;">};</span><br /><br /><span style="font-family:courier new;">filter f_get_second_chunk {</span><br /><span style="font-family:courier new;"> match('^... .. [0-9]+:[0-9]+:(?&lt;rdate.second_tens&gt;[0-9])[0-9]$' </span><br /><span style="font-family:courier new;"> type(pcre) value('rdate'));</span><br /><span style="font-family:courier new;">};<br /><br />The way it works is as follows:<br /></span><ul><li>the rewrite statement sets the name-value pair named "rdate" to $R_DATE (the macro)</li><li>the filter statement uses Perl Compatible Regular Expressions to parse the value of the "rdate" value and uses a named subpattern on the tens of seconds position to store that character in a value named "rdate.second_tens"</li><li>Later on in the configuration you can use "rdate.second_tens" just like any other macro/value.</li></ul>This proves that the current rewrite/parser/filter subsystems are really powerful, however even though this proved to be possible, there are some lessons learned from this example:<br /><ul><li>the macro and name-value space should really converge to each, this would mean that the match() filter could directly match against the macro value $R_DATE without the need for the separate rewrite statement</li><li>when you are after a given goal, you don't really want to differentiate rewrite/parser/filter rules at all. The current syntax of using separate blocks for separate type of log processing elements is a pain.<br /></li></ul>So I'm thinking about inventing yet another block, which simply wouldn't care what kind of processing element is added to it, something along the lines:<br /><br /><span style="font-family:courier new;">pipeline rdateseconds {</span><br /><span style="font-family:courier new;"> set("$R_DATE", value("rdate"));</span><br /><span style="font-family:courier new;"> match('^... .. [0-9]+:[0-9]+:(?<rdate.second_tens>[0-9])[0-9]$' </rdate.second_tens></span><br /><span style="font-family:courier new;"> type(pcre) value('rdate'));</span><br /><span style="font-family:courier new;"></span><br /><span style="font-family:courier new;">};</span><br /><br />And then:<br /><br /><span style="font-family:courier new;">log {<br /> source(src);<br /> pipeline(rdateseconds);<br /> destination(dst);<br />};</span><br /><br />Maybe I should even allow the creation of rewrite/parser/filter elements right there in the log statement:<br /><br /><span style="font-family:courier new;">log {<br /> source(src);<br /> filter(facility(mail));<br /> destination(dst);<br />};</span><br /><br />What do you think?<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-563457908046508710?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com2tag:blogger.com,1999:blog-24916965.post-35999655557266867982009-06-03T10:34:00.003+02:002009-06-03T10:38:56.256+02:00Nordic Meet on Nagios 2009I'm sitting at <a href="http://nordicmeetonnagios.op5.org/">NMN 2009</a> right now, and although the event title says it is a Nagios meet, I'm going to give a presentation on syslog-ng and the new features that 3.0 brings and an example on how to integrate syslog-ng and Nagios.<br /><br />If you are here and have a question just feel free to find me in the "BalaBit" T-Shirt. :) There's also <a href="http://nordicmeetonnagios.op5.org/">live streaming on the conference website</a>, so you can catch me at 15:50 Central European Time.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-3599965555726686798?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-55205718034421613292009-05-30T19:20:00.004+02:002009-05-30T19:57:24.543+02:00syslog-ng 4.0 roadmap plus release policy changesI've updated the syslog-ng OSE roadmap on the syslog-ng <a href="http://www.balabit.com/network-security/syslog-ng/opensource-logging-system/roadmap/">webpage</a> to include information about the upcoming syslog-ng version:<br /><br /><a href="http://www.balabit.com/network-security/syslog-ng/opensource-logging-system/roadmap/">http://www.balabit.com/network-security/syslog-ng/opensource-logging-system/roadmap/</a><br /><br />Also, I'd like to bring the changed release/support policy to your attention, that you can read at the same location above. I'd like to introduce stable track and feature track releases, the first being supported for a long time, whereas feature track releases are only supported until the next feature/stable release is published. When a sufficient number of features were published via feature track releases, the last one becomes stable and the cycle continues. Note that feature releases are <span style="font-weight: bold;">NOT </span>development snapshots, they are releases just like the major versions previously, the only difference is that instead of a <a href="http://www.balabit.com/dl/html/syslog-ng-v3.0-guide-admin-en.html/ch01s04.html">large feature list</a> like with <a href="http://www.balabit.com/dl/html/syslog-ng-v3.0-guide-admin-en.html/ch01s04.html">syslog-ng 3.0</a>, only a smaller set of changes are included.<br /><br />This makes it possible to publish features more often, always concentrating on a few of them at a time, instead of doing development for a long time and come out with a feature packed release. I hope to increase the pace of syslog-ng development with this change and also to cause less problem for users who prefer stability over features. Please read the details on the roadmap page.<br /><br />I've also opened the syslog-ng 3.1 repository and pushed it to our <a href="http://git.balabit.hu/">git server</a>. Right now there are no differences (except for the version number) between 3.0 and 3.1, I'm planning to integrate <a href="http://marci.blogs.balabit.com/">Marton's</a> message tagging and patterndb changes as soon as possible (his git tree is <a href="http://git.balabit.hu/?p=marci/syslog-ng-3.0.git;a=summary">here</a>). Hopefully the 3.1 cycle will be quite short as most of the things on the roadmap are already implemented, although scattered around in various public and private trees.<br /><br />With the opening of the 3.1 branch, I'm also obsoleting 2.0 (in the new support model two stable track versions are supported at any given time and we have 2.0, 2.1 and 3.0 right now), but that'll go in a separate post/announcement.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-5520571803442161329?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-17724511012890677842009-05-08T22:23:00.003+02:002009-05-08T22:36:55.583+02:00syslog-ng OSE 3.0.2 releasedAfter a long time and a lot of accumulated bugfixes, I've pressed the "release" button and<a href="https://www.balabit.com/network-security/syslog-ng/opensource-logging-system/upgrades/#"> syslog-ng OSE 3.0.2 </a>was published on our website. The first official version to feature binary packages for Linux and BSD platforms. Since there was a long time between 3.0.1 and 3.0.2 the <a href="https://www.balabit.com/downchangelog.bbx?cl=/downloads/syslog-ng/open-source-edition/3.0.2/changelog-en.txt">changelog</a> is quite large, however most of it are bugfixes, only some minor enhancements here and there.<br /><br />Hopefully I didn't miss any important bugs and problems. It must be much better stability/functionality wise than 3.0.1 was.<br /><br />The diffstat since 3.0.1:<br /> 150 files changed, 4332 insertions(+), 3000 deletions(-)<br /><br />You can also check the patches in our <a href="http://git.balabit.hu/?p=bazsi/syslog-ng-3.0.git;a=summary">git repository</a>.<br /><br />If you are using the 3.0 branch you are really recommended to check out this release. If you are using anything earlier than 3.0 you are also recommended upgrade, syslog-ng 3.0 is revolutionary to previous versions in <a href="http://http://wwwen.balabit/dl/html/syslog-ng-admin-guide_en.html/ch01s04.html">many ways</a>, especially if you want to do more to your logs than merely store them in a plain text file.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-1772451101289067784?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-72206347905706526632009-05-08T15:30:00.003+02:002009-05-08T15:31:19.456+02:00OSDC 2009 slidesI've uploaded my OSDC 2009 presentation slides to<br /><a href="http://people.balabit.hu/bazsi/slides/osdc-2009-syslog-ng-3.0.odp">http://people.balabit.hu/bazsi/slides/osdc-2009-syslog-ng-3.0.odp</a> Which has an example for processing iptables logs with db-parser() and putting the results in a customized SQL table.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-7220634790570652663?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-4093955768410564242009-05-03T20:36:00.003+02:002009-05-03T20:42:20.323+02:00Nordic Nagios Meet 2009I'm going to give a talk on syslog-ng on the upcoming Nordic Nagios Meet 2009. I expect the event to be great fun, just like <a href="http://bazsi.blogs.balabit.com/2008/06/nordic-nagios-meet-08.html">last year</a>. If you are in the Nordic region and use Nagios, rrdtools or syslog-ng, I recommend to pay a visit as you can meet the primary authors and some active contributors to these projects.<br /><br />If you are there and have anything to ask/talk about syslog-ng, just feel free to approach me, I'm probably going to wear a badge, so you can recognize me :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-409395576841056424?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-11613073709952697652009-05-03T20:22:00.006+02:002009-05-03T20:43:02.273+02:00OSDC 2009 and syslog-ng automatic testingI've spent the last week in the nice city of Nuremberg where <a href="http://www.netways.de/en/osdc/y2009/">Open Source Data Center Conference</a> took place, organized by <a href="http://www.netways.de/">Netways AG</a>. I really liked the talks about <a href="http://reductivelabs.com/products/puppet/">Puppet</a>, <a href="http://www.linbit.com/">DRBD</a> and the description of the <a href="http://www.booking.com/">booking.com </a>infrastructure which runs MySQL.<br /><br />Although I really enjoyed the conference I also had some free time to improve the automatic test program for syslog-ng, which now also covers TLS encrypted source and SQL destinations. I've also implemented a small script to collect coverage data of the testcases, thus right now I know that about 63% of syslog-ng is covered by automatic tests. (initially it was 55% but there were some low hanging fruits). I expect to raise this number easily to around 80%, then it'll probably become much more difficult to increase it further as the rest is error processing paths, and unless I come up with something to inject errors from the testcases those are difficult to test.<br /><br />Of course having a test suite is not a replacement for real-life, field testing, but nevertheless it makes it much easier to do releases as it ensures that no important functionality is broken completely.<br /><br />Based on this test infrastructure I'm going to release 3.0.2, after which I'll probably change the way I manage releases for syslog-ng, but I'll talk about that in a forthcoming post.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-1161307370995269765?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-18050486019656891112009-05-03T08:55:00.004+02:002009-05-03T09:43:50.500+02:00My son is 7 weeks old<table style="width: auto;"><tbody><tr><td><a href="http://picasaweb.google.com/lh/photo/o-ouRosdumU_dDspBYoYNg?feat=embedwebsite"><img src="http://lh3.ggpht.com/_HXml9RfutgE/SfwjXMQ2StI/AAAAAAAAAnI/m0I8EO0pCUk/s400/IMG_2460.JPG" /></a></td></tr><tr><td style="font-family: arial,sans-serif; font-size: 11px; text-align: right;">From <a href="http://picasaweb.google.com/bazsi77/DaniAprilis25?feat=embedwebsite">Dani-aprilis-25</a></td></tr></tbody></table><br /><br />The reason I was absent from this blog in the couple of last weeks is my now 7 weeks old son, Dániel. You can find a picture of him right here in the post, but some additional ones in my <a href="http://picasaweb.google.com/bazsi77/">Picasa albums</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-1805048601965689111?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com1tag:blogger.com,1999:blog-24916965.post-60891657425630215782009-03-23T22:15:00.004+01:002009-03-23T22:39:31.468+01:00Features that fell off the radarI was long pondering with the problem that it is quite tricky to enter regexps into syslog-ng configuration file, since if you enclose the string in double quotes (e.g. in ""), the backslash character needs to be escaped.<br /><br />Since backslash is used in regexps quite often, it can become cumbersome to enter regexps like:<br /><br /><span style="font-family: courier new;">match("[a-z\\-]+");</span><br /><br />Note that the backslash is doubled because otherwise the syslog-ng string parser would pass the sequence to the regexps compiler as: "[a-z-]+" which is certainly different in meaning what the above expression says.<br /><br />I always remembered that syslog-ng also supports single quotes (aka apostrophes), but I remembered they behaved just as if you used normal quotation marks. Therefore I was thinking about a 3rd string format, one that would not require escaping.<br /><br />However I was reading the related code the other day, and found that apostrophes work exactly the way I planned this 3rd string syntax to behave: not to get in the way when entering regexps. In fact it behaves just like apostrophes in the UNIX shells. It does not care about escaping, it only cares about the terminating apostrophe.<br /><br />I was dealing with regexp related questions on the mailing list a lot, and the root cause of the problems was most times this escaping stuff, and I never knew the proper answer and behaviour is already in syslog-ng, I've just forgotten about it completely.<br /><br />And now as I check the <a href="http://wwwen.balabit/dl/html/syslog-ng-admin-guide_en.html/bk01-toc.html">documentation for syslog-ng</a>, it does not mention this syntax either, even though it had been present even in the 1.6.x times.<br /><br />So if you had trouble writing lots of regexps in syslog-ng configuration, and I told you to properly escape your regexps, please forgive me. syslog-ng is better than I've thought :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-6089165742563021578?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-82151381670036112092009-03-16T17:59:00.002+01:002009-03-16T18:04:57.088+01:00Newborn babyAfter about two weeks being late, my son was born yesterday evening at 22:45CET. He weights 3270g and 56cm. Both the mother and the child are fine and I'm a proud new father.<br /><br />I guess this starts a section in my life, hopefully for the better.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-8215138167003611209?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com3tag:blogger.com,1999:blog-24916965.post-39863523146163354902009-03-14T11:06:00.003+01:002009-03-14T11:17:38.362+01:00syslog-ng OSE binary packagesI' happy to announce that BalaBit has decided to make the binary packages for syslog-ng OSE available for free.<br /><br />As you may know, BalaBit has various syslog-ng support packages and as a part of this service it prepared binary installation packages for different platforms. The access to these packages either required a support contract but could also be purchased separately for a yearly fee.<br /><br />With syslog-ng 3.0, the binary packages for syslog-ng OSE will become freely accessible.<br /><br />Since syslog-ng is an open source project, BalaBit planned to finish this task in the Open Source spirit: open and visible to all community members. This also means that the set of packages published with this e-mail is NOT yet release grade, rather it is more of a development snapshot of the current state of affairs. So please don't ruin your production systems with this package, it is more advisable to try them in a test environment (chroot or a dedicated test machine).<br /><br />With all these said, here is the link:<br /><br /><a href="https://www.balabit.com/network-security/syslog-ng/opensource-logging-system/upgrades/">https://www.balabit.com/network-security/syslog-ng/opensource-logging-system/upgrades/</a><br /><br />Please pick the release named "3.0HEAD". This contains a source snapshot (effectively git from two days ago), and a set of packages for SUSE 10, RHEL4/5, FreeBSD 6.x, Debian etch, and Linux generic.<br /><br />The binary packages contain all runtime dependencies needed to run syslog-ng, thus no further packages are required, it is an all-in-one package. The rpm/deb packages are prepared the same, they install syslog-ng in /opt/syslog-ng in order to avoid clashes with a system supplied syslog-ng daemon.<br /><br />There are two install kits for each platform:<br /><ul><li>one that includes database drivers (dubbed as "server")</li><li>one that does not include database drivers (dubbed as "client")</li></ul><br />Currently there are no other differences between the packages, but later on there might be.<br /><br />With the current infrastructure in place, I'm confident that with each syslog-ng OSE release, I can publish the source AND binary packages at the same time.<br /><br />I'd really appreciate success/failure reports and also any kind of comment you may have.<br /><br />I'd like to release 3.0.2 together with its binary packages, let's hope that I get enough feedback on these packages so that I can do that.<br /><br />Enjoy!<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-3986352314616335490?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-11210342392252104352009-03-11T22:55:00.003+01:002009-03-11T22:56:18.958+01:00First IETF syslog-protocol related questionI'm happy as I've received the first question about the new IETF specified syslog-protocol support. There's a need for that after all :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-1121034239225210435?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-57758998865458324012009-03-11T08:31:00.004+01:002009-05-03T20:43:23.112+02:00Next event on the horizonI didn't realize it is already that time of the year, but I was reminded that I'm going to give a talk on syslog-ng 3.0 on <a href="http://www.netways.de/osdc/y2009/">Open Source Data Center conference</a> in Nürnberg, Germany at the end of April. I'm going to talk about the nifty new features of syslog-ng 3.0.<br /><br />It would be very nice to meet syslog-ng users there. :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-5775899886545832401?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-18506812680723470762009-03-03T10:58:00.005+01:002009-03-11T08:31:04.151+01:00An introduction to db-parser()As promised on the mailing list here comes a short description of the new db-parser functionality of syslog-ng. For an introduction to parsers in general see my previous <a href="http://bazsi.blogs.balabit.com/2008/10/syslog-ng-message-parsing.html">blog post here</a>.<br /><br />The aim for db-parser is two-fold:<br /><ul><li>extract interesting information from a log message</li><li>attach tags to a log message for later classification.</li></ul>For instance here's a log sample (lines broken for readability):<br /><pre><br />Feb 24 11:55:22 bzorp sshd[4376]: Accepted password for bazsi \<br /> from 10.50.0.247 port 42156 ssh2<br /></pre><br /><br />This message states that a user named "bazsi" has logged into the host named "bzorp" using SSH2 from the quoted IP and port. When you read this message as a human, the event that happened is perfectly clear. However if it is not a human, but a piece of software that has to make out the meaning of the message, you need to identify the event (e.g. that a user login has happened) and the additional information associated with the event (e.g. that he used 10.50.0.247 as the client).<br /><br />If I wanted to express this as name-value pairs, it would be something like this:<br /><pre><br />event="user login", protocol="ssh2", \<br /> client="10.50.0.247:42156", method="password"<br /></pre><br />Surely this latter form is easier to analyze than the first. So the first step of all kinds of log analysis is to extract information from messages. At a first glance, the easiest way to extract this information is the use of<br />regular expressions. For example:<br /><pre><br />^\w{3} [ :0-9]{11} [._[:alnum:]-]+ sshd\[[0-9]+\]: Accepted \<br /> (gssapi(-with-mic|-keyex)?|rsa|dsa|password|publickey|keyboard-interactive/pam) \<br /> for [^[:space:]]+ from [^[:space:]]+ port [0-9]+( (ssh|ssh2))?<br /></pre><br />Once you match with the regular expression above (courtesy of the <a href="http://logcheck.org/">logcheck project</a>), the parentheseses mark the variable part of the information that you can reference as $1, $2 and so on.<br /><br />The problem with regular expressions are several fold:<br /><ul><li>they are difficult to write (just look at the example above)</li><li>they are even more difficult to understand, once written (again, please look at the example)</li><li>they are slow and they scale poorly with the number of regexps that we need to match against the incoming message stream.<br /></li></ul>Projects like <a href="http://logcheck.org/">logcheck</a> use regular expressions, but with the number of patterns increasing, the time needed to analyze logs skyrockets, which makes the whole thing unfeasible. Also, logcheck does not aim at extracting information from messages, it merely classifies them.<br /><br />Clearly a different approach is needed. And that's what db-parser in syslog-ng is.<br /><br />The db-parser() functionality of syslog-ng has the following objectives:<br /><ul><li>use a database to match various messages (and not filters embedded in the configuration file)</li><li>classify events into logcheck-like classes (cracking, violation, ignore, unknown)</li><li>extract variable information from messages, and place those into name-value pairs</li><li>be fast, scale to a high number of events/sec and high number of patterns</li><li>integrate well to the rest of syslog-ng<br /></li></ul>db-parser() is a generic parser, fits nicely to the parser framework inside syslog-ng. You can use it just like csv-parser():<br /><pre><br />...<br />parser p_db { db-parser(); };<br />...<br />log { source(src); parser(p_db); destination(d_parsed); };<br />...<br /></pre><br />The database used by db-parser is an XML file that is read during syslog-ng startup. Here is an example entry from the db-parser() database:<br /><pre><br />&lt;patterndb&gt;<br />&lt;ruleset name='sshd'&gt;<br /> &lt;pattern&gt;sshd&lt;/pattern&gt;<br /> &lt;rules&gt;<br /> &lt;rule provider='balabit' id='1' class='system'&gt;<br /> &lt;patterns&gt;<br /> &lt;pattern&gt;Accepted rsa for@QSTRING:username: @from\<br />@QSTRING:client_addr: @port @NUMBER:port:@ ssh2&lt;/pattern&gt;<br /> &lt;/patterns&gt;<br /> &lt;/rule&gt;<br /> ...<br /> &lt;/rules&gt;<br />&lt;/ruleset&gt;<br />&lt;/patterndb&gt;<br /></pre><br /><br /><br />As you can see the database is structured, and the first selection criteria to apply is the name of the application (e.g. the value for $PROGRAM). Then each rule matches against the message payload (e.g. the value for $MESSAGE) with the syslog header stripped off. The rule specifies the classification (e.g. 'system' in the example above) and lists one or more patterns. If any of the patterns match, the rule is considered a match.<br /><br />The variable part of the pattern is specified using special sequences, starting and ending with a '@' character. Within the enclosing '@' characters a colon separated list of parameters are listed:<br /><ul><li>the parser to apply (QSTRING and NUMBER in the example above)</li><li>the name of the value to be extracted from this position</li><li>additional arguments to be passed to the parser</li></ul>The available parsers are currently not really documented, but here is a<br />list of them (you can find these in the radix.c source file):<br /><ul><li>IPv4: to parse an IPv4 address</li><li>NUMBER: to parse a number</li><li>STRING: to parse a word</li><li>ESTRING: to parse a sequence of characters ending with a specific character</li><li>QSTRING: to parse a string enclosed within quotes<br /></li></ul>Of course further parsers can be added to the code easily. You don't have to specify monsterous regexps to match an IPv4 address anymore. Not to mention IPv6 :)<br /><br />If a message matches a rule, the db-parser() will make the following list of values defined for the given message:<br /><ul><li>.classifier.class: logcheck-like classification</li><li>.classifier.rule_id: the ID of the database entry that matched</li><li>pattern specific values: variable part that get extracted from the message by patterns<br /></li></ul>Each of the values defined previously can be referenced inside syslog-ng using a macro, e.g. you can do things like:<br /><pre><br /># You can use them in a filter:<br />filter f_class {<br />match("system" value(".classifier.class"));<br />};<br /><br /># but you can also use them in the names of files:<br />destination d_parsed {<br />file("/var/log/messages/${.classifier.class}.log");<br />};<br /></pre><br />That's a rough skeleton of what db-parser() is. If you are interested, you can find the db-parser() implementation in syslog-ng OSE 3.0:<br /><br /><a href="http://www.balabit.com/network-security/syslog-ng/opensource-logging-system/">http://www.balabit.com/network-security/syslog-ng/opensource-logging-system/</a><br /><br />You can also find some example pattern databases here:<br /><br /><a href="http://www.balabit.com/downloads/files/patterndb/">http://www.balabit.com/downloads/files/patterndb/</a><br /><br />We are also thinking about further ideas to enhance db-parser() and make it the foundation of an Open Source log analysis framework. Stay tuned!<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-1850681268072347076?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com5tag:blogger.com,1999:blog-24916965.post-5390555192962603092009-01-18T12:02:00.003+01:002009-01-18T12:08:57.936+01:00GStaticMutex and AIXIf you use GLib on non-Linux platforms such as AIX and think that G_STATIC_MUTEX_INIT does nothing but zero-initialize the mutex, think twice. Although quite clearly <a href="http://library.gnome.org/devel/glib/stable/glib-Threads.html#G-STATIC-MUTEX-INIT--CAPS">stated in the documentation</a>, I thought I was smarter and used a GStaticMutex embedded in a structure that was zero initialized.<br /><br />If you look at the definition of G_STATIC_MUTEX_INIT on most platforms (Linux, Solaris, BSDs), it contains nothing but zeroes. This lead me to the impression that zero filling a GStaticMutex instance is enough to initialize it.<br /><br />In reality it isn't. On AIX this renders the mutex to be entirely useless without warnings or aborts. The results are of course bugs that are difficult to track down and fix.<br /><br />This took me an entire day to figure out, as the SQL driver in syslog-ng had this problem. This was fixed since, but if you are running syslog-ng on AIX with the SQL driver, be sure to <a href="http://git.balabit.hu/?p=bazsi/syslog-ng-3.0.git;a=commit;h=c62e656554681f365429f317fb93f2eb257145ca">have this patch applied</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-539055519296260309?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-74216320149120503452009-01-15T13:20:00.003+01:002009-03-11T08:30:50.211+01:00syslog-ng OSE 3.0 finally releasedFinally I could take the time to actually announce the freshly released syslog-ng OSE 3.0 branch. It was uploaded to our website during the winter holidays, but I had to integrate syslog-ng OSE to our new release infrastructure, which among others has a much <a href="http://www.balabit.com/network-security/syslog-ng/opensource-logging-system/upgrades/">nicer web interface</a>.<br /><br />Here is a summary on what is new in syslog-ng 3.0:<br /><br /><a href="http://www.balabit.com/dl/html/syslog-ng-admin-guide_en.html/ch01s04.html">http://www.balabit.com/dl/html/syslog-ng-admin-guide_en.html/ch01s04.html</a><br /><br />Enjoy!<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-7421632014912050345?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com3tag:blogger.com,1999:blog-24916965.post-5849734240442758452008-12-11T23:41:00.004+01:002009-03-11T08:30:39.087+01:00include file support implementedI've implemented basic include file/directory functionality in syslog-ng, using the format numbered second in my <a href="http://bazsi.blogs.balabit.com/2008/12/include-syntax.html">previous post</a>.<br /><br />I've now pushed an expermental implementation of include files in the syslog-ng OSE 3.0 repository, in a separate branch called 'include'.<br /><br />E.g. in order to test the code, please clone the syslog-ng 3.0 repository:<br /><br />$ git clone git://git.balabit.hu/bazsi/syslog-ng-3.0.git<br /><br />Then check out the 'include' branch:<br /><br />$ git checkout --track -b include origin/include<br /><br />Then compile as usual. I didn't want to integrate it right into syslog-ng OSE 3.0 tree as I'd like to release that first as 3.0.1.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-584973424044275845?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com2tag:blogger.com,1999:blog-24916965.post-41282368716982322572008-12-10T16:16:00.003+01:002008-12-10T16:25:38.105+01:00include syntaxI'm about to implement configuration file includes, and although the implementation is quite straightforward, the syntax to be used is something to give a thought or two.<br /><br />Currently the syslog-ng configuration file consists of statements, each with the following basic format:<br /><br />stmt [<id>] { ... };<br /><br />The "id" gives a unique identifier of the statement, and the braces enclose the contents. Currently only the ID part is optional, the braces are always there.<br /><br />To make the include statement consistent with that, it'd have to look something like:<br /><br />include { "filename" };<br /><br />Obviously I don't like this too much, as it is way different from all other applications permitting the use of include statements. What about this:<br /><br />include "filename";<br /><br />E.g. use the ID part the name of the file to be included. I like this better. A third option might be the use of 'pragma' directives, currently only used to specify the file format compatibility in the case of syslog-ng 3.0:<br /><br />@version: 3.0<br /><br />This'd mean that include statements would look like this:<br /><br />@include: filename<br /><br />The problem with this last option is that pragmas are currently only processed at the beginning of the configuration file. So that code should also be generalized.<br /><br />I think I'd go with the second option, that's not completely inconsistent, but still the most intuitive to use.<br /><br />What do you think?<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-4128236871698232257?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-80939031701332721432008-11-23T13:55:00.007+01:002008-11-23T17:27:10.934+01:00syslog-ng 3.0 and SNMP trapsLast time I've written about how syslog-ng is able to change message contents. I thought it'd be useful to give you a more practical example, instead of a generic description.<br /><br />It is quite common to convert SNMP traps to syslog messages. The easiest implementation is to run snmptrapd and have it create a log message based on the trap. There's a small issue though: snmptrapd uses the UNIX syslog() API, and as such it is not able to propagate the originating host of the SNMP trap to the hostname portion of the syslog message. This means that all traps are logged as messages coming from the host running snmptrapd, and the hostname information is part of the message payload.<br /><br />Of course it'd be much easier to process syslog messages, if this were not the case.<br /><br />A solution would be to patch snmptrapd to send complete syslog frames, but that would require changing snmptrapd source. The alternative is to use the new parse and rewrite features of syslog-ng 3.0.<br /><br />First, you need to filter snmptrapd messages:<br /><br /><span style="font-family: courier new;">filter f_snmptrapd { program("snmptrapd"); };</span><br /><br />Then we'd need to grab the first field of the message payload, where snmptrapd is configured to put it:<br /><br /><span style="font-family: courier new;">rewrite r_snmptrapd {<br /> subst("^([^ ]+) (.*)$ ", "${2}");<br /> set("${1}" value("HOST"));<br />};</span><br /><br />Both rewrite expression kinds are demonstrated here:<br /><ul><li>subst() has two arguments: the first is a regexp to search for, the second is a template to be substituted if there's a match<br /></li><li>set() has a single argument: a template to be used as the new value</li></ul>Rewrite rules operate by the contents of the $MESSAGE value by default, which holds the message payload. Of course this can be changed by specifying the value() option. The notion 'value' in syslog-ng 3.0 refers to a name-value pair, in syslog-ng 3.0 every message is composed of a set of name-value pairs. The names of standard values match the name of the corresponding macro, but without the '$' sign.<br /><br />Please NOTE that the new value is a template which makes it possible to use macros such as $HOST or $MESSAGE defined by syslog-ng.<br /><br />Now let's wire the complete configuration together:<br /><br /><span style="font-family: courier new;">filter f_snmptrapd { program("snmptrapd"); };</span><br /><br /> <span style="font-family: courier new;">rewrite r_snmptrapd { </span><br /><span style="font-family: courier new;"> subst("^([^ ]+) (.*)$ ", "${2}"); </span><br /><span style="font-family: courier new;"> set("${1}" value("HOST")); </span><br /><span style="font-family: courier new;">};</span><br /><br /><span style="font-family: courier new;"> log { </span><br /><span style="font-family: courier new;"> source(s_all); </span><br /><span style="font-family: courier new;"> filter(f_snmptrapd);</span><br /><span style="font-family: courier new;"> rewrite(r_snmptrapd);</span><br /><span style="font-family: courier new;"> destination(d_all);</span><br /><span style="font-family: courier new;"> flags(final);</span><br /><span style="font-family: courier new;">};</span><br /><br /><span style="font-family: courier new;"> log { </span><br /><span style="font-family: courier new;"> source(s_all); </span><br /><span style="font-family: courier new;"> destination(d_all);</span><br /><span style="font-family: courier new;"> flags(final);</span><br /><span style="font-family: courier new;"> };</span><br /><br />Of course this is only an example of the power of what syslog-ng is now capable of doing. Please let me know if you can think of other uses.<br /><br />The current 3.0 branch of syslog-ng has not been released yet, it is available in the git repository at <a href="http://git.balabit.hu/">git.balabit.hu</a>, and also as <a href="http://www.balabit.hu/downloads/files/syslog-ng/sources/3.0/src-snapshot/">nightly snapshots</a>.<br /><br />I'd be grateful for any kind of feedback you might have, please post it either as comments on this blog, or to the mailing list.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-8093903170133272143?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-42004169484644772122008-11-08T09:05:00.003+01:002008-11-23T13:55:36.718+01:00syslog-ng statisticsFor a long time I meant to give the "log statistics" feature of syslog-ng an overhaul, and finally with the advent of syslog-ng 3.0, this was done.<br /><br />I'm not sure all of you know, but even earlier syslog-ng versions (2.1 and 2.0) did collect some per-source and per-destination statistics. These were reported periodically in the system log. The problem with this approach that it didn't really scale: with a large configuration the statistics message could become kilobytes long, and parsing this information from a file possibly several gigabytes in size is daunting.<br /><br />syslog-ng 3.0 has two important changes in this area: it adds several new kinds of counters (like per-host counters), and a UNIX domain socket where you can query the current status of these counters.<br /><br />As counters certainly have an overhead, you can now control how much statistics you want to gather. The new stats_level() option has three levels for now:<br /><ol><li>stats_level(0) is basically the same as earlier syslog-ng versions, per-source and per-destination statistics are kept here. This is the default.</li><li>stats_level(1) adds new counters without a big overhead, that is it adds counters for TCP connections, but does not keep per-host counters</li><li>stats_level(2) adds counters that can have a measurable performance impact, it adds for example per-host (as in $HOST) counters and also keeps track of the time the last message was received from a given host. These counters usually require an hash table lookup in the fastpath.</li></ol>Once you have the counters, you can still use the venerable "log statistics" message, by setting the stats_freq() option which defaults to 10 minutes, just like in earlier versions.<br /><br />However if you don't want to dig the logs produced by syslog-ng, you can also use the new UNIX domain socket at /var/run/syslog-ng/syslog-ng.ctl (the path might depend on the compilation options).<br /><br />If you connect to this socket using netcat (some netcat versions do support UNIX domain sockets), and you send a "STATS" command to it, you get the list of counters.<br /><br />There are no proper, command line clients for the UNIX domain channel yet, but if you have some scripting ability, you can start gather statistics easily, without the hassles of parsing log files, right after installing a syslog-ng 3.0 snapshot. :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-4200416948464477212?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com1tag:blogger.com,1999:blog-24916965.post-3462069799741937562008-10-30T11:45:00.006+01:002008-11-02T21:39:44.391+01:00syslog-ng message parsingEarlier this month, I announced the new syslog-ng 3.0 git tree, adding a lot of new features to syslog-ng Open Source Edition. I thought it'd be useful to describe the new features with some more details, so this time I'd write about message parsing.<br /><br />First of all, the message structure was a bit generalized in syslog-ng. Earlier it was encapsulating a syslog message and had little space to anything beyond that. That is, every log message that syslog-ng handled had <span style="font-weight: bold;">date,</span> <span style="font-weight: bold;">host</span>, <span style="font-weight: bold;">program</span> and <span style="font-weight: bold;">message</span> fields, but syslog-ng didn't care about message contents.<br /><br />This has changed, a LogMessage became a set of <span style="font-weight: bold;">name-value pairs</span>, with some "built-in" pairs that correspond to the parts of a syslog message.<br /><br />The aim with this change is: new name-value pairs can be associated with messages through the use of a parsing. It is now possible to parse non-syslog logs and use the columns the same way you could do it with syslog fields. Use them in the name of files, SQL tables or columns in an SQL table.<br /><br />Here is an example:<br /><br /><pre><br />parser p_parse_apache_logs { ... };<br /><br />destination d_peruser { <br /> file("/var/log/apache/${APACHE.USER_NAME}.log"); <br />};<br /><br />log { <br /> source(s_local); <br /> parser(p_parse_apache_logs); <br /> destination(d_peruser_files); <br />};<br /></pre><br /><br />This means that you can "extract" information from the payload and use this information for naming destination files or SQL tables, basically anywhere where you can use a template.<br /><br />There are currently two parsers implemented in syslog-ng:<br /><ul><li>a generic CSV (comma separated-values) parser, which can be parameterized to basically accept any kind of formally formatted input (so tab/space separated is also ok)</li><li>a database based parser, which uses a log pattern database to recognize messages belonging to specific applications and extract information on that.</li></ul>Since the database based parser is quite complex so it deserves its own post, I'd skip that for now. The CSV parser has the following options:<br /><br /><ul><li>template: defines the input to be used for parsing, can use macros<br /></li><li>columns: list of strings, the names to be associated with the columns parsed<br /></li><li>delimiters: the set of characters that delimit columns<br /></li><li>quotes or quote_pairs: the quote characters to support, quote_pairs makes it possible to use different start and end quote (like enclosing fields in braces)<br /></li><li>null: the null value which if found should substituted with an empty string</li><li>flags: see the documentation<br /></li></ul>The csv parser is capable of parsing real CSV data, e.g. it knows about quoting rules. So if you have an application that logs into files using space or comma separated data, you can almost be sure that you can process it with CSV parser.<br /><br />Here is an example that parses Apache logs, so that each field in the message becomes a name-value pair:<br /><br /><pre><br />parser p_apache {<br />csv-parser(columns("APACHE.CLIENT_IP",<br /> "APACHE.IDENT_NAME",<br /> "APACHE.USER_NAME",<br /> "APACHE.TIMESTAMP",<br /> "APACHE.REQUEST_URL",<br /> "APACHE.REQUEST_STATUS",<br /> "APACHE.CONTENT_LENGTH",<br /> "APACHE.REFERER",<br /> "APACHE.USER_AGENT",<br /> "APACHE.PROCESS_TIME",<br /> "APACHE.SERVER_NAME")<br /> # flags:<br /> # escape-none,escape-backslash,escape-double-char,<br /> # strip-whitespace<br /> flags(escape-double-char,strip-whitespace)<br /> delimiters(" ")<br /> quote-pairs('""[]')<br /> );<br />};<br /><br />parser p_apache_timestamp {<br /> csv-parser(columns("APACHE.TIMESTAMP.DAY",<br /> "APACHE.TIMESTAMP.MONTH",<br /> "APACHE.TIMESTAMP.YEAR",<br /> "APACHE.TIMESTAMP.HOUR",<br /> "APACHE.TIMESTAMP.MIN",<br /> "APACHE.TIMESTAMP.MIN",<br /> "APACHE.TIMESTAMP.ZONE")<br /> delimiters("/: ")<br /> flags(escape-none)<br /> template("${APACHE.TIMESTAMP}"));<br />};<br /></pre><br /><br />The first parser splits the major fields, and the second splits the timestamp to manageable pieces. You can then bind this parser to a log path of your choosing:<br /><br /><pre><br />log {<br /> source(s_apache);<br /> parser(p_apache); parser(p_apache_timestamp);<br /> destination(d_apache);<br />};<br /></pre><br /><br />As you can see the second parser uses a value created by the previous parser, using its template() option. Once this parsing is done, you can use any of the values created this way<br />in your d_apache destination, be it the name of the file, or a column in an SQL table.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-346206979974193756?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-83017697802650702642008-10-08T21:36:00.004+02:002009-05-03T20:43:38.588+02:006th Netfilter workshopI've spent my last week in Paris, where this year's Netfilter Workshop was held. I wanted to take this opportunity to thank Eric of <a href="http://www.inl.fr/">INL</a> for the organization. It was a wonderful and useful event, and I enjoyed it a lot. It is always nice to meet these wonderful guys.<br /><br />Here are some blog posts about the same event:<br /><ul><li>INL: <a href="http://nfws.inl.fr/en/">http://nfws.inl.fr/en/</a><br /></li><li>DaveM: <a href="http://vger.kernel.org/%7Edavem/cgi-bin/blog.cgi/2008/10/05#nfws2008">http://vger.kernel.org/~davem/cgi-bin/blog.cgi/2008/10/05#nfws2008</a></li><li>Patrick McHardy: <a href="http://people.netfilter.org/kaber/weblog/">http://people.netfilter.org/kaber/weblog/</a><br /></li></ul><br />Finally we could get <a href="http://www.balabit.com/support/community/products/tproxy/">Transparent Proxying</a> merged, now queued for 2.6.28.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-8301769780265070264?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-86231561897539354602008-10-01T16:03:00.002+02:002008-10-01T16:11:16.097+02:00syslog-ng OSE 3.0 git tree publishedI could finally get my syslog-ng 3.0 OSE tree published at git.balabit.hu. No nightly snapshots yet and I still have to prepare a formal announcement to post on the mailing list, but for those I teased with functions from the 3.0 branch, here it comes.<br /><br />From the top of my head, OSE 3.0 supports:<br /><ul><li>TLS encrypted channels,</li><li>syslog message rewrite,</li><li>parse parts of the syslog message and use the parsed parts in macros<br /></li><li>PCRE and glob filters (in addition to POSIX regexps),</li><li>support for the new IETF syslog protocols,</li><li>program sources,</li><li>new statistics framework that can be queried using UNIX domain sockets</li><li>etc.</li></ul>I just wanted to get the word out. Success/failure reports would be appreciated.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-8623156189753935460?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com0tag:blogger.com,1999:blog-24916965.post-29069167347973039962008-06-30T16:30:00.003+02:002008-11-08T09:04:23.403+01:00Migrate over to PCRE?As of now the development of the generic rewrite feature has been completed in one of my private git repositories. The new code uses PCRE and I'm somewhat undecided how to move forward with PCRE.<br /><br />For those who might not know PCRE is an implementation of regular expressions and is an acronym for "Perl Compatible Regular Expressions". PCRE adds a lot more features and seems to perform better than its POSIX equivalent.<br /><br />So the situation is as follows:<br /><ul><li>various filters use POSIX regexps</li><li>rewrite uses PCRE</li></ul>This is not a very consistent combination, thus I'm planning to add PCRE support for filters too. The only question is whether it is needed to have two independent regexp styles in syslog-ng in the long run.<br /><br />If I decide that one of them is enough, then I'd deprecate POSIX style regexps in filters and wouldn't implement POSIX in rewrite rules. This combination would yield a syslog-ng that would give warnings when POSIX-style regular expressions are in use and in a forthcoming release I'd change the default regexp style to PCRE, and yet another syslog-ng release later, I'd phase out POSIX completely.<br /><br />If the decision is to keep them both in the long run, it would mean that I'd need to implement POSIX style regexps for rewrite rules as well. This would probably the least intrusive for users, but also a lot more work. Also, this would allow adding other filtering options like globbing or prefix search.<br /><br />What do you think? Is the addition of modular search algorithms worth it?<br /><br />Please send your opinions to the mailing list: syslog-ng@lists.balabit.hu<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/24916965-2906916734797303996?l=bazsi.blogs.balabit.com'/></div>Bazsihttp://www.blogger.com/profile/05513463981388142009noreply@blogger.com3