2010-05-03 Miguel de Dios <miguel.dedios@artica.es>
* operation/reporting/reporting_xml.php: added default value "now" in $report["datetime"]. Removed (as comment at the momment) obsolet report items, and added the items: "event_report_agent", "text", "sql", "event_report_module", "alert_report_module", "alert_report_agent", "url", "database_serialized", "TTRT", "TTO", "MTBF" and "MTTR". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2655 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
0014988481
commit
89f35e54b2
|
@ -1,3 +1,11 @@
|
|||
2010-05-03 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* operation/reporting/reporting_xml.php: added default value "now" in
|
||||
$report["datetime"]. Removed (as comment at the momment) obsolet report
|
||||
items, and added the items: "event_report_agent", "text", "sql",
|
||||
"event_report_module", "alert_report_module", "alert_report_agent",
|
||||
"url", "database_serialized", "TTRT", "TTO", "MTBF" and "MTTR".
|
||||
|
||||
2010-05-03 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_reporting.php: added the parameter "$html" in the
|
||||
|
|
|
@ -121,6 +121,8 @@ if (! $id_report) {
|
|||
|
||||
$report = get_db_row ('treport', 'id_report', $id_report);
|
||||
|
||||
$report["datetime"] = get_system_time();
|
||||
|
||||
if (! give_acl ($config['id_user'], $report['id_group'], "AR")) {
|
||||
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation","Trying to access graph reader");
|
||||
include ("general/noaccess.php");
|
||||
|
@ -235,21 +237,21 @@ foreach ($contents as $content) {
|
|||
array_push ($data["objdata"]["sla"], $sla_data);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
case 'event_report':
|
||||
$data["title"] = __("Event report");
|
||||
$table_report = event_reporting ($report['id_group'], $content['period'], $datetime, true);
|
||||
$data["objdata"] = "<![CDATA[";
|
||||
$data["objdata"] .= print_table ($table_report, true);
|
||||
$data["objdata"] .= "]]>";
|
||||
break;
|
||||
case 5:
|
||||
case 'alert_report':
|
||||
$data["title"] = __('Alert report');
|
||||
$data["objdata"] = "<![CDATA[";
|
||||
$data["objdata"] .= alert_reporting ($report['id_group'], $content['period'], $datetime, true);
|
||||
$data["objdata"] .= "]]>";
|
||||
break;
|
||||
// case 4:
|
||||
// case 'event_report':
|
||||
// $data["title"] = __("Event report");
|
||||
// $table_report = event_reporting ($report['id_group'], $content['period'], $datetime, true);
|
||||
// $data["objdata"] = "<![CDATA[";
|
||||
// $data["objdata"] .= print_table ($table_report, true);
|
||||
// $data["objdata"] .= "]]>";
|
||||
// break;
|
||||
// case 5:
|
||||
// case 'alert_report':
|
||||
// $data["title"] = __('Alert report');
|
||||
// $data["objdata"] = "<![CDATA[";
|
||||
// $data["objdata"] .= alert_reporting ($report['id_group'], $content['period'], $datetime, true);
|
||||
// $data["objdata"] .= "]]>";
|
||||
// break;
|
||||
case 6:
|
||||
case 'monitor_report':
|
||||
$data["title"] = __('Monitor report');
|
||||
|
@ -277,26 +279,265 @@ foreach ($contents as $content) {
|
|||
$data["title"] = __('Sumatory');
|
||||
$data["objdata"] = format_numeric (get_agentmodule_data_sum ($content['id_agent_module'], $content['period'], $datetime));
|
||||
break;
|
||||
case 11:
|
||||
case 'general_group_report':
|
||||
$data["title"] = __('Group');
|
||||
// case 11:
|
||||
// case 'general_group_report':
|
||||
// $data["title"] = __('Group');
|
||||
// $data["objdata"] = "<![CDATA[";
|
||||
// $data["objdata"] .= print_group_reporting ($report['id_group'], true);
|
||||
// $data["objdata"] .= "]]>";
|
||||
// break;
|
||||
// case 12:
|
||||
// case 'monitor_health':
|
||||
// $data["title"] = __('Monitor health');
|
||||
// $data["objdata"] = "<![CDATA[";
|
||||
// $data["objdata"] .= monitor_health_reporting ($report['id_group'], $content['period'], $datetime, true);
|
||||
// $data["objdata"] .= "]]>";
|
||||
// break;
|
||||
// case 13:
|
||||
// case 'agents_detailed':
|
||||
// $data["title"] = __('Agents detailed view');
|
||||
// $data["objdata"] = "<![CDATA[";
|
||||
// $data["objdata"] .= get_group_agents_detailed_reporting ($report['id_group'], $content['period'], $datetime, true);
|
||||
// $data["objdata"] .= "]]>";
|
||||
// break;
|
||||
case 'agent_detailed_event':
|
||||
case 'event_report_agent':
|
||||
$data["title"] = __('Agent detailed event');
|
||||
|
||||
$data["objdata"]["event_report_agent"] = array ();
|
||||
|
||||
$date = get_system_time ();
|
||||
|
||||
$events = get_agent_events ($content['id_agent'], $content['period'], $date );
|
||||
if (empty ($events)) {
|
||||
$events = array ();
|
||||
}
|
||||
|
||||
foreach ($events as $event) {
|
||||
$objdata = array ();
|
||||
$objdata['event'] = $event['evento'];
|
||||
$objdata['event_type'] = $event['event_type'];
|
||||
$objdata['criticity'] = get_priority_name($event['criticity']);
|
||||
$objdata['count'] = $event['count_rep'];
|
||||
$objdata['timestamp'] = $event['time2'];
|
||||
array_push ($data["objdata"]["event_report_agent"], $objdata);
|
||||
}
|
||||
break;
|
||||
case 'text':
|
||||
$data["title"] = __('Text');
|
||||
$data["objdata"] = "<![CDATA[";
|
||||
$data["objdata"] .= print_group_reporting ($report['id_group'], true);
|
||||
$data["objdata"] .= safe_output($content["text"]);
|
||||
$data["objdata"] .= "]]>";
|
||||
break;
|
||||
case 12:
|
||||
case 'monitor_health':
|
||||
$data["title"] = __('Monitor health');
|
||||
$data["objdata"] = "<![CDATA[";
|
||||
$data["objdata"] .= monitor_health_reporting ($report['id_group'], $content['period'], $datetime, true);
|
||||
$data["objdata"] .= "]]>";
|
||||
case 'sql':
|
||||
$data["title"] = __('SQL');
|
||||
|
||||
//name tags of row
|
||||
if ($content['header_definition'] != '') {
|
||||
$tags = explode('|', $content['header_definition']);
|
||||
}
|
||||
|
||||
if ($content['treport_custom_sql_id'] != 0) {
|
||||
$sql = get_db_value_filter('`sql`', 'treport_custom_sql', array('id' => $content['treport_custom_sql_id']));
|
||||
}
|
||||
else {
|
||||
$sql = $content['external_source'];
|
||||
}
|
||||
|
||||
$result = get_db_all_rows_sql($sql);
|
||||
if ($result === false) {
|
||||
$result = array();
|
||||
}
|
||||
|
||||
if (isset($result[0])) {
|
||||
for ($i = 0; $i < (count($result[0]) - count($tags)); $i) {
|
||||
$tags[] = 'unname_' . $i;
|
||||
}
|
||||
}
|
||||
|
||||
$data["objdata"]["data"] = array ();
|
||||
|
||||
foreach ($result as $row) {
|
||||
$objdata = array ();
|
||||
$i = 0;
|
||||
foreach ($row as $column) {
|
||||
$objdata[$tags[$i]] = $column;
|
||||
$i++;
|
||||
}
|
||||
array_push($data["objdata"]["data"], $objdata);
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
case 'agents_detailed':
|
||||
$data["title"] = __('Agents detailed view');
|
||||
$data["objdata"] = "<![CDATA[";
|
||||
$data["objdata"] .= get_group_agents_detailed_reporting ($report['id_group'], $content['period'], $datetime, true);
|
||||
$data["objdata"] .= "]]>";
|
||||
case 'event_report_module':
|
||||
$data["title"] = __('Agents detailed event');
|
||||
$data["objdata"]["event_report_module"] = array();
|
||||
|
||||
$events = get_module_detailed_event_reporting($content['id_agent_module'], $content['period'], $report["datetime"], true, false);
|
||||
|
||||
foreach ($events->data as $eventRow) {
|
||||
$objdata = array();
|
||||
$objdata['event_name'] = $eventRow[0];
|
||||
$objdata['event_type'] = $eventRow[1];
|
||||
$objdata['criticity'] = $eventRow[2];
|
||||
$objdata['count'] = $eventRow[3];
|
||||
$objdata['timestamp'] = $eventRow[4];
|
||||
|
||||
array_push($data["objdata"]["event_report_module"], $objdata);
|
||||
}
|
||||
break;
|
||||
case 'alert_report_module':
|
||||
$data["title"] = __('Alert report module');
|
||||
$data["objdata"]["alert_report_module"] = array();
|
||||
|
||||
$alerts = alert_reporting_module ($content['id_agent_module'], $content['period'], $report["datetime"], true, false);
|
||||
|
||||
foreach ($alerts->data as $row) {
|
||||
$objdata = array();
|
||||
|
||||
$actionsHtml = strip_tags($row[2], '<li>');
|
||||
$actions = explode('</li>', $actionsHtml);
|
||||
|
||||
$objdata['template'] = $row[1];
|
||||
|
||||
$objdata['action'] = array();
|
||||
foreach ($actions as $action) {
|
||||
$actionText = strip_tags($action);
|
||||
if ($actionText == '') {
|
||||
continue;
|
||||
}
|
||||
$objdata['action'][] = $actionText;
|
||||
}
|
||||
|
||||
$firedHtml = strip_tags($row[3], '<li>');
|
||||
$fireds= explode('</li>', $firedHtml);
|
||||
|
||||
$objdata['fired'] = array();
|
||||
foreach ($fireds as $fired) {
|
||||
$firedText = strip_tags($fired);
|
||||
if ($firedText == '') {
|
||||
continue;
|
||||
}
|
||||
$objdata['fired'][] = $firedText;
|
||||
}
|
||||
array_push($data["objdata"]["alert_report_module"], $objdata);
|
||||
}
|
||||
break;
|
||||
case 'alert_report_agent':
|
||||
$data["title"] = __('Alert report agent');
|
||||
|
||||
$alerts = alert_reporting_agent ($content['id_agent'], $content['period'], $report["datetime"], true, false);
|
||||
$data["objdata"]["alert_report_agent"] = array();
|
||||
|
||||
foreach ($alerts->data as $row) {
|
||||
$objdata = array();
|
||||
|
||||
$objdata['module'] = $row[0];
|
||||
$objdata['template'] = $row[1];
|
||||
|
||||
$actionsHtml = strip_tags($row[2], '<li>');
|
||||
$actions = explode('</li>', $actionsHtml);
|
||||
|
||||
$objdata['action'] = array();
|
||||
foreach ($actions as $action) {
|
||||
$actionText = strip_tags($action);
|
||||
if ($actionText == '') {
|
||||
continue;
|
||||
}
|
||||
$objdata['action'][] = $actionText;
|
||||
}
|
||||
|
||||
$firedHtml = strip_tags($row[3], '<li>');
|
||||
$fireds= explode('</li>', $firedHtml);
|
||||
|
||||
$objdata['fired'] = array();
|
||||
foreach ($fireds as $fired) {
|
||||
$firedText = strip_tags($fired);
|
||||
if ($firedText == '') {
|
||||
continue;
|
||||
}
|
||||
$objdata['fired'][] = $firedText;
|
||||
}
|
||||
|
||||
array_push($data["objdata"]["alert_report_agent"], $objdata);
|
||||
}
|
||||
break;
|
||||
case 'url':
|
||||
$data["title"] = __('Import text from URL');
|
||||
|
||||
$curlObj = curl_init();
|
||||
|
||||
curl_setopt($curlObj, CURLOPT_URL, $content['external_source']);
|
||||
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
|
||||
$output = curl_exec($curlObj);
|
||||
curl_close($curlObj);
|
||||
|
||||
$data["objdata"] = $output;
|
||||
break;
|
||||
case 'database_serialized':
|
||||
$data["title"] = __('Serialize data');
|
||||
|
||||
//Create the head
|
||||
$tags = array();
|
||||
if ($content['header_definition'] != '') {
|
||||
$tags = explode('|', $content['header_definition']);
|
||||
}
|
||||
array_unshift($tags, 'Date');
|
||||
|
||||
$datelimit = $report["datetime"] - $content['period'];
|
||||
|
||||
$result = get_db_all_rows_sql('SELECT *
|
||||
FROM tagente_datos_string
|
||||
WHERE id_agente_modulo = ' . $content['id_agent_module'] . '
|
||||
AND utimestamp > ' . $datelimit . ' AND utimestamp <= ' . $report["datetime"]);
|
||||
if ($result === false) {
|
||||
$result = array();
|
||||
}
|
||||
|
||||
$data["objdata"]["data"] = array ();
|
||||
foreach ($result as $row) {
|
||||
$date = date ($config["date_format"], $row['utimestamp']);
|
||||
$serialized = $row['datos'];
|
||||
$rowsUnserialize = explode($content['line_separator'], $serialized);
|
||||
foreach ($rowsUnserialize as $rowUnser) {
|
||||
$columnsUnserialize = explode($content['column_separator'], $rowUnser);
|
||||
array_unshift($columnsUnserialize, $date);
|
||||
|
||||
$objdata = array ();
|
||||
$i = 0;
|
||||
foreach ($columnsUnserialize as $column) {
|
||||
$objdata[$tags[$i]] = $column;
|
||||
$i++;
|
||||
}
|
||||
array_push($data["objdata"]["data"], $objdata);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'TTRT':
|
||||
$ttr = get_agentmodule_ttr ($content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
if ($ttr != 0) $ttr = human_time_description_raw ($ttr);
|
||||
|
||||
$data["title"] = __('TTRT');
|
||||
$data["objdata"] = format_numeric($ttr);
|
||||
break;
|
||||
case 'TTO':
|
||||
$tto = get_agentmodule_tto ($content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
if ($tto != 0) $tto = human_time_description_raw ($tto);
|
||||
|
||||
$data["title"] = __('TTO');
|
||||
$data["objdata"] = format_numeric($tto);
|
||||
break;
|
||||
case 'MTBF':
|
||||
$mtbf = get_agentmodule_mtbf ($content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
if ($mtbf != 0) $mtbf = human_time_description_raw ($mtbf);
|
||||
|
||||
$data["title"] = __('MTBF');
|
||||
$data["objdata"] = format_numeric($mtbf);
|
||||
break;
|
||||
case 'MTTR':
|
||||
$mttr = get_agentmodule_mttr ($content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
if ($mttr != 0) $mttr = human_time_description_raw ($mttr);
|
||||
|
||||
$data["title"] = __('MTTR');
|
||||
$data["objdata"] = format_numeric($mttr);
|
||||
break;
|
||||
}
|
||||
xml_array ($data);
|
||||
|
|
Loading…
Reference in New Issue