download url: http://sourceforge.net/projects/nagiosappender/
home page url: https://sourceforge.net/project/showfiles.php?group_id=140996
In an earlier article (http://www.novell.com/communities/node/4131/application-monitoring-made-easy-java-applications-using-nagios), I presented a simple a method for generating a maintenance free system level view of the status of your backroom applications without the need to refactor any of your code.
The key requirements for this solution are:
- Java application
- Log4j logging
- Nagios monitoring
If your application is like many, though, you may find that there are specific messages you want to ignore … like an ERROR level message that really should have been a DEBUG level. Or perhaps you’re thinking of using Nagios for the first time, and you have a specific error you’re interested in, and can ignore the rest for the time being … By using the log4j facility, in conjunction with the NagiosAppender, we can easily use the existing include / exclude fitler capability to clearly identify the set of messages we want to monitor.
To use filters, first we need to turn the feature on in the NagiosAppender configuration.
or, if you’re using log4.xml
<param name=”ExcludeFilterEnabled” value=”true”/>
<param name=”PatternFilterFile” value=”conf/NagiosIncludeExcludeFilters.properties”/>
Notice that you can turn include or exclude filters separately.
Now we can turn our attention to the filters file. This file contains a list of regular expressions we are going to use to drive our filter engine. Here is an example of a configuration that passes on all messages, because we’re including everything, and excluding nothing (… not a very useful application of filtering ….)
Note that there are no exclude filters registered. This is important, because if we have enabled both include and exclude filtering, we need to pass both filter tests to pass on the message.
Here is an example of a configuration that has been dialed down to listen for just a few specific message signatures. Again, we are defining regular expressions here, not the actual message. Also, we are matching the regular expression against the unformatted raw log4j message, not the formatted message you’ve defined in your PatternLayout.
includeFilter=Account was just deleted for user:(.*)
includeFilter=Bug fix 2738 just failed(.*)
- Follow instructions for application monitoring (http://www.novell.com/communities/node/4131/application-monitoring-made-easy-java-applications-using-nagios)
- Turn on include and/or exclude filtering in your log4j file as necessary
- Create a properties file that is accessible to your application, and specify it in your log4j file
- Add include and exlude regular expressions to your filters property file
Senior Software Engineer
Tideworks Technology, Inc.
Nagios Server version 2.9
NagiosAppender version 1.2.4
Log4j version 1.2.9