***********************************************************************************/
-/*
+/*
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.
*/
-// $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');
// 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
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 {
$dbms->query($local_sql);
}
-
+
}
//Now we loop the tasks that we have to 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();
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
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";
//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;
$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 = "";
syslog (LOG_INFO, "Couldn't find suitable OS for processing the logline");
break;
}
-
+
if ($local_process_return <> 'TRUE') {
$local_process_return = 'FALSE';
}
}
$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");
- }
+ }
}
}
* INPUT : NONE
* OUTPUT : NONE
*/
-
+
global $dbms, $class_settings;
//Find records in log that still have to be processed.
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") {
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 () {
* 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();
}
}