'.__('Database maintenance').' » '; echo __('Database sanity tool').""; $sanity = get_parameter ("sanity", 0); if ($sanity == 1) { // Create tagente estado when missing echo "

".__('Checking tagente_estado table')."

"; $sql = "SELECT * FROM tagente_modulo"; $result = mysql_query ($sql); while ($row = mysql_fetch_array ($result)) { $id_agente_modulo = $row[0]; $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 = get_db_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, '0000-00-00 00:00:00', 0, 100, $id_agente, '0000-00-00 00:00:00', 0, 0, 0)"; echo "Inserting module $id_agente_modulo in state table
"; process_sql ($sql); } } echo "

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

"; $query1 = "SELECT * FROM tagente_estado"; $result = mysql_query($query1); while ($row = mysql_fetch_array ($result)) { $id_agente_modulo = $row[1]; # check if exist in tagente_estado and create if not $query2 = "SELECT COUNT(*) FROM tagente_modulo WHERE id_agente_modulo = $id_agente_modulo"; $result2 = mysql_query ($query2); $row2 = mysql_fetch_array ($result2); if ($row2[0] == 0) { $query3 = "DELETE FROM tagente_estado WHERE id_agente_modulo = $id_agente_modulo"; echo "Deleting non-existing module $id_agente_modulo in state table
"; mysql_query($query3); } } } elseif ($sanity == 2) { echo "

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

"; $query1 = "SELECT * FROM tagente_estado WHERE utimestamp = 0"; $result = mysql_query ($query1); while ($row = mysql_fetch_array ($result)) { $id_agente_modulo = $row[1]; echo "Deleting non init module $id_agente_modulo
"; $sql = "DELETE FROM tagente_modulo WHERE id_agente_modulo = $id_agente_modulo"; mysql_query ($sql); $sql = "DELETE FROM tagente_estado WHERE id_agente_modulo = $id_agente_modulo"; mysql_query ($sql); } echo "Deleting bad module (id 0)
"; $sql = "DELETE FROM tagente_modulo WHERE id_modulo = 0"; mysql_query ($sql); } 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 "  "; echo __('Sanitize my database now'); echo ""; echo "

"; echo ""; echo "  "; echo __('Delete non-initialized modules now'); echo ""; echo "
"; ?>