BUGFIX: Secondary indices on log_notification were unique.
[gnucomo.git] / src / gcm_daemon / gcm_daemon.php
index 958895a..7a38aba 100755 (executable)
    Gnucomo-0.0.3: December 6th 2002
 
  $Log: gcm_daemon.php,v $
- Revision 1.14  2003-09-01 06:51:07  arjen
+ Revision 1.15  2003-09-02 12:48:09  arjen
+ BUGFIX: Secondary indices on log_notification were unique.
+ Additional information in the 'usr' table: 'display_name' and 'email'.
+ Added new issues and services.
+
+ Revision 1.14  2003/09/01 06:51:07  arjen
  Accept command argument '-c config' to use an alternate
  gnucomo configuration.
 
@@ -45,7 +50,7 @@
 
 */
 
-// $Id: gcm_daemon.php,v 1.14 2003-09-01 06:51:07 arjen Exp $
+// $Id: gcm_daemon.php,v 1.15 2003-09-02 12:48:09 arjen Exp $
 
 ini_set('include_path', '.:./classes:../phpclasses');
 ini_set('html_errors', 'false');
@@ -62,7 +67,7 @@ require_once "gnucomo.process_log.php";
 $project_name   = "gnucomo";    // name of the entire project
 $app_name       = "gcm_daemon"; // name of the application running
 $developrelease = "FALSE";      // Indicates if special debug settings are needed
-$db_version     = 42;           // The db_version indicates what the level of
+$db_version     = 43;           // The db_version indicates what the level of
                                 // the database should be. If the database is
                                 // old an update will be generated.
 $gcmd_version   = 5;            // This value indicates the active version of
@@ -196,6 +201,7 @@ do
   //At this place we start processing new log-lines
 
   process_log ();
+  //service_check();
   find_notifications();
 
   $keep_running = false;
@@ -430,8 +436,55 @@ function GatherStatistics($objectid)
    UpdateStatistic($objectid, 'logs', $cnt->count);
 }
 
+/*
+ *   Service_check - Check the log entries if there are any unknown
+ *   services.
+ */
+
+function service_check()
+{
+   global  $dbms;
+
+   $log_res = $dbms->query("SELECT objectid, servicecode,rawdata FROM log");
+
+   for ($log_row = 0; $log_row < $dbms->num_rows($log_res); $log_row++)
+   {
+      $log_entry = $dbms->fetch_object($log_res, $log_row);
+
+      //   Check if the service is used on the object.
+
+      $qry = "SELECT * FROM object_service WHERE objectid='";
+      $qry .= $log_entry->objectid . "' AND servicecode='";
+      $qry .= $log_entry->servicecode . "'";
+
+      $os_res = $dbms->query($qry);
+      if ($dbms->num_rows($os_res) == 0)
+      {
+         //   Service is not found for the object, check if the service
+         //   exists at all.
 
-function find_notifications () {
+         $qry = "SELECT * FROM service WHERE servicecode='";
+         $qry .= $log_entry->servicecode . "'";
+
+         if ($dbms->num_rows($dbms->query($qry)) == 0)
+         {
+            echo "Service " . $log_entry->servicecode . " does not exist.\n";
+         }
+         else
+         {
+            $qry = "SELECT objectname FROM object WHERE objectid='";
+            $qry .= $log_entry->objectid . "'";
+            $object = $dbms->fetch_object($dbms->query($qry), 0);
+            echo "Service " . $log_entry->servicecode . " is not used on ";
+            echo $object->objectname . ".\n";
+         }
+         echo $log_entry->rawdata . "\n";
+      }
+   }
+}
+
+function find_notifications ()
+{
 
 /*
  *  Do something with notification checks.