* DATES *
First : November 8th 2002
+ Gnucomo-0.0.3: December 6th 2002
*/
// Set the standard variables //
$project_name = "gnucomo"; //name of the entire project
$app_name = "gcm_daemon"; //name of the application running
-$db_version = 13; //The db_version indicates what the level of
+$developrelease = "FALSE"; //Indicates if special debug settings are needed
+$db_version = 20; //The db_version indicates what the level of
//the database should be. If the database is
//old an update will be generated.
-$gcmd_version = 2; //This value indicates the active version of the gcm_daemon,
+$gcmd_version = 3; //This value indicates the active version of the gcm_daemon,
//which is saved in the database. Log records that were not
//recognized before will now be recognized. The version doesn't
//mean anything in the overall gnucomo project.
+//Avoid time-limit issues
+set_time_limit(0);
+
+
// Read the database settings //
$class_settings = new gnucomo_config();
$class_settings->read($project_name);
if ($dbms->have_db_connection() == "FALSE") {
exit ("Database connection failed.");
+} else {
+ //The database connection has been made.
+ $dbms_working = copy_db_class($dbms);
}
-//The database connection has been made.
-
//Verify if the database is up-to-date by checking the versionnumber
-$local_sql = "SELECT setting_value FROM db_value WHERE setting = 'db_version'";
+$local_sql = "SELECT setting_value FROM db_value WHERE setting = 'db_version' ";
$dbms->query($local_sql);
if ($dbms->fetch_row() == "TRUE") {
if ($dbms->fetch_row() == "TRUE") {
if ($dbms->db_result_row[0] < $gcmd_version) {
//Reactive log-records that weren't understood earlier.
- $local_sql = "UPDATE log SET processed = false WHERE recognized = false";
+ $local_sql = "UPDATE log SET processed = false WHERE logid NOT IN (SELECT DISTINCT logid FROM log_adv)";
$dbms->query($local_sql);
//Update de gcm_daemon version in the database
}
+//Now we loop the tasks that we have to do.
+
+do {
+
+ //At this place we start processing new log-lines
+ process_log ();
-
-//At this place we start processing new log-lines
-process_log ();
+ $keep_running = 'FALSE';
+
+} while ($keep_running == 'TRUE');
//Tell the log that we're ending our efforts in a nice way
syslog (LOG_INFO, "gcm_daemon ended nicely");
* OUTPUT : NONE
*/
global $dbms;
-
- //Find open records.
- $local_sql = "SELECT * FROM log WHERE processed = FALSE";
+ global $dbms_working;
+
+/*
+ //Start a transaction for the processing/
+ $local_sql_working = "BEGIN TRANSACTION";
+ $dbms_working->query($local_sql_working);
+*/
+ //Find records in log that still have to be processed.
+
+ $local_sql = " SELECT setting_value FROM db_value WHERE setting = 'log_processing'";
$dbms->query($local_sql);
+
+ if ($dbms->fetch_row() == "TRUE") {
+ $last_log = $dbms->db_result_row[0];
+ }
+
+
+ $local_sql = "SELECT * FROM log WHERE logid > CAST(".$last_log." AS BIGINT) order by logid";
+ $dbms->query($local_sql);
+
$local_counter = 0;
if ($dbms->num_rows() > 0) {
//Walk through all the log-records.
while ($local_counter < $dbms->num_rows()) {
+
$local_return_row = $dbms->fetch_row();
if ($local_return_row == 'TRUE') {
//Work on active rows
syslog (LOG_INFO, "Couldn't find suitable OS for processing the logline");
break;
}
-
- //Now that the processing took place change the processing state if processing was
- //completed successfully.
- if ($local_process_return == 'TRUE') {
- $local_sql_processed = "UPDATE log SET recognized = TRUE where logid = $local_log_id";
- $dbms_changes->query($local_sql_processed);
+
+ if ($local_process_return <> 'TRUE') {
+ $local_process_return = 'FALSE';
}
-
- //Change the status of the log-record to processed.
- $local_sql_processed = "UPDATE log SET processed = TRUE WHERE logid = $local_log_id";
- $dbms_changes->query($local_sql_processed);
} else {
}
$local_counter++;
}
+
+ $local_sql = "UPDATE db_value SET setting_value = '".$local_log_id."' where setting = 'log_processing'";
+ $dbms->query($local_sql);
+
+
} else {
syslog (LOG_INFO, "Couldn't clone database connection.");
die ("Couldn't reconnect to the database.\n");
}
+ } else {
+ die ("done");
}
+/*
+ //close the transaction
+ $local_working = "COMMIT";
+ $dbms_working->query($local_working);
+*/
}
?>