mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
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
f728246d50
commit
a59bdce0ad
@ -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>
|
2011-11-29 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* modules/pandora_module_snmpget.cc: Modified the call to snmpget.exe
|
* 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->id = strtoul (id.c_str (), NULL, 0);
|
||||||
this->source = source;
|
this->source = source;
|
||||||
this->pattern = pattern;
|
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->application = application;
|
||||||
this->log_event = NULL;
|
this->log_event = NULL;
|
||||||
this->first_run = 1;
|
this->first_run = 1;
|
||||||
@ -411,7 +417,7 @@ Pandora_Module_Logevent::filterEvent (PEVENTLOGRECORD pevlr, string description)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pattern filter
|
// 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#define __PANDORA_MODULE_LOGEVENT_H__
|
#define __PANDORA_MODULE_LOGEVENT_H__
|
||||||
|
|
||||||
#include "pandora_module.h"
|
#include "pandora_module.h"
|
||||||
|
#include "boost/regex.h"
|
||||||
|
|
||||||
// Log event read buffer size
|
// Log event read buffer size
|
||||||
#define BUFFER_SIZE 1024
|
#define BUFFER_SIZE 1024
|
||||||
@ -39,14 +40,15 @@ namespace Pandora_Modules {
|
|||||||
|
|
||||||
class Pandora_Module_Logevent : public Pandora_Module {
|
class Pandora_Module_Logevent : public Pandora_Module {
|
||||||
private:
|
private:
|
||||||
unsigned long id;
|
regex_t regexp;
|
||||||
int type;
|
unsigned long id;
|
||||||
unsigned char first_run;
|
int type;
|
||||||
string source;
|
unsigned char first_run;
|
||||||
string application;
|
string source;
|
||||||
string pattern;
|
string application;
|
||||||
HANDLE log_event;
|
string pattern;
|
||||||
HANDLE messages_dll;
|
HANDLE log_event;
|
||||||
|
HANDLE messages_dll;
|
||||||
|
|
||||||
HANDLE openLogEvent ();
|
HANDLE openLogEvent ();
|
||||||
void closeLogEvent ();
|
void closeLogEvent ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user