mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Added nt top N HTML report
Former-commit-id: b9151e9eb32f6da305cb9b061746ecbe7c8cb763
This commit is contained in:
parent
775ebfe1d2
commit
d7b25fa65d
@ -675,6 +675,12 @@ function reporting_make_reporting_data($report = null, $id_report,
|
|||||||
$content,
|
$content,
|
||||||
$pdf);
|
$pdf);
|
||||||
break;
|
break;
|
||||||
|
case 'nt_top_n':
|
||||||
|
$report['contents'][] = reporting_nt_top_n_report(
|
||||||
|
$report,
|
||||||
|
$content,
|
||||||
|
$pdf);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
$index_content++;
|
$index_content++;
|
||||||
}
|
}
|
||||||
@ -10518,4 +10524,36 @@ function reporting_translate_sla_status_for_graph ($status) {
|
|||||||
);
|
);
|
||||||
return $sts[$status];
|
return $sts[$status];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the required data to build network traffic top N report
|
||||||
|
*
|
||||||
|
* @param int Period (time window).
|
||||||
|
* @param array Information about the item of report.
|
||||||
|
* @param bool Pdf or not
|
||||||
|
*
|
||||||
|
* @return array With report presentation info and report data.
|
||||||
|
*/
|
||||||
|
function reporting_nt_top_n_report ($period, $content, $pdf) {
|
||||||
|
$return['type'] = 'nt_top_n';
|
||||||
|
$return['title'] = $content["name"];
|
||||||
|
$return["description"] = $content["description"];
|
||||||
|
|
||||||
|
// Get the data sent and received
|
||||||
|
$return["data"] = array();
|
||||||
|
$start_time = $period['datetime'] - (int)$content['period'];
|
||||||
|
$sql = "SELECT SUM(bytes) sum_bytes, SUM(pkts) sum_pkts, %s host
|
||||||
|
FROM tnetwork_matrix
|
||||||
|
WHERE utimestamp > {$start_time} AND utimestamp < {$period['datetime']}
|
||||||
|
GROUP BY %s
|
||||||
|
ORDER BY sum_bytes DESC
|
||||||
|
LIMIT {$content['top_n_value']}";
|
||||||
|
$return["data"]["send"] = db_get_all_rows_sql(
|
||||||
|
sprintf($sql, "source", "source")
|
||||||
|
);
|
||||||
|
$return["data"]["recv"] = db_get_all_rows_sql(
|
||||||
|
sprintf($sql, "destination", "destination")
|
||||||
|
);
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -319,6 +319,9 @@ function reporting_html_print_report($report, $mini = false, $report_info = 1) {
|
|||||||
case 'SLA':
|
case 'SLA':
|
||||||
reporting_html_SLA($table, $item, $mini);
|
reporting_html_SLA($table, $item, $mini);
|
||||||
break;
|
break;
|
||||||
|
case 'nt_top_n':
|
||||||
|
reporting_html_nt_top_n($table, $item, $mini);
|
||||||
|
break;
|
||||||
case 'SLA_monthly':
|
case 'SLA_monthly':
|
||||||
reporting_enterprise_html_SLA_monthly($table, $item, $mini);
|
reporting_enterprise_html_SLA_monthly($table, $item, $mini);
|
||||||
break;
|
break;
|
||||||
@ -3922,4 +3925,58 @@ function reporting_html_planned_downtimes_table ($planned_downtimes) {
|
|||||||
return $downtimes_table;
|
return $downtimes_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print network traffic data into top n tables
|
||||||
|
* (one for received data and another for sent)
|
||||||
|
*
|
||||||
|
* @param stdClass Table class to paint the report
|
||||||
|
* @param array Associative array with info about
|
||||||
|
* @param bool Unused
|
||||||
|
*/
|
||||||
|
function reporting_html_nt_top_n ($table, $item, $mini) {
|
||||||
|
// Prepare the table
|
||||||
|
$table_top = new stdClass();
|
||||||
|
$table_top->cellpadding = 0;
|
||||||
|
$table_top->cellspacing = 0;
|
||||||
|
$table_top->width = "100%";
|
||||||
|
$table_top->class = "databox data";
|
||||||
|
$table_top->cellpadding = 0;
|
||||||
|
$table_top->cellspacing = 0;
|
||||||
|
$table_top->width = "100%";
|
||||||
|
$table_top->class = "databox data";
|
||||||
|
$table_top->head['host'] = __('Agent');
|
||||||
|
$table_top->head['bytes'] = __('Bytes');
|
||||||
|
$table_top->head['pkts'] = __('Packages');
|
||||||
|
|
||||||
|
// Build the table for sent packages
|
||||||
|
if (empty($item["data"]["send"])) {
|
||||||
|
$table->data["send_title"] = "<h3>" . __("No network traffic sent data") . "</h3>";
|
||||||
|
} else {
|
||||||
|
foreach ($item["data"]["send"] as $s_item) {
|
||||||
|
$table_top->data[] = array(
|
||||||
|
'host' => $s_item["host"],
|
||||||
|
'bytes' => $s_item["sum_bytes"],
|
||||||
|
'pkts' => $s_item["sum_pkts"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$table->data["send"] = html_print_table($table_top, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset the table and build the table for received packages
|
||||||
|
$table_top->data = array();
|
||||||
|
if (empty($item["data"]["send"])) {
|
||||||
|
$table->data["recv_title"] = "<h3>" . __("No network traffic received data") . "</h3>";
|
||||||
|
} else {
|
||||||
|
foreach ($item["data"]["recv"] as $s_item) {
|
||||||
|
$table_top->data[] = array(
|
||||||
|
'host' => $s_item["host"],
|
||||||
|
'bytes' => $s_item["sum_bytes"],
|
||||||
|
'pkts' => $s_item["sum_pkts"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$table->data["recv_title"] = "<h3>" . __("Network traffic received") . "</h3>";
|
||||||
|
$table->data["recv"] = html_print_table($table_top, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user