Removed unused code (meta static graphs)

This commit is contained in:
fermin831 2018-11-08 16:46:34 +01:00
parent 64a5c626c1
commit 80d3299b2b
2 changed files with 93 additions and 190 deletions

View File

@ -25,13 +25,12 @@ if ($get_image_path_status){
$only_src = get_parameter("only_src", 0);
$result = array();
$result['bad'] = html_print_image($img_src . '_bad.png', true, '', $only_src);
$result['ok'] = html_print_image($img_src . '_ok.png', true, '', $only_src);
$result['warning'] = html_print_image($img_src . '_warning.png', true, '', $only_src);
$result['ok'] = html_print_image($img_src . '_ok.png', true, '', $only_src);
$result['normal'] = html_print_image($img_src . '.png', true, '', $only_src);
echo json_encode($result);
return;
}

View File

@ -1633,78 +1633,11 @@ function visual_map_print_item($mode = "read", $layoutData,
break;
case STATIC_GRAPH:
case GROUP_ITEM:
if (! defined ('METACONSOLE')) {
}
else {
// For each server defined and not disabled:
$servers = db_get_all_rows_sql ('SELECT *
FROM tmetaconsole_setup
WHERE disabled = 0');
if ($servers === false)
$servers = array();
$result = array();
$count_modules = 0;
foreach ($servers as $server) {
// If connection was good then retrieve all data server
if (metaconsole_connect($server) == NOERR)
$connection = true;
else
$connection = false;
$result_server = db_get_all_rows_sql ($sql);
if (!empty($result_server)) {
// Create HASH login info
$pwd = $server['auth_token'];
$auth_serialized = json_decode($pwd,true);
if (is_array($auth_serialized)) {
$pwd = $auth_serialized['auth_token'];
$api_password = $auth_serialized['api_password'];
$console_user = $auth_serialized['console_user'];
$console_password = $auth_serialized['console_password'];
}
$user = $config['id_user'];
$user_rot13 = str_rot13($config['id_user']);
$hashdata = $user.$pwd;
$hashdata = md5($hashdata);
$url_hash = '&' .
'loginhash=auto&' .
'loginhash_data=' . $hashdata . '&' .
'loginhash_user=' . $user_rot13;
foreach ($result_server as $result_element_key => $result_element_value) {
$result_server[$result_element_key]['server_id'] = $server['id'];
$result_server[$result_element_key]['server_name'] = $server['server_name'];
$result_server[$result_element_key]['server_url'] = $server['server_url'].'/';
$result_server[$result_element_key]['hashdata'] = $hashdata;
$result_server[$result_element_key]['user'] = $config['id_user'];
$count_modules++;
}
$result = array_merge($result, $result_server);
}
if ($connection) {
metaconsole_restore_db();
}
}
}
if (($layoutData['image'] != null && $layoutData['image'] != 'none') || $layoutData['show_statistics'] == 1) {
$img_style_title = strip_tags($label);
if ($layoutData['type'] == STATIC_GRAPH) {
if ($layoutData['id_agente_modulo'] != 0) {
if ($layoutData['id_metaconsole'] != 0) {
//Metaconsole db connection
$connection = db_get_row_filter ('tmetaconsole_setup',
@ -1780,83 +1713,84 @@ function visual_map_print_item($mode = "read", $layoutData,
else if($layoutData['label_position']=='right'){
$imgpos = 'float:left';
}
$varsize = getimagesize($config['homedir'] . '/' . $img);
if($layoutData['show_statistics'] == 1){
if($layoutData['show_statistics'] == 1) {
if (get_parameter('action') == 'edit') {
if ($width == 0 || $height == 0) {
echo '<img id="image_'.$id.'" src="images/console/signes/group_status.png" style="width:520px;height:80px;'.$imgpos.'">';
echo '<img id="image_'.$id.'" src="images/console/signes/group_status.png" style="width:520px;height:80px;'.$imgpos.'">';
}
else{
echo '<img id="image_'.$id.'" src="images/console/signes/group_status.png" style="width:'.$width.'px;height:'.$height.'px;'.$imgpos.'">';
echo '<img id="image_'.$id.'" src="images/console/signes/group_status.png" style="width:'.$width.'px;height:'.$height.'px;'.$imgpos.'">';
}
}
else{
$agents_critical = agents_get_agents(array (
'disabled' => 0,
'id_grupo' => $layoutData['id_group'],
'status' => AGENT_STATUS_CRITICAL),
array ('COUNT(*) as total'), 'AR', false);
$agents_warning = agents_get_agents(array (
'disabled' => 0,
'id_grupo' => $layoutData['id_group'],
'status' => AGENT_STATUS_WARNING),
array ('COUNT(*) as total'), 'AR', false);
$agents_unknown = agents_get_agents(array (
'disabled' => 0,
'id_grupo' => $layoutData['id_group'],
'status' => AGENT_STATUS_UNKNOWN),
array ('COUNT(*) as total'), 'AR', false);
$agents_ok = agents_get_agents(array (
'disabled' => 0,
'id_grupo' => $layoutData['id_group'],
'status' => AGENT_STATUS_OK),
array ('COUNT(*) as total'), 'AR', false);
$total_agents = $agents_critical[0]['total'] + $agents_warning[0]['total'] + $agents_unknown[0]['total'] + $agents_ok[0]['total'];
$stat_agent_ok = $agents_ok[0]['total']/$total_agents*100;
$stat_agent_wa = $agents_warning[0]['total']/$total_agents*100;
$stat_agent_cr = $agents_critical[0]['total']/$total_agents*100;
$stat_agent_un = $agents_unknown[0]['total']/$total_agents*100;
if($width == 0 || $height == 0){
$dyn_width = 520;
$dyn_height = 80;
}
else{
$dyn_width = $width;
$dyn_height = $height;
}
echo '<table cellpadding="0" cellspacing="0" border="0" class="databox" style="width:'.$dyn_width.'px;height:'.$dyn_height.'px;text-align:center;';
if($layoutData['label_position'] == 'left'){
echo "float:right;";
}
elseif ($layoutData['label_position'] == 'right') {
echo "float:left;";
}
echo '">';
echo "<tr style='height:10%;'>";
echo "<th style='text-align:center;background-color:#9d9ea0;color:black;font-weight:bold;'>" .groups_get_name($layoutData['id_group'],true) . "</th>";
echo "</tr>";
echo "<tr style='background-color:whitesmoke;height:90%;'>";
echo "<td>";
$agents_critical = agents_get_agents(
array (
'disabled' => 0,
'id_grupo' => $layoutData['id_group'],
'status' => AGENT_STATUS_CRITICAL
),
array ('COUNT(*) as total'),
'AR',
false
);
$agents_warning = agents_get_agents(
array (
'disabled' => 0,
'id_grupo' => $layoutData['id_group'],
'status' => AGENT_STATUS_WARNING
),
array ('COUNT(*) as total'),
'AR',
false
);
$agents_unknown = agents_get_agents(
array (
'disabled' => 0,
'id_grupo' => $layoutData['id_group'],
'status' => AGENT_STATUS_UNKNOWN
),
array ('COUNT(*) as total'),
'AR',
false
);
$agents_ok = agents_get_agents(
array (
'disabled' => 0,
'id_grupo' => $layoutData['id_group'],
'status' => AGENT_STATUS_OK
),
array ('COUNT(*) as total'),
'AR',
false
);
$total_agents = $agents_critical[0]['total'] + $agents_warning[0]['total'] + $agents_unknown[0]['total'] + $agents_ok[0]['total'];
$stat_agent_ok = $agents_ok[0]['total']/$total_agents*100;
$stat_agent_wa = $agents_warning[0]['total']/$total_agents*100;
$stat_agent_cr = $agents_critical[0]['total']/$total_agents*100;
$stat_agent_un = $agents_unknown[0]['total']/$total_agents*100;
if($width == 0 || $height == 0){
$dyn_width = 520;
$dyn_height = 80;
} else {
$dyn_width = $width;
$dyn_height = $height;
}
echo '<table cellpadding="0" cellspacing="0" border="0" class="databox" style="width:'.$dyn_width.'px;height:'.$dyn_height.'px;text-align:center;';
if($layoutData['label_position'] == 'left'){
echo "float:right;";
}
elseif ($layoutData['label_position'] == 'right') {
echo "float:left;";
}
echo '">';
echo "<tr style='height:10%;'>";
echo "<th style='text-align:center;background-color:#9d9ea0;color:black;font-weight:bold;'>" .groups_get_name($layoutData['id_group'],true) . "</th>";
echo "</tr>";
echo "<tr style='background-color:whitesmoke;height:90%;'>";
echo "<td>";
echo "<div style='margin-left:2%;color: #FFF;font-size: 12px;display:inline;background-color:#FC4444;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_cr, 2)) ."%</div>";
echo "<div style='background-color:white;color: black ;font-size: 12px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Critical</div>";
echo "<div style='margin-left:2%;color: #FFF;font-size: 12px;display:inline;background-color:#f8db3f;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_wa, 2)) ."%</div>";
@ -1865,68 +1799,38 @@ function visual_map_print_item($mode = "read", $layoutData,
echo "<div style='background-color:white;color: black ;font-size: 12px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Normal</div>";
echo "<div style='margin-left:2%;color: #FFF;font-size: 12px;display:inline;background-color:#9d9ea0;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_un, 2)) ."%</div>";
echo "<div style='background-color:white;color: black ;font-size: 12px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Unknown</div>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "</table>";
}
}
else{
} else {
$options = array(
"class" => "image",
"id" => "image_" . $id,
"title" => $img_style_title,
"style" => $borderStyle.$imgpos
);
if ($width == 0 || $height == 0) {
if($varsize[0] > 150 || $varsize[1] > 150){
echo html_print_image($img, true,
array("class" => "image",
"id" => "image_" . $id,
"width" => "70px",
"height" => "70px",
"title" => $img_style_title,
"style" => $borderStyle.$imgpos), false,
false, false, $isExternalLink);
}
else{
echo html_print_image($img, true,
array("class" => "image",
"id" => "image_" . $id,
"title" => $img_style_title,
"style" => $borderStyle.$imgpos), false,
false, false, $isExternalLink);
$options['width'] = "70px";
$options['height'] = "70px";
}
}
else{
echo html_print_image($img, true,
array("class" => "image",
"id" => "image_" . $id,
"width" => $width,
"height" => $height,
"title" => $img_style_title,
"style" => $borderStyle.$imgpos), false,
false, false, $isExternalLink);
$options['width'] = $width;
$options['height'] = $height;
}
echo html_print_image($img, true, $options,
false, false, false, $isExternalLink);
}
}
if($layoutData['label_position']=='down'){
echo io_safe_output($text);
}
else if($layoutData['label_position']=='left' || $layoutData['label_position']=='right'){
if ($layoutData['label_position'] != 'up') {
echo io_safe_output($text);
}
if (! defined ('METACONSOLE')) {
}
else {
metaconsole_restore_db();
}
break;
if (is_metaconsole()) metaconsole_restore_db();
break;
case PERCENTILE_BAR:
if (($layoutData['image'] == 'value') && ($value_text !== false)) {
$unit_text = db_get_sql ('SELECT unit