syslog-ng source
patternize.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2012 Balabit
3  * Copyright (c) 2009-2011 Péter Gyöngyösi
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published
7  * by the Free Software Foundation, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * As an additional exemption you are allowed to compile & link against the
19  * OpenSSL libraries as published by the OpenSSL project. See the file
20  * COPYING for details.
21  *
22  */
23 
24 #ifndef CORRELATION_PATTERNIZE_H_INCLUDED
25 #define CORRELATION_PATTERNIZE_H_INCLUDED
26 
27 #define PTZ_ALGO_SLCT 1
28 #define PTZ_ALGO_LOGHOUND 2
29 
30 #define PTZ_ITERATE_NONE 0
31 #define PTZ_ITERATE_OUTLIERS 1
32 #define PTZ_ITERATE_HIEARARCH 2
33 
34 #define PTZ_SEPARATOR_CHAR 0x1E
35 #define PTZ_PARSER_MARKER_CHAR 0x1A
36 
37 #define PTZ_NUM_OF_PARSERS 1
38 #define PTZ_PARSER_ESTRING 0
39 
40 #include "syslog-ng.h"
41 
42 typedef struct _Patternizer
43 {
44  guint algo;
45  guint iterate;
46  guint support;
49  const gchar *delimiters;
50 
51  // NOTE: for now, we store all logs read in the memory.
52  // This brings in some obvious constraints and should be solved
53  // in a more optimized way later.
54  GPtrArray *logs;
55 
56 } Patternizer;
57 
58 typedef struct _Cluster
59 {
60  GPtrArray *loglines;
61  char **words;
62  GPtrArray *samples;
63 } Cluster;
64 
65 /* only declared for the test program */
66 GHashTable *ptz_find_frequent_words(GPtrArray *logs, guint support, const gchar *delimiters, gboolean two_pass);
67 GHashTable *ptz_find_clusters_slct(GPtrArray *logs, guint support, const gchar *delimiters, guint num_of_samples);
68 
69 
70 GHashTable *ptz_find_clusters(Patternizer *self);
71 void ptz_print_patterndb(GHashTable *clusters, const gchar *delimiters, gboolean named_parsers);
72 
73 gboolean ptz_load_file(Patternizer *self, gchar *input_file, gboolean no_parse, GError **error);
74 
75 Patternizer *ptz_new(gdouble support_treshold, guint algo, guint iterate, guint num_of_samples,
76  const gchar *delimiters);
77 void ptz_free(Patternizer *self);
78 
79 #endif
FILE * input_file
Definition: add.c:32
GHashTable * ptz_find_clusters_slct(GPtrArray *logs, guint support, const gchar *delimiters, guint num_of_samples)
Definition: patternize.c:234
void ptz_print_patterndb(GHashTable *clusters, const gchar *delimiters, gboolean named_parsers)
Definition: patternize.c:557
GHashTable * ptz_find_frequent_words(GPtrArray *logs, guint support, const gchar *delimiters, gboolean two_pass)
Definition: patternize.c:100
gboolean ptz_load_file(Patternizer *self, gchar *input_file, gboolean no_parse, GError **error)
Definition: patternize.c:580
GHashTable * ptz_find_clusters(Patternizer *self)
Definition: patternize.c:363
Patternizer * ptz_new(gdouble support_treshold, guint algo, guint iterate, guint num_of_samples, const gchar *delimiters)
Definition: patternize.c:631
void ptz_free(Patternizer *self)
Definition: patternize.c:648
Definition: patternize.h:59
char ** words
Definition: patternize.h:61
GPtrArray * samples
Definition: patternize.h:62
GPtrArray * loglines
Definition: patternize.h:60
Definition: patternize.h:43
gdouble support_treshold
Definition: patternize.h:48
guint iterate
Definition: patternize.h:45
guint algo
Definition: patternize.h:44
const gchar * delimiters
Definition: patternize.h:49
guint support
Definition: patternize.h:46
GPtrArray * logs
Definition: patternize.h:54
guint num_of_samples
Definition: patternize.h:47