***********************
** FILE NAME : message.h
** SYSTEM NAME :
-** VERSION NUMBER : $Revision: 1.3 $
+** VERSION NUMBER : $Revision: 1.8 $
**
** DESCRIPTION : Classes to for handling client messages
**
********************************
** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
** CREATION DATE : Sep 16, 2002
-** LAST UPDATE : Nov 04, 2002
+** LAST UPDATE : Aug 06, 2003
** MODIFICATIONS :
**************************************************************************/
/*****************************
$Log: message.h,v $
- Revision 1.3 2002-11-09 08:04:27 arjen
+ Revision 1.8 2003-12-04 10:38:09 arjen
+ Major redesign. All input is handled through XML. Raw input data is first
+ transformed into an XML document for further processing.
+ A collection of polymorphic classes handle the transformation of various
+ input formats into XML.
+ Classifying input data is done with a finite improbability calculation.
+
+ Revision 1.7 2003/08/11 16:56:16 arjen
+ Different kinds of log files are parsed by a collection of objects
+ of different classes, derived from the base class line_cooker
+ Depending on the message content or the message_type element in
+ XML, one of these objects is selected.
+
+ Logrunner is integrated with gcm_input. Although its functionality
+ is still limited, a connection between logrunner and gcm_input
+ is beginning to form.
+
+ Revision 1.6 2003/04/29 09:16:44 arjen
+ Read XML input,
+ Only cooked log entries for now.
+
+ Revision 1.5 2003/03/16 09:42:40 arjen
+ Read IRIX system logs.
+
+ Revision 1.4 2002/12/06 22:26:28 arjen
+ Set the value of log.processed to FALSE when inserting a
+ new log entry into the database
+ When a syslog entry arrives from last year, gcm_input subtracts one from the
+ year of arrival to create the year of the log entry.
+ Read output from "rpm -qa" and enter packages in the parameter table.
+
+ Revision 1.3 2002/11/09 08:04:27 arjen
Added a reference to the GPL
Revision 1.2 2002/11/04 10:13:36 arjen
*****************************/
-/* static const char *RCSID = "$Id: message.h,v 1.3 2002-11-09 08:04:27 arjen Exp $"; */
+/* static const char *RCSID = "$Id: message.h,v 1.8 2003-12-04 10:38:09 arjen Exp $"; */
#include <iostream>
#include <list>
#include <AXE/String.h>
#include <AXE/date.h>
+#include <libxml/parser.h>
+
+#include "message_filter.h"
+#include "line_cooker.h"
#include "database.h"
-/*
-///////////////////////////////////////////////////////////////////////////
-// NAME : message_buffer
-// BASECLASS :
-// MEMBERS :
-// OPERATORS :
-// METHODS : rewind()
-//
-// DESCRIPTION :
-//
-// RELATIONS :
-// SEE ALSO :
-// LAST MODIFIED : Nov 04, 2002
-///////////////////////////////////////////////////////////////////////////
-*/
+// Associates line cookers and message filters
-class message_buffer
+struct xform
{
- std::istream *input;
- std::list<String> buffer;
-
- std::list<String>::iterator next_line;
-
-public:
-
- message_buffer()
- {
- input = 0;
- next_line = buffer.begin();
- }
-
- message_buffer(std::istream *in)
- {
- input = in;
- next_line = buffer.begin();
- }
-
- void from(std::istream *in)
- {
- input = in;
- }
-
- friend bool operator >> (message_buffer &, String &);
-
- void rewind()
- {
- next_line = buffer.begin();
- }
+ message_filter *mf;
+ line_cooker *lc;
+ double uncertainty;
- void operator ++()
+ xform()
{
- if (next_line != buffer.end())
- {
- next_line++;
- }
+ mf = NULL;
+ lc = NULL;
+ uncertainty = 1.0;
}
- void operator --()
+ xform(message_filter *m, line_cooker *l)
{
- if (next_line != buffer.begin())
- {
- next_line--;
- }
+ mf = m;
+ lc = l;
+ uncertainty = 1.0;
}
};
//
// RELATIONS :
// SEE ALSO :
-// LAST MODIFIED : Nov 04, 2002
+// LAST MODIFIED : Aug 06, 2003
///////////////////////////////////////////////////////////////////////////
*/
UTC arrival; // When we got the message.
String service; // Service that created the message
+ std::list<xform> kitchen; // The collection of message filters and line cookers
+ xform pan; // The one we cook this log with
+
bool mail_header; // Does the message contain a mail header ?
bool gpg_encrypted; // Is the message encrypted ?
+ std::strstream xmlBuffer;
+ xmlDocPtr xmlDom;
+
double certainty; // How certain are we about the message
enum
{
- UNKNOWN, SYSLOG, ACCESSLOG, ERRORLOG
+ UNKNOWN, RPMLIST, XML, COOKER_OBJECT
} classification;
message_buffer input;
gnucomo_database database;
+ void enterXML();
+ bool extractHeader();
+
public:
client_message(std::istream *in, gnucomo_database db);
+ void add_cooker(line_cooker *lc, message_filter *mf)
+ {
+ xform x(mf, lc);
+
+ kitchen.push_back(x);
+ }
+
double classify(String host, UTC arrival = Now(), String serv = "");
int enter();
};