0)
if (!isset($groups[$graph["id_group"]])){
continue;
}
if ($only_names) {
$graphs[$graph['id_graph']] = $graph['name'];
}
else {
$graphs[$graph['id_graph']] = $graph;
$graphsCount = db_get_value_sql("SELECT COUNT(id_gs) FROM tgraph_source WHERE id_graph = " . $graph['id_graph']);
$graphs[$graph['id_graph']]['graphs_count'] = $graphsCount;
}
}
return $graphs;
}
/**
* Print a custom graph image.
*
* @param $id_graph Graph id to print.
* @param $height Height of the returning image.
* @param $width Width of the returning image.
* @param $period Period of time to get data in seconds.
* @param $stacked Wheter the graph is stacked or not.
* @param $return Whether to return an output string or echo now (optional, echo by default).
* @param $date Date to start printing the graph
*/
function custom_graphs_print ($id_graph, $height, $width, $period, $stacked, $return = false, $date = 0) {
global $config;
$sources = db_get_all_rows_field_filter ('tgraph_source', 'id_graph', $id_graph);
$modules = array ();
$weights = array ();
if($sources === false) {
echo "
".__('Empty graph')."
";
return;
}
foreach ($sources as $source) {
array_push ($modules, $source['id_agent_module']);
array_push ($weights, $source['weight']);
}
$output = graphic_combined_module($modules, $weights, $period, $width, $height,
'', '', 0, 0, 0, $stacked, $date);
if ($return)
return $output;
echo $output;
}
/**
* Get all the possible periods in a custom graph.
*
* @return The possible periods in a custom graph in an associative array.
*/
function custom_graphs_get_periods () {
$periods = array ();
$periods[1] = __('1 hour');
$periods[2] = '2 '.__('hours');
$periods[3] = '3 '.__('hours');
$periods[6] = '6 '.__('hours');
$periods[12] = '12 '.__('hours');
$periods[24] = __('1 day');
$periods[48] = __('2 days');
$periods[168] = __('1 week');
$periods[720] = __('1 month');
$periods[4320] = __('6 months');
return $periods;
}
/**
* Get all the possible periods in a custom graph in seconds.
*
* @return The possible periods in a custom graph in an associative array.
*/
function custom_graphs_get_sec_periods () {
$periods = array ();
$periods[3600] = __('1 hour');
$periods[7200] = '2 '.__('hours');
$periods[10800] = '3 '.__('hours');
$periods[21600] = '6 '.__('hours');
$periods[43200] = '12 '.__('hours');
$periods[86400] = __('1 day');
$periods[172800] = __('2 days');
$periods[345600] = __('4 days');
$periods[604800] = __('1 week');
$periods[1296000] = __('15 daysk');
$periods[2592000] = __('1 month');
$periods[5184000] = __('2 months');
$periods[15552000] = __('6 months');
$periods[31104000] = __('1 year');
return $periods;
}
?>