Disabled DEBUG output
authorarjen <arjen>
Thu, 14 Aug 2003 10:22:42 +0000 (10:22 +0000)
committerarjen <arjen>
Thu, 14 Aug 2003 10:22:42 +0000 (10:22 +0000)
src/gcm_daemon/gcm_daemon.php

index edfa844..05f291b 100755 (executable)
@@ -7,19 +7,22 @@
 ***********************************************************************************/
 
 
-/* 
+/*
    NAME                : gcm_daemon
    AUTHOR      : Brenno J.S.A.A.F. de Winter
                  De Winter Information Solutions
-   COPYRIGHT   : 2002 - De Winter Information Solutions, 
+   COPYRIGHT   : 2002 - De Winter Information Solutions,
                  Brenno J.S.A.A.F. de Winter
-   
-   * DATES * 
+
+   * DATES *
    First       : November 8th 2002
    Gnucomo-0.0.3: December 6th 2002
 
  $Log: gcm_daemon.php,v $
- Revision 1.12  2003-08-05 07:46:37  arjen
+ Revision 1.13  2003-08-14 10:22:42  arjen
+ Disabled DEBUG output
+
+ Revision 1.12  2003/08/05 07:46:37  arjen
  BUGFIX: Print an error message if a parameter does not have
  any history.
 
@@ -38,7 +41,7 @@
 
 */
 
-// $Id: gcm_daemon.php,v 1.12 2003-08-05 07:46:37 arjen Exp $
+// $Id: gcm_daemon.php,v 1.13 2003-08-14 10:22:42 arjen Exp $
 
 ini_set('include_path', '.:./classes:../phpclasses');
 
@@ -54,9 +57,9 @@ require_once "gnucomo.process_log.php";
 // Set the standard variables //
 $project_name  = "gnucomo";    //name of the entire project
 $app_name      = "gcm_daemon"; //name of the application running
-$developrelease = "TRUE";      //Indicates if special debug settings are needed
-$db_version    = 42;           //The db_version indicates what the level of 
-                               //the database should be. If the database is 
+$developrelease = "FALSE";      //Indicates if special debug settings are needed
+$db_version    = 42;           //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 the gcm_daemon,
                                //which is saved in the database. Log records that were not
@@ -99,9 +102,9 @@ $dbms->query($local_sql);
 
 if ($dbms->fetch_row() == "TRUE") {
   $active_version = $dbms->db_result_row[0];
+
   //Update the database to the most recent version.
-  if ($active_version < $db_version) { 
+  if ($active_version < $db_version) {
      include ("gnucomo_db_version.php");
   }
 } else {
@@ -127,7 +130,7 @@ if ($dbms->fetch_row() == "TRUE") {
       $dbms->query($local_sql);
 
    }
-      
+
 }
 
 //Now we loop the tasks that we have to do.
@@ -145,7 +148,7 @@ do {
       GatherStatistics($object->objectid);
    }
 
-  //At this place we start processing new log-lines 
+  //At this place we start processing new log-lines
   process_log ();
   //notificationstats();  //  This function is obsolete
   find_notifications();
@@ -158,9 +161,9 @@ do {
 syslog (LOG_INFO, "gcm_daemon ended nicely");
 
 function process_log () {
+
  /* This function will walk through the log-records that haven't been processed
-  * first a snapshot will be created of a the non-processed records. 
+  * first a snapshot will be created of a the non-processed records.
   * sequentially each record will dealt with. By doing that changes will be made
   * in several log_adv_xxx tables
   * INPUT  : NONE
@@ -178,16 +181,16 @@ function process_log () {
   if ($dbms->fetch_row() == "TRUE") {
      $last_log = $dbms->db_result_row[0];
   }
-  
+
   //Query the log-table
   $local_sql = "SELECT * FROM log WHERE logid > CAST(".$last_log." AS BIGINT) order by logid";
   $dbms->query($local_sql);
 
-  //Update the log-statistics in the object-table 
+  //Update the log-statistics in the object-table
   $local_statistics_db = copy_db_class($dbms, $class_settings->database());
   $local_findobject_db = copy_db_class($dbms, $class_settings->database());
 
-  //Make totals 
+  //Make totals
   $local_upper_row = $dbms->num_rows() + $last_log + 1;
   $local_sql = "SELECT COUNT(logid), objectid from log WHERE logid > CAST(". $last_log .
       " AS BIGINT) AND logid < CAST (" . $local_upper_row . " AS BIGINT) GROUP BY objectid";
@@ -196,10 +199,10 @@ function process_log () {
   //Loop the objects
   for ($i = 1; $i <= $local_statistics_db->num_rows(); $i++) {
       $local_object_row = $local_statistics_db->fetch_row();
-      $local_sql = "UPDATE object SET log_count = log_count + " . 
+      $local_sql = "UPDATE object SET log_count = log_count + " .
           $local_statistics_db->db_result_row[0] . " WHERE objectid = '" .
          $local_statistics_db->db_result_row[1] . "'";
-      $local_findobject_db->query($local_sql);  
+      $local_findobject_db->query($local_sql);
   }
 
   $local_counter = 0;
@@ -210,7 +213,7 @@ function process_log () {
     $dbms_changes = copy_db_class($dbms, $class_settings->database());
     if ($dbms_changes->have_db_connection() == 'TRUE') {
 
-       $local_sql               = 0 ;     
+       $local_sql               = 0 ;
        $local_sql_statistics    = "";
        $local_object_os         = "";
        $local_object_os_version = "";
@@ -245,7 +248,7 @@ function process_log () {
                 syslog (LOG_INFO, "Couldn't find suitable OS for processing the logline");
                 break;
              }
-            
+
             if ($local_process_return <> 'TRUE') {
               $local_process_return = 'FALSE';
             }
@@ -256,20 +259,20 @@ function process_log () {
 
          }
          $local_counter++;
-       } 
-       
+       }
+
        //Register that the logrecords have been processed.
        $local_sql = "UPDATE db_value SET setting_value = '".$local_log_id."' where setting = 'log_processing'";
        $dbms->query($local_sql);
-       
+
 
        //Update the statistics for the object-table
-       
+
 
      } else {
        syslog (LOG_INFO, "Couldn't clone database connection.");
        die ("Couldn't reconnect to the database.\n");
-    }     
+    }
    }
 
 }
@@ -368,7 +371,7 @@ function notificationstats ()
  * INPUT  : NONE
  * OUTPUT : NONE
  */
-           
+
  global $dbms, $class_settings;
 
  //Find records in log that still have to be processed.
@@ -380,11 +383,11 @@ function notificationstats ()
  if ($dbms->fetch_row() == "TRUE") {
     $last_notification = $dbms->db_result_row[0];
  }
+
  //Determine how many records we are going to analyse.
  $local_sql = "SELECT MAX(notificationid) FROM notification " .
    "WHERE notificationid > CAST ('" . $last_notification . "' AS BIGINT)";
- $dbms->query($local_sql);  
+ $dbms->query($local_sql);
 
  //Only process data if there are new notifications
  if ($dbms->fetch_row() == "TRUE") {
@@ -400,17 +403,17 @@ function notificationstats ()
 
      for ($i=0; $i < $dbms->num_rows(); $i++) {
        $dbms->fetch_row();
-    
+
        $local_sql = "UPDATE object SET notification_count = notification_count + " . $dbms->db_result_row[0] .
          " WHERE objectid = '" . $dbms->db_result_row[1] . "'";
-      $local_dbms->query($local_sql); 
-     }  
+      $local_dbms->query($local_sql);
+     }
 
-     $local_sql = "UPDATE db_value SET setting_value = '" . $local_max . 
+     $local_sql = "UPDATE db_value SET setting_value = '" . $local_max .
        "' WHERE setting = 'last_notification'";
-     $dbms->query($local_sql);  
-  }   
- } 
+     $dbms->query($local_sql);
+  }
+ }
 }
 
 function find_notifications () {
@@ -421,14 +424,14 @@ function find_notifications () {
  * INPUT  : NONE
  * OUTPUT : NONE
  */
-    
+
  global $dbms;
 
  //Find checks that have to be executed.
  $local_sql = "select * from notification_check where age(last_execution) > time_between_executions";
  $dbms->query($local_sql);
  for ($i=0; $i<$dbms->num_rows(); $i++) {
-     //A check has been found that has to be executed 
+     //A check has been found that has to be executed
      $dbms->fetch_row();
  }
 }