Reject log entries that are found to be invalid.
authorarjen <arjen>
Mon, 1 Sep 2003 06:57:14 +0000 (06:57 +0000)
committerarjen <arjen>
Mon, 1 Sep 2003 06:57:14 +0000 (06:57 +0000)
src/gcm_input/message.cpp

index 93560a3..596aba5 100644 (file)
@@ -8,7 +8,7 @@
 ***********************
 **      FILE NAME      : message.cpp
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.13 $
+**      VERSION NUMBER : $Revision: 1.14 $
 **
 **  DESCRIPTION      :  Implementation of the message handling classes
 **
 
 /*****************************
    $Log: message.cpp,v $
-   Revision 1.13  2003-08-16 15:28:45  arjen
+   Revision 1.14  2003-09-01 06:57:14  arjen
+   Reject log entries that are found to be invalid.
+
+   Revision 1.13  2003/08/16 15:28:45  arjen
    Fixed a namespace problem
 
    Revision 1.12  2003/08/11 16:56:16  arjen
@@ -83,7 +86,7 @@
 
 *****************************/
 
-static const char *RCSID = "$Id: message.cpp,v 1.13 2003-08-16 15:28:45 arjen Exp $";
+static const char *RCSID = "$Id: message.cpp,v 1.14 2003-09-01 06:57:14 arjen Exp $";
 
 #include <algorithm>
 #include <libxml/xpath.h>
@@ -440,7 +443,7 @@ double client_message::classify(String host, UTC arriv, String serv)
    }
    else if (!arrival.proper())
    {
-      *log << "Arrival time is not knwon.\n";
+      *log << "Arrival time is not known.\n";
       certainty = 0.0;
    }
    else
@@ -786,45 +789,50 @@ int client_message::enter()
 #ifdef DEBUG
             std::cerr << "\ncooker check: " << pan->check_pattern(line) << "\n";
 #endif
-            pan->cook_this(line, arrival);
-
-            if (pan->hostname() == hostname(0,~pan->hostname()))
+            if (pan->cook_this(line, arrival))
             {
+               if (pan->hostname() == hostname(0,~pan->hostname()))
+               {
 
 #ifdef DEBUG
-               std::cerr << " Information from cooker:\n";
-               std::cerr << "     timestamp = " << pan->timestamp() << "\n";
-               std::cerr << "     hostname  = " << pan->hostname() << "\n";
-               std::cerr << "     service   = " << pan->service() << "\n";
+                  std::cerr << " Information from cooker:\n";
+                  std::cerr << "     timestamp = " << pan->timestamp() << "\n";
+                  std::cerr << "     hostname  = " << pan->hostname() << "\n";
+                  std::cerr << "     service   = " << pan->service() << "\n";
 #endif
-               /*   Insert a new record into the log table   */
+                  /*   Insert a new record into the log table   */
 
-               insertion += "'" + objectid + "',";
-               insertion += "'" + pan->service() + "',";
-               insertion += "'" + pan->timestamp().format("%Y-%m-%d %T") + "',";
-               insertion += "'" + arrival.format("%Y-%m-%d %T") + "',";
-               insertion += "'" + SQL_Escape(line) + "',FALSE";
-               insertion += ")";
+                  insertion += "'" + objectid + "',";
+                  insertion += "'" + pan->service() + "',";
+                  insertion += "'" + pan->timestamp().format("%Y-%m-%d %T") + "',";
+                  insertion += "'" + arrival.format("%Y-%m-%d %T") + "',";
+                  insertion += "'" + SQL_Escape(line) + "',FALSE";
+                  insertion += ")";
 
-               if (testmode)
-               {
-                  *log << insertion << "\n";
+                  if (testmode)
+                  {
+                     *log << insertion << "\n";
+                  }
+                  else
+                  {
+                     database.Query(insertion);
+                  }
+
+                  if (verbose)
+                  {
+                     *log << "\n\n";
+                  }
+
+                  nr_lines++;
                }
                else
                {
-                  database.Query(insertion);
+                  *log << "   Hostname " << pan->hostname() << " does not match.\n";
                }
-
-               if (verbose)
-               {
-                  *log << "\n\n";
-               }
-
-               nr_lines++;
             }
             else
             {
-               *log << "   Hostname " << pan->hostname() << " does not match.\n";
+               *log << "gcm_input WARNING: Not a valid line: " << line << "\n";
             }
             break;