Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

logfilehandler.h

Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 2004 Russell Leighton
00003 **
00004 ** This program is free software; you can redistribute it and/or modify
00005 ** it under the terms of the GNU General Public License as published by
00006 ** the Free Software Foundation; either version 2 of the License, or
00007 ** (at your option) any later version.
00008 **
00009 ** This program is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 ** GNU General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU General Public License
00015 ** along with this program; if not, write to the Free Software
00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017 */
00018 
00019 
00020 
00021 
00022 #ifndef __AWHANDLER_LOGFILE__
00023 #define __AWHANDLER_LOGFILE__
00024 
00025 #include "hash.h"
00026 #include "regexmatch.h"
00027 #include "monitor.h"
00028 #include "wire.h"
00029 
00031 /*\@{*/
00032 
00076 
00081 
00122 /* 
00123 
00124 Changes:
00125 
00126 02/11/04 Russell Leighton
00127 Port to handler
00128 
00129 */
00130 
00134 typedef struct aw_logfilehandler_digest_s {
00135 
00136   /* list */
00137   struct aw_logfilehandler_digest_s *next;
00138  
00139   /* line from log file we are dedupping */
00140   byte_t
00141    *line;
00142 
00143   /* associated event */
00144   aw_event_sig_t
00145    *eventsig;
00146 
00147   aw_timestamp_t
00148    createtime;
00149 
00150   u_int32_t
00151    count;
00152 
00153 } aw_logfilehandler_digest_t;
00154 
00158 typedef struct {
00159 
00160   aw_event_sig_t
00161    match,               /* regex matched */
00162    nomatch;             /* regex did not match */
00163 
00164 } aw_logfilehandler_events_t;
00165 
00169 typedef struct {
00170 
00171   int32_t
00172    fd;               /* open fd to text file */
00173 
00174   ino_t
00175    inode;            /* inode of file */
00176 
00177   off_t
00178    offset;           /* where in file */
00179 
00180   aw_hashString_t
00181    *line2digest;     /* lookup for digest */
00182 
00183   aw_logfilehandler_digest_t
00184    *active_digests;  /* list of active digests */
00185 
00186 } aw_logfilehandler_state_t;
00187 
00188 
00192 typedef struct {
00193 
00194   aw_logfilehandler_events_t
00195     events;
00196 
00197   /* regex string */
00198   const byte_t
00199    *regex;
00200 
00201   /* holds substitution string, may be NULL */
00202   const byte_t
00203    *subst;
00204 
00205 } aw_logfilehandler_regex_t;
00206 
00210 typedef struct {
00211 
00212   aw_logfilehandler_events_t
00213     events;
00214 
00215   /* holds compiled regular expression  */
00216   regex_t
00217    pattern;
00218 
00219   /* holds substitution string, may be NULL */
00220   byte_t
00221    *subst;
00222 
00223 } aw_logfilehandler_watcher_t;
00224 
00228 typedef struct {
00229 
00230   aw_handler_t 
00231     handler_header;
00232 
00233   /* max size of text line */
00234   int32_t
00235    max_line_len;
00236 
00237   /* filename to watch (or name of Unix domain socket) */
00238   const char
00239    *filename;
00240 
00241   u_int32_t
00242    nwatchers;
00243 
00244   aw_logfilehandler_watcher_t
00245    *watchers;
00246 
00247   /* holds time interval for digest, if > 0 */
00248   aw_timestamp_t
00249    digest_interval;
00250 
00251   aw_logfilehandler_state_t
00252    state;
00253 
00254 } aw_logfilehandler_t ;
00255 
00256 
00269 aw_logfilehandler_t *aw_create_logfilehandler(const byte_t *filename,
00270                                               const u_int32_t nregexs,
00271                                               const aw_logfilehandler_regex_t *regexs,  
00272                                               const aw_timestamp_t digest_interval,
00273                                               int32_t (*regevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00274                                               int32_t (*regmaskevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00275                                               const aw_alarm_sched_t *sched,
00276                                               aw_logger_t *logger
00277                                           );
00278 
00283 void aw_free_logfilehandler(aw_logfilehandler_t *p);
00284 
00288 aw_handler_t *aw_wire_logfilehandler(aw_wire_mkhandler_args_t *args);
00289 
00290 /*\@}*/
00291 
00292 #endif
00293 
Aware 0.11.1 Copyright (C) 1998-2005 Russell Leighton (russ@elegant-software.com)