".__('Checking tagente_estado table').""; $rows = db_get_all_rows_in_table('tagente_modulo'); if ($rows === false) { $rows = array(); } foreach ($rows as $row) { $id_agente_modulo = $row['id_agente_modulo']; $id_agente = $row["id_agente"]; // check if exist in tagente_estado and create if not $sql = "SELECT COUNT(*) FROM tagente_estado WHERE id_agente_modulo = $id_agente_modulo"; $total = db_get_sql ($sql); if ($total == 0) { $sql = "INSERT INTO tagente_estado (id_agente_modulo, datos, timestamp, estado, id_agente, last_try, utimestamp, current_interval, running_by, last_execution_try) VALUE ($id_agente_modulo, 0, '01-01-1970 00:00:00', 0, 100, $id_agente, '01-01-1970 00:00:00', 0, 0, 0)"; echo "Inserting module $id_agente_modulo in state table
"; db_process_sql ($sql); } } echo "

".__('Checking database consistency')."

"; $rows = db_get_all_rows_in_table('tagente_estado'); if ($rows === false) { $rows = array(); } foreach ($rows as $row) { $id_agente_modulo = $row['id_agente_modulo']; # check if exist in tagente_estado and create if not $rows = db_get_all_rows_sql("SELECT COUNT(*) AS count FROM tagente_modulo WHERE id_agente_modulo = $id_agente_modulo"); if ($rows !== false) { $row = reset($rows); $count = $row['count']; if ($count == 0) { echo "Deleting non-existing module $id_agente_modulo in state table
"; db_process_sql_delete('tagente_estado', array('id_agente_modulo' => $id_agente_modulo)); } } } } elseif ($sanity == 2) { echo "

".__('Deleting non-init data')."

"; $rows = db_get_all_rows_filter("tagente_estado", array("utimestamp" => 0)); if ($rows === false) { $rows = array(); } foreach ($rows as $row) { echo "Deleting non init module " . $row['id_agente_modulo'] ."
"; modules_delete_agent_module($row['id_agente_modulo']); } echo "Deleting bad module (id 0)
"; db_process_sql_delete('tagente_modulo', array('id_modulo' => 0)); } echo "
"; echo "
"; echo __('Pandora FMS Sanity tool is used to remove bad database structure data, created modules with missing status, or modules that cannot be initialized (and don\'t report any valid data) but retry each its own interval to get data. This kind of bad modules could degrade performance of Pandora FMS. This database sanity tool is also implemented in the pandora_db.pl that you should be running each day or week. This console sanity DONT compact your database, only delete bad structured data.'); echo "

"; echo ""; echo html_print_image('images/status_away.png', true) . "  "; echo __('Sanitize my database now'); echo ""; echo "

"; echo ""; echo html_print_image('images/status_away.png', true) . "  "; echo __('Delete non-initialized modules now'); echo ""; echo "
"; ?>