mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Fixed module events graph in vc
This commit is contained in:
parent
d57508f09e
commit
b4c31df636
@ -3565,7 +3565,7 @@ function graph_custom_sql_graph ($id, $width, $height,
|
|||||||
* @param string homeurl
|
* @param string homeurl
|
||||||
* @param bool return or echo the result
|
* @param bool return or echo the result
|
||||||
*/
|
*/
|
||||||
function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $homeurl, $return = false, $id_module = 0) {
|
function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $homeurl, $return = false) {
|
||||||
global $config;
|
global $config;
|
||||||
global $graphic_type;
|
global $graphic_type;
|
||||||
|
|
||||||
@ -3605,19 +3605,112 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho
|
|||||||
$full_legend[$cont] = $name;
|
$full_legend[$cont] = $name;
|
||||||
|
|
||||||
$top = $datelimit + ($periodtime * ($i + 1));
|
$top = $datelimit + ($periodtime * ($i + 1));
|
||||||
if ($id_module != 0) {
|
$event = db_get_row_filter ('tevento',
|
||||||
$event = db_get_row_filter ('tevento',
|
array ('id_agente' => $id_agent,
|
||||||
array ('id_agente' => $id_agent,
|
'utimestamp > '.$bottom,
|
||||||
'utimestamp > '.$bottom,
|
'utimestamp < '.$top), 'criticity, utimestamp');
|
||||||
'utimestamp < '.$top), 'criticity, utimestamp');
|
|
||||||
|
if (!empty($event['utimestamp'])) {
|
||||||
|
$data[$cont]['utimestamp'] = $periodtime;
|
||||||
|
switch ($event['criticity']) {
|
||||||
|
case EVENT_CRIT_WARNING:
|
||||||
|
$data[$cont]['data'] = 2;
|
||||||
|
break;
|
||||||
|
case EVENT_CRIT_CRITICAL:
|
||||||
|
$data[$cont]['data'] = 3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$data[$cont]['data'] = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$event = db_get_row_filter ('tevento',
|
$data[$cont]['utimestamp'] = $periodtime;
|
||||||
array ('id_agente' => $id_agent,
|
$data[$cont]['data'] = 1;
|
||||||
'id_agentmodule' => $id_module,
|
|
||||||
'utimestamp > '.$bottom,
|
|
||||||
'utimestamp < '.$top), 'criticity, utimestamp');
|
|
||||||
}
|
}
|
||||||
|
$cont++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$colors = array(1 => COL_NORMAL, 2 => COL_WARNING, 3 => COL_CRITICAL, 4 => COL_UNKNOWN);
|
||||||
|
|
||||||
|
// Draw slicebar graph
|
||||||
|
if ($config['flash_charts']) {
|
||||||
|
$out = flot_slicesbar_graph($data, $period, $width, $height, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$out = slicesbar_graph($data, $period, $width, $height, $colors, $config['fontpath'], $config['round_corner'], $homeurl);
|
||||||
|
|
||||||
|
// Draw legend
|
||||||
|
$out .= "<br>";
|
||||||
|
$out .= " ";
|
||||||
|
foreach ($legend as $hour) {
|
||||||
|
$out .= "<span style='font-size: 6pt'>" . $hour . "</span>";
|
||||||
|
$out .= " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($return) {
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo $out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a static graph with event data of agents
|
||||||
|
*
|
||||||
|
* @param integer id_agent Agent ID
|
||||||
|
* @param integer width pie graph width
|
||||||
|
* @param integer height pie graph height
|
||||||
|
* @param integer period time period
|
||||||
|
* @param string homeurl
|
||||||
|
* @param bool return or echo the result
|
||||||
|
*/
|
||||||
|
function graph_graphic_moduleevents ($id_agent, $id_module, $width, $height, $period = 0, $homeurl, $return = false) {
|
||||||
|
global $config;
|
||||||
|
global $graphic_type;
|
||||||
|
|
||||||
|
$data = array ();
|
||||||
|
|
||||||
|
$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph
|
||||||
|
$interval = (int) ($period / $resolution);
|
||||||
|
$date = get_system_time ();
|
||||||
|
$datelimit = $date - $period;
|
||||||
|
$periodtime = floor ($period / $interval);
|
||||||
|
$time = array ();
|
||||||
|
$data = array ();
|
||||||
|
$legend = array();
|
||||||
|
$full_legend = array();
|
||||||
|
|
||||||
|
$cont = 0;
|
||||||
|
for ($i = 0; $i < $interval; $i++) {
|
||||||
|
$bottom = $datelimit + ($periodtime * $i);
|
||||||
|
if (! $graphic_type) {
|
||||||
|
if ($config['flash_charts']) {
|
||||||
|
$name = date('H:i:s', $bottom);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$name = date('H\h', $bottom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$name = $bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show less values in legend
|
||||||
|
if ($cont == 0 or $cont % 2)
|
||||||
|
$legend[$cont] = $name;
|
||||||
|
|
||||||
|
$full_legend[$cont] = $name;
|
||||||
|
|
||||||
|
$top = $datelimit + ($periodtime * ($i + 1));
|
||||||
|
|
||||||
|
$event = db_get_row_filter ('tevento',
|
||||||
|
array ('id_agente' => $id_agent,
|
||||||
|
'id_agentmodule' => $id_module,
|
||||||
|
'utimestamp > '.$bottom,
|
||||||
|
'utimestamp < '.$top), 'criticity, utimestamp');
|
||||||
|
|
||||||
if (!empty($event['utimestamp'])) {
|
if (!empty($event['utimestamp'])) {
|
||||||
$data[$cont]['utimestamp'] = $periodtime;
|
$data[$cont]['utimestamp'] = $periodtime;
|
||||||
|
@ -1097,27 +1097,27 @@ function visual_map_print_item($mode = "read", $layoutData,
|
|||||||
if ($width == 0 || $height == 0) {
|
if ($width == 0 || $height == 0) {
|
||||||
if ($layoutData['label_position']=='left') {
|
if ($layoutData['label_position']=='left') {
|
||||||
$img = '<div style="float:left;height:'.$himg.'px;">' .
|
$img = '<div style="float:left;height:'.$himg.'px;">' .
|
||||||
$img = graph_graphic_agentevents ($layoutData['id_agent'], 500, 50, $layoutData['period'], '', true, $layoutData['id_agente_modulo']);
|
$img = graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true);
|
||||||
}
|
}
|
||||||
elseif ($layoutData['label_position']=='right') {
|
elseif ($layoutData['label_position']=='right') {
|
||||||
$img = '<div style="float:right;height:'.$himg.'px;">' .
|
$img = '<div style="float:right;height:'.$himg.'px;">' .
|
||||||
$img = graph_graphic_agentevents ($layoutData['id_agent'], 500, 50, $layoutData['period'], '', true, $layoutData['id_agente_modulo']);
|
$img = graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$img = graph_graphic_agentevents ($layoutData['id_agent'], 500, 50, $layoutData['period'], '', true, $layoutData['id_agente_modulo']);
|
$img = graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if ($layoutData['label_position']=='left') {
|
if ($layoutData['label_position']=='left') {
|
||||||
$img = '<div style="float:left;height:'.$himg.'px;">' .
|
$img = '<div style="float:left;height:'.$himg.'px;">' .
|
||||||
$img = graph_graphic_agentevents ($layoutData['id_agent'], $width, $height, $layoutData['period'], '', true, $layoutData['id_agente_modulo']);
|
$img = graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true);
|
||||||
}
|
}
|
||||||
elseif ($layoutData['label_position']=='right') {
|
elseif ($layoutData['label_position']=='right') {
|
||||||
$img = '<div style="float:right;height:'.$himg.'px;">' .
|
$img = '<div style="float:right;height:'.$himg.'px;">' .
|
||||||
$img = graph_graphic_agentevents ($layoutData['id_agent'], $width, $height, $layoutData['period'], '', true, $layoutData['id_agente_modulo']);
|
$img = graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$img = graph_graphic_agentevents ($layoutData['id_agent'], $width, $height, $layoutData['period'], '', true, $layoutData['id_agente_modulo']);
|
$img = graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user