cellpadding = 3; $table->cellspacing = 3; $table->width = 600; $table->class = "databox"; $table->head = array (); $table->data = array (); $table->align = array (); $table->size = array (); $moduletype_name = get_moduletype_name (get_agentmodule_type ($module_id)); $offset = (int) get_parameter("offset"); $block_size = (int) $config["block_size"]; // The "columns" array is the number(and definition) of columns in the report: // $columns = array( // "COLUMN1" => array(ROW_FROM_DB_TABLE, FUNCTION_NAME_TO_FORMAT_THE_DATA, "align"=>COLUMN_ALIGNMENT, "width"=>COLUMN_WIDTH) // "COLUMN2" => array(ROW_FROM_DB_TABLE, FUNCTION_NAME_TO_FORMAT_THE_DATA, "align"=>COLUMN_ALIGNMENT, "width"=>COLUMN_WIDTH) // .... // ) // // For each row from the query, and for each column, we'll call the FUNCTION passing as argument // the value of the ROW. // $columns = array (); if ($moduletype_name == "log4x") { $table->width = "100%"; $sql_body = sprintf ("FROM tagente_datos_log4x WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); $columns = array( "Timestamp" => array("utimestamp", "format_timestamp", "align" => "center" ), "Sev" => array("severity", "format_data", "align" => "center", "width" => "70px"), "Message" => array("message", "format_verbatim", "align" => "left", "width" => "45%"), "StackTrace" => array("stacktrace", "format_verbatim", "align" => "left", "width" => "50%") ); } else if (preg_match ("/string/", $moduletype_name)) { $sql_body = sprintf (" FROM tagente_datos_string WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); $columns = array( "Timestamp" => array("utimestamp", "format_timestamp", "align" => "center"), "Data" => array("datos", "format_data", "align" => "center"), "Time" => array("utimestamp", "format_time", "align" => "center") ); } else { $sql_body = sprintf (" FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); $columns = array( "Timestamp" => array("utimestamp", "format_timestamp", "align" => "center"), "Data" => array("datos", "format_data", "align" => "center"), "Time" => array("utimestamp", "format_time", "align" => "center") ); } $sql = "SELECT * " . $sql_body; $sql_count = "SELECT count(*) " . $sql_body; $count = get_db_value_sql($sql_count); $sql .= " LIMIT " . $offset . "," . $block_size; $result = get_db_all_rows_sql ($sql); if ($result === false) { $result = array (); } $header_title = __('Received data from')." ".get_agentmodule_agent_name ($module_id)." / ".get_agentmodule_name ($module_id); $header_title .= "

" . __("From the last") . " " . human_time_description ($period); echo "

".$header_title. "

"; echo "
"; echo __("Choose a time from now") . ": "; $intervals = array (); $intervals[3600] = human_time_description_raw (3600); // 1 hour $intervals[86400] = human_time_description_raw (86400); // 1 day $intervals[604800] = human_time_description_raw (604800); // 1 week $intervals[2592000] = human_time_description_raw (2592000); // 1 month echo print_extended_select_for_time ($intervals, 'period', $period, 'this.form.submit();', '', '0', 10) . __(" seconds."); echo "

"; // $index = 0; foreach($columns as $col => $attr){ $table->head[$index] = $col; if (isset($attr["align"])) $table->align[$index] = $attr["align"]; if (isset($attr["width"])) $table->size[$index] = $attr["width"]; $index++; } foreach ($result as $row) { $data = array (); foreach($columns as $col => $attr){ $data[] = $attr[1] ($row[$attr[0]]); } array_push ($table->data, $data); if (count($table->data) > 200) break; } if (empty ($table->data)) { echo '

'.__('There was a problem locating the source of the graph').'

'; } else { pagination($count); print_table ($table); unset ($table); } ?>