2011-11-30 Ramon Novoa <rnovoa@artica.es>
* modules/pandora_module_logevent.cc, modules/pandora_module_logevent.h: Added support for regular expressions to the pattern filter. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5220 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
24fe9ee841
commit
2b9d5ba84f
|
@ -1,3 +1,9 @@
|
|||
2011-11-30 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* modules/pandora_module_logevent.cc,
|
||||
modules/pandora_module_logevent.h: Added support for regular
|
||||
expressions to the pattern filter.
|
||||
|
||||
2011-11-29 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* modules/pandora_module_snmpget.cc: Modified the call to snmpget.exe
|
||||
|
|
|
@ -62,6 +62,12 @@ Pandora_Module_Logevent::Pandora_Module_Logevent (string name, string source, st
|
|||
this->id = strtoul (id.c_str (), NULL, 0);
|
||||
this->source = source;
|
||||
this->pattern = pattern;
|
||||
if (! pattern.empty ()) {
|
||||
// Compile the regular expression
|
||||
if (regcomp (&this->regexp, pattern.c_str (), REG_EXTENDED) != 0) {
|
||||
pandoraLog ("Invalid regular expression %s", pattern.c_str ());
|
||||
}
|
||||
}
|
||||
this->application = application;
|
||||
this->log_event = NULL;
|
||||
this->first_run = 1;
|
||||
|
@ -411,7 +417,7 @@ Pandora_Module_Logevent::filterEvent (PEVENTLOGRECORD pevlr, string description)
|
|||
}
|
||||
|
||||
// Pattern filter
|
||||
if (! this->pattern.empty () && description.find(this->pattern) == string::npos) {
|
||||
if (! this->pattern.empty () && regexec (&this->regexp, description.c_str (), 0, NULL, 0) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#define __PANDORA_MODULE_LOGEVENT_H__
|
||||
|
||||
#include "pandora_module.h"
|
||||
#include "boost/regex.h"
|
||||
|
||||
// Log event read buffer size
|
||||
#define BUFFER_SIZE 1024
|
||||
|
@ -39,14 +40,15 @@ namespace Pandora_Modules {
|
|||
|
||||
class Pandora_Module_Logevent : public Pandora_Module {
|
||||
private:
|
||||
unsigned long id;
|
||||
int type;
|
||||
unsigned char first_run;
|
||||
string source;
|
||||
string application;
|
||||
string pattern;
|
||||
HANDLE log_event;
|
||||
HANDLE messages_dll;
|
||||
regex_t regexp;
|
||||
unsigned long id;
|
||||
int type;
|
||||
unsigned char first_run;
|
||||
string source;
|
||||
string application;
|
||||
string pattern;
|
||||
HANDLE log_event;
|
||||
HANDLE messages_dll;
|
||||
|
||||
HANDLE openLogEvent ();
|
||||
void closeLogEvent ();
|
||||
|
|
Loading…
Reference in New Issue