diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index f0e69a6ae3..920cd76295 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -227,6 +227,7 @@ config_check(); } $table->data[0][3] = $maintenance_img; + // Main help icon $table->data[0][4] = ui_print_help_icon ("main_help", true, '', 'images/header_help.png'); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index be8db775eb..6700e82a81 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -918,7 +918,7 @@ if ($update_module || $create_module) { $plugin_parameter = (string) get_parameter ('plugin_parameter'); } - + $ip_target = (string) get_parameter ('ip_target'); $custom_id = (string) get_parameter ('custom_id'); $history_data = (int) get_parameter('history_data'); diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index e79a653d6b..ea2127f59e 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -139,6 +139,7 @@ if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "PM")) else $return_all_group = true; html_print_select_groups(false, "AR", $return_all_group, "ag_group", $ag_group, 'this.form.submit();', '', 0, false, false, true, '', false, 'width:100px;'); + echo "<td>"; echo __('Show Agents') . ' '; $fields = array( @@ -406,6 +407,7 @@ else { } } + $agents = db_get_all_rows_sql ($sql); // Delete rnum row generated by oracle_recode_query() function diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index ccff4f36b5..14d7e8ed77 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -31,7 +31,7 @@ if (is_ajax ()) { $component['throw_unknown_events'] = !network_components_is_disable_type_event($id_component, EVENTS_GOING_UNKNOWN); - + // Decrypt passwords in the component. $component['plugin_pass'] = io_output_password($component['plugin_pass']); diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 40c00406da..9552e12827 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -140,7 +140,7 @@ if (is_ajax ()) { $rfield = html_print_select($fields_value_select, 'field'.$i.'_recovery_value', '', '', '', 0, true, false, false, 'fields_recovery'); } - else{ + else { $ffield = html_print_textarea ('field' . $i . '_value',1, 1, $fv[0], 'style="min-height:40px" class="fields"', true); $rfield = html_print_textarea ('field' . $i . '_recovery_value', 1, 1, $fv[0], diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 1dfdbb2200..77fe5bbfa3 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -306,7 +306,7 @@ $(document).ready (function () { $("[name=field" + i + "_value]").val(old_value); $("[name=field" + i + "_recovery_value]").val(old_recovery_value); } - else{ + else { $("[name=field" + i + "_value]").val($("[name=field" + i + "_value]").val()); $("[name=field" + i + "_recovery_value]").val($("[name=field" + i + "_recovery_value]").val()); } diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index 26bad3f89a..176a6623ac 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -471,7 +471,7 @@ print_alert_template_steps ($step, $id); $table->id = 'template'; $table->width = '98%'; -if(defined("METACONSOLE")){ +if(defined("METACONSOLE")) { $table->width = '100%'; $table->class = 'databox data'; $table->head[0] = __('Create Template'); @@ -479,7 +479,7 @@ if(defined("METACONSOLE")){ $table->headstyle[0] = 'text-align: center'; } $table->style = array (); -if(!defined("METACONSOLE")){ +if(!defined("METACONSOLE")) { $table->style[0] = 'font-weight: bold; vertical-align: top'; $table->style[2] = 'font-weight: bold; vertical-align: top'; } diff --git a/pandora_console/godmode/category/category.php b/pandora_console/godmode/category/category.php index d6129a11e3..dfe354aad3 100755 --- a/pandora_console/godmode/category/category.php +++ b/pandora_console/godmode/category/category.php @@ -43,7 +43,7 @@ if(defined('METACONSOLE')) { 'text' => '<a href="index.php?sec=advanced&sec2=godmode/category/category&tab=list&pure='.(int)$config['pure'].'">' . html_print_image ("images/list.png", true, array ("title" => __('List categories'))) .'</a>')); } -else{ +else { $buttons = array( 'list' => array( 'active' => false, @@ -132,6 +132,7 @@ if (!empty($result)) { $iterator++; $data = array (); + if(defined('METACONSOLE')){ $data[0] = "<a href='index.php?sec=advanced&sec2=godmode/category/edit_category&action=update&id_category=" . $category["id"] . "&pure=" . (int)$config['pure'] . "'>" . $category["name"] . "</a>"; $data[1] = "<a href='index.php?sec=advanced&sec2=godmode/category/edit_category&action=update&id_category=".$category["id"] . "&pure=" . (int)$config['pure'] . "'>" . html_print_image("images/config.png", true, array("title" => "Edit")) . "</a> "; diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index e0cceddebc..2382378e6b 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -28,6 +28,7 @@ if (! check_acl($config['id_user'], 0, "EW")) { $update = get_parameter('upd_button', ''); $default = (int) get_parameter('default', 0); + if ($default != 0) { $event_fields = io_safe_input('evento,id_agente,estado,timestamp'); $fields_selected = explode (',', $event_fields); diff --git a/pandora_console/godmode/events/event_edit_filter.php b/pandora_console/godmode/events/event_edit_filter.php index af44c2a72a..5891fd4db3 100644 --- a/pandora_console/godmode/events/event_edit_filter.php +++ b/pandora_console/godmode/events/event_edit_filter.php @@ -157,7 +157,8 @@ $table->class = "databox"; $table->style[0] = 'vertical-align: top;'; $table->valign[1] = 'top'; -if (defined('METACONSOLE')){ + +if (defined('METACONSOLE')) { $table->width = '100%'; $table->border = 0; $table->cellspacing = 3; @@ -285,7 +286,7 @@ $add_without_tag_disabled = empty($tags_select_without); $remove_without_tag_disabled = empty($tag_without_temp); -if (defined("METACONSOLE")){ +if (defined("METACONSOLE")) { $table->data[13][0] = '<b>' . __('Events with following tags') . '</b>'; $table->data[13][0] .= '<br>' . html_print_select ($tags_select_with, 'select_with', @@ -537,4 +538,4 @@ function replace_hidden_tags(what_button) { $(id_hidden).val(Base64.encode(jQuery.toJSON(value_store))); } /* ]]> */ -</script> +</script> \ No newline at end of file diff --git a/pandora_console/godmode/events/event_responses.editor.php b/pandora_console/godmode/events/event_responses.editor.php index 1bca27e8c7..4f5da16a6b 100644 --- a/pandora_console/godmode/events/event_responses.editor.php +++ b/pandora_console/godmode/events/event_responses.editor.php @@ -57,7 +57,7 @@ else { $table->width = '90%'; -if(defined('METACONSOLE')){ +if(defined('METACONSOLE')) { $table->width = '100%'; $table->class = 'databox data'; $table->head[0] = __('Edit event responses'); diff --git a/pandora_console/godmode/events/event_responses.list.php b/pandora_console/godmode/events/event_responses.list.php index 687c8e81a4..174b60288e 100644 --- a/pandora_console/godmode/events/event_responses.list.php +++ b/pandora_console/godmode/events/event_responses.list.php @@ -25,7 +25,7 @@ if (! check_acl($config['id_user'], 0, "PM")) { return; } -if(!defined('METACONSOLE')){ +if(!defined('METACONSOLE')) { echo '<br><br><div style="width:99%;text-align:right;">'; echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/events§ion=responses&mode=editor&pure='.$config['pure'].'">'; html_print_submit_button(__('Create response'), 'create_response_button', false, array('class' => 'sub next')); @@ -78,7 +78,7 @@ foreach($event_responses as $response) { html_print_table($table); -if(defined('METACONSOLE')){ +if(defined('METACONSOLE')) { echo '<br><br><div style="width:100%;text-align:right;">'; echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/events§ion=responses&mode=editor&pure='.$config['pure'].'">'; html_print_submit_button(__('Create response'), 'create_response_button', false, array('class' => 'sub next')); diff --git a/pandora_console/godmode/massive/massive_add_action_alerts.php b/pandora_console/godmode/massive/massive_add_action_alerts.php index 85d32ae932..7262fce4f3 100755 --- a/pandora_console/godmode/massive/massive_add_action_alerts.php +++ b/pandora_console/godmode/massive/massive_add_action_alerts.php @@ -176,7 +176,7 @@ $agents_with_templates_json = json_encode($agents_with_templates_json); echo "<input type='hidden' id='hidden-agents_with_templates' value='$agents_with_templates_json'>"; -echo '<div class="action-buttons" style="width: '. $table->width . '" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; +echo '<div class="action-buttons" style="width: ' . $table->width . '" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; html_print_input_hidden ('add', 1); html_print_submit_button (__('Add'), 'go', false, 'class="sub add"'); echo '</div>'; diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 5cc76ae83a..3737e6b3a3 100644 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -58,6 +58,7 @@ $group = 0; $group_by_agent = 0; $order_uptodown = 0; $show_resume = 0; +$show_address_agent = 0; $top_n = 0; $top_n_value = 10; $exception_condition = REPORT_EXCEPTION_CONDITION_EVERYTHING; @@ -87,6 +88,7 @@ $inventory_modules = array(); $date = null; // Only avg is selected by default for the simple graphs $only_avg = true; +$time_compare_overlapped = false; //Added for events items $filter_event_validated = false; @@ -187,6 +189,9 @@ switch ($action) { $projection_period = $item['top_n_value']; $period_pg = $item['period']; } + + // HACK it is saved in show_graph field. + $time_compare_overlapped = $item['show_graph']; break; case 'prediction_date': $description = $item['description']; @@ -419,7 +424,15 @@ switch ($action) { $period = $item['period']; $order_uptodown = $item['order_uptodown']; $show_resume = $item['show_resume']; - $show_graph = $item['show_graph']; + break; + case 'availability': + $description = $item['description']; + $period = $item['period']; + $order_uptodown = $item['order_uptodown']; + $show_resume = $item['show_resume']; + // HACK it is saved in show_graph field. + // Show interfaces instead the modules + $show_address_agent = $item['show_graph']; break; case 'group_report': $description = $item['description']; @@ -498,7 +511,8 @@ switch ($action) { break; } -$urlForm = $config['homeurl'] . 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=' . $actionParameter . '&id_report=' . $idReport; +$urlForm = $config['homeurl'] . + 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=' . $actionParameter . '&id_report=' . $idReport; echo '<form action="' . $urlForm . '" method="post">'; html_print_input_hidden('id_item', $idItem); @@ -518,7 +532,7 @@ else " . __('Item Editor') . " </th> </tr> - </thead>"; + </thead>"; } ?> <tbody> @@ -552,8 +566,8 @@ else </tr> <tr id="row_netflow_filter" style="" class="datos"> <td><?php echo __('Filter');?></td> - <td><?php - + <td> + <?php $own_info = get_user_info ($config['id_user']); // Get group list that user has access @@ -1039,6 +1053,14 @@ else ?> </td> </tr> + <tr id="row_time_compare_overlapped" style="" class="datos"> + <td><?php echo __('Time compare (Overlapped)');?></td> + <td> + <?php + html_print_checkbox('time_compare_overlapped', 1, $time_compare_overlapped); + ?> + </td> + </tr> <tr id="row_only_avg" style="" class="datos"> <td><?php echo __('Only average');?></td> <td><?php html_print_checkbox('only_avg', 1, $only_avg);?></td> @@ -1080,9 +1102,28 @@ else <td><?php html_print_select ($show_graph_options, 'combo_graph_options', $show_graph);?></td> </tr> + <tr id="row_show_address_agent" style="" class="datos"> + <td> + <?php + echo __('Show address instead module name.') . + ui_print_help_tip(__('Show the main address of agent.'), true); + ?> + </td> + <td> + <?php + html_print_checkbox('checkbox_show_address_agent', 1, + $show_address_agent); + ?> + </td> + </tr> <tr id="row_show_resume" style="" class="datos"> <td><?php echo __('Show resume') . ui_print_help_tip(__('Show a resume table with max, min, average of total modules on the report bottom'), true);?></td> - <td><?php html_print_checkbox('checkbox_show_resume', 1, $show_resume);?></td> + <td> + <?php + html_print_checkbox('checkbox_show_resume', 1, + $show_resume); + ?> + </td> </tr> <tr id="row_event_filter" style="" class="datos"> <td><?php echo __('Event filter'); ?></td> @@ -1144,7 +1185,7 @@ else <br /> <?php print_SLA_list('95%', $action, $idItem); -print_General_list('95%', $action, $idItem); +print_General_list('95%', $action, $idItem, $type); echo '<div class="action-buttons" style="width: 100%">'; if ($action == 'new') { html_print_submit_button(__('Create item'), 'create_item', false, 'class="sub wand"'); @@ -1170,7 +1211,8 @@ function print_SLA_list($width, $action, $idItem = null) { global $config; global $meta; - $report_item_type = db_get_value ('type', 'treport_content', 'id_rc', $idItem); + $report_item_type = db_get_value('type', 'treport_content', 'id_rc', + $idItem); ?> <table class="databox" id="sla_list" border="0" cellpadding="4" cellspacing="4" width="100%"> <thead> @@ -1222,17 +1264,17 @@ function print_SLA_list($width, $action, $idItem = null) { $server_name_element = ''; if ($meta && $server_name != '') $server_name_element .= ' (' . $server_name . ')'; - + echo '<tr id="sla_' . $item['id'] . '" style="" class="datos">'; echo '<td class="sla_list_agent_col">' . printSmallFont($nameAgent) . $server_name_element . '</td>'; echo '<td class="sla_list_module_col">' . printSmallFont($nameModule) . '</td>'; - + if (enterprise_installed() && $report_item_type == 'SLA_services') { enterprise_include_once("include/functions_services.php"); $nameService = enterprise_hook('services_get_name', array($item['id_agent_module'])); echo '<td class="sla_list_service_col">' . printSmallFont($nameService) . '</th>'; } - + echo '<td class="sla_list_sla_min_col">' . $item['sla_min'] . '</td>'; echo '<td class="sla_list_sla_max_col">' . $item['sla_max'] . '</td>'; echo '<td class="sla_list_sla_limit_col">' . $item['sla_limit'] . '</td>'; @@ -1322,9 +1364,10 @@ function print_SLA_list($width, $action, $idItem = null) { <?php } -function print_General_list($width, $action, $idItem = null) { +function print_General_list($width, $action, $idItem = null, $type = 'general') { global $config; global $meta; + if (!isset($meta)) $meta = false; @@ -1339,11 +1382,24 @@ function print_General_list($width, $action, $idItem = null) { <table class="databox" id="general_list" border="0" cellpadding="4" cellspacing="4" width="100%"> <thead> <tr> - <th class="header" scope="col"><?php echo __('Agent');?></th> - <th class="header" scope="col"><?php echo __('Module');?></th> - <th class="header" scope="col"><?php echo __('Operation') . - ui_print_help_tip(__("Please be careful, when the module have diferent intervals in their life, the summatory maybe get bad result."), true);?></th> - <th class="header" scope="col"><?php echo __('Action');?></th> + <?php + if ($type == "availability") { + ?> + <th class="header" scope="col"><?php echo __('Agent');?></th> + <th class="header" scope="col"><?php echo __('Module');?></th> + <th class="header" scope="col"><?php echo __('Action');?></th> + <?php + } + else { + ?> + <th class="header" scope="col"><?php echo __('Agent');?></th> + <th class="header" scope="col"><?php echo __('Module');?></th> + <th class="header" scope="col"><?php echo __('Operation') . + ui_print_help_tip(__("Please be careful, when the module have diferent intervals in their life, the summatory maybe get bad result."), true);?></th> + <th class="header" scope="col"><?php echo __('Action');?></th> + <?php + } + ?> </tr> </thead> <?php @@ -1359,10 +1415,13 @@ function print_General_list($width, $action, $idItem = null) { case 'update': case 'edit': echo '<tbody id="list_general">'; - $itemsGeneral = db_get_all_rows_filter('treport_content_item', array('id_report_content' => $idItem)); + $itemsGeneral = db_get_all_rows_filter( + 'treport_content_item', + array('id_report_content' => $idItem)); if ($itemsGeneral === false) { $itemsGeneral = array(); } + foreach ($itemsGeneral as $item) { $server_name = $item ['server_name']; // Metaconsole db connection @@ -1373,22 +1432,41 @@ function print_General_list($width, $action, $idItem = null) { continue; } } - $idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); + $idAgent = db_get_value_filter( + 'id_agente', 'tagente_modulo', + array('id_agente_modulo' => $item['id_agent_module'])); + $nameAgent = agents_get_name ($idAgent); $nameModule = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); $server_name_element = ''; if ($meta && $server_name != '') - $server_name_element .= ' (' . $server_name . ')'; + $server_name_element .= ' (' . $server_name . ')'; - echo '<tr id="general_' . $item['id'] . '" style="" class="datos"> + + if ($type == "availability") { + echo '<tr id="general_' . $item['id'] . '" style="" class="datos"> <td>' . printSmallFont($nameAgent) . $server_name_element . '</td> <td>' . printSmallFont($nameModule) . '</td> - <td>' . printSmallFont($operation[$item['operation']]) . '</td> <td style="text-align: center;"> <a href="javascript: deleteGeneralRow(' . $item['id'] . ');">' . html_print_image("images/cross.png", true) . '</a> </td> </tr>'; + } + else { + echo '<tr id="general_' . $item['id'] . '" style="" class="datos"> + <td>' . printSmallFont($nameAgent) . $server_name_element . '</td> + <td>' . printSmallFont($nameModule) . '</td> + <td>' . + printSmallFont($operation[$item['operation']]) . + '</td> + <td style="text-align: center;"> + <a href="javascript: deleteGeneralRow(' . $item['id'] . ');">' . html_print_image("images/cross.png", true) . '</a> + </td> + </tr>'; + } + + if ($meta) { //Restore db connection metaconsole_restore_db(); @@ -1400,7 +1478,13 @@ function print_General_list($width, $action, $idItem = null) { <tr id="row" style="display: none;" class="datos"> <td class="agent_name"></td> <td class="module_name"></td> - <td class="operation_name"></td> + <?php + if ($type != "availability") { + ?> + <td class="operation_name"></td> + <?php + } + ?> <td style="text-align: center;"><a class="delete_button" href="javascript: deleteGeneralRow(0);"><?php html_print_image("images/cross.png", false); ?></a></td> </tr> </tbody> @@ -1427,8 +1511,25 @@ function print_General_list($width, $action, $idItem = null) { ui_print_agent_autocomplete_input($params); ?> </td> - <td><select id="id_agent_module_general" name="id_agente_modulo_general" disabled="disabled" style="max-width: 180px"><option value="0"><?php echo __('Select an Agent first'); ?></option></select></td> - <td><?php html_print_select ($operation, 'id_operation_module_general', 0, false, '', '', false, false, true, 'width: 200px', false); ?></td> + <td> + <select id="id_agent_module_general" name="id_agente_modulo_general" disabled="disabled" style="max-width: 180px"> + <option value="0"><?php echo __('Select an Agent first'); ?></option> + </select> + </td> + <?php + if ($type !== "availability") { + ?> + <td> + <?php + html_print_select($operation, + 'id_operation_module_general', 0, + false, '', '', false, false, true, + 'width: 200px', false); + ?> + </td> + <?php + } + ?> <td style="text-align: center;"><a href="javascript: addGeneralRow();"><?php html_print_image("images/disk.png", false); ?></a></td> </tr> </tbody> @@ -1460,7 +1561,8 @@ $(document).ready (function () { minuteText: '<?php echo __('Minute');?>', secondText: '<?php echo __('Second');?>', currentText: '<?php echo __('Now');?>', - closeText: '<?php echo __('Close');?>'}); + closeText: '<?php echo __('Close');?>' + }); }); function create_custom_graph() { @@ -1699,13 +1801,13 @@ function addSLARow() { var slaMin = $("input[name=sla_min]").val(); var slaMax = $("input[name=sla_max]").val(); var slaLimit = $("input[name=sla_limit]").val(); - + var serviceId = $("select#id_service>option:selected").val(); var serviceName = $("select#id_service>option:selected").text(); if (((idAgent != '') && (slaMin != '') && (slaMax != '') && (slaLimit != '')) || serviceId != '') { - + if (nameAgent != '') { //Truncate nameAgent var params = []; @@ -1722,7 +1824,7 @@ function addSLARow() { nameAgent = data; } }); - + //Truncate nameModule var params = []; params.push("truncate_text=1"); @@ -1748,7 +1850,7 @@ function addSLARow() { params.push("sla_max=" + slaMax); params.push("sla_limit=" + slaLimit); params.push("server_id=" + serverId); - + if (serviceId != '') { params.push("id_service=" + serviceId); } @@ -1800,7 +1902,13 @@ function addGeneralRow() { var idAgent = $("input[name=id_agent_general]").val(); var serverId = $("input[name=id_server]").val(); var idModule = $("#id_agent_module_general").val(); - var operation = $("#id_operation_module_general").val(); + var operation; + if ($("#id_operation_module_general").length) { + operation = $("#id_operation_module_general").val(); + } + else { + operation = ""; + } var nameModule = $("#id_agent_module_general :selected").text(); var nameOperation = $("#id_operation_module_general :selected").text(); @@ -1835,6 +1943,7 @@ function addGeneralRow() { nameModule = data; } }); + //Truncate nameOperation var params = []; params.push("truncate_text=1"); @@ -1850,6 +1959,7 @@ function addGeneralRow() { nameOperation = data; } }); + var params = []; params.push("add_general=1"); params.push("id=" + $("input[name=id_item]").val()); @@ -1919,9 +2029,11 @@ function chooseType() { $("#general_list").hide(); $("#row_order_uptodown").hide(); $("#row_show_resume").hide(); + $("#row_show_address_agent").hide(); $("#row_show_graph").hide(); $("#row_max_min_avg").hide(); $("#row_only_avg").hide(); + $("#row_time_compare_overlapped").hide(); $("#row_quantity").hide(); $("#row_exception_condition_value").hide(); $("#row_exception_condition").hide(); @@ -1965,6 +2077,7 @@ function chooseType() { $("#row_event_graphs").show(); break; case 'simple_graph': + $("#row_time_compare_overlapped").show(); $("#row_only_avg").show(); // The break hasn't be forgotten, this element // only should be shown on the simple graphs. @@ -1975,6 +2088,7 @@ function chooseType() { $("#row_period").show(); $("#row_show_in_two_columns").show(); $("#row_show_in_landscape").show(); + $("#row_time_compare_overlapped").show(); break; case 'projection_graph': $("#row_description").show(); @@ -2024,7 +2138,7 @@ function chooseType() { $("#row_only_display_wrong").show(); $("#row_working_time").show(); $("#row_sort").show(); - + $(".sla_list_agent_col").hide(); $(".sla_list_module_col").hide(); $(".sla_list_service_col").show(); @@ -2178,7 +2292,7 @@ function chooseType() { $("#row_event_filter").show(); $("#row_event_graphs").show(); $("#row_event_graph_by_agent").hide(); - + $('#agent_autocomplete').hide(); $('#agent_autocomplete_events').show(); break; @@ -2207,6 +2321,14 @@ function chooseType() { $("input[name='last_value']").prop("checked", true); } break; + case 'availability': + $("#row_description").show(); + $("#row_period").show(); + $("#general_list").show(); + $("#row_order_uptodown").show(); + $("#row_show_address_agent").show(); + $("#row_show_in_two_columns").show(); + break; case 'group_report': $("#row_group").show(); $("#row_servers").show(); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index c1e06300d2..2850deb5db 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -97,11 +97,11 @@ if ($idReport != 0) { $edit = true; break; } - + if (! $edit) { // The user that created the report should can delete it. Despite its permissions. $delete_report_bypass = false; - + if ($action == 'delete_report') { if ($config['id_user'] == $report['id_user'] || is_user_admin ($config["id_user"])) { $delete_report_bypass = true; @@ -342,14 +342,14 @@ switch ($action) { } break; } - + if (! $delete) { db_pandora_audit("ACL Violation", "Trying to access report builder deletion"); require ("general/noaccess.php"); exit; } - + $result = reports_delete_report ($idReport); if ($result !== false) db_pandora_audit("Report management", "Delete report #$idReport"); @@ -399,7 +399,7 @@ switch ($action) { html_print_table($table_aux); echo "</form>"; } - + ui_require_jquery_file ('pandora.controls'); ui_require_jquery_file ('ajaxqueue'); @@ -450,8 +450,14 @@ switch ($action) { $filter['metaconsole'] = 0; $reports = reports_get_reports ($filter, - array ('name', 'id_report', 'description', 'private', - 'id_user', 'id_group', 'non_interactive'), $return_all_group, 'RR', $group, $strict_user); + array ( + 'name', + 'id_report', + 'description', + 'private', + 'id_user', + 'id_group', + 'non_interactive'), $return_all_group, 'RR', $group, $strict_user); $table->width = '0px'; if (sizeof ($reports)) { @@ -541,7 +547,8 @@ switch ($action) { if (enterprise_hook ('load_custom_reporting_2') !== ENTERPRISE_NOT_HOOK) { $next = 7; } - + + //Admin options only for RM flag if (check_acl ($config['id_user'], 0, "RM")) { @@ -673,7 +680,7 @@ switch ($action) { } break; case 'update': - case 'save': + case 'save': switch ($activeTab) { case 'main': $reportName = get_parameter('name'); @@ -753,12 +760,13 @@ switch ($action) { $first_page = $config['custom_report_front_firstpage']; $footer = $config['custom_report_front_footer']; - } else { - + } + else { + $start_url = ui_get_full_url(false, false, false, false); $first_page = "<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;"><img src="" . $start_url . "/images/pandora_report_logo.png" alt="" width="800" /></p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;"><span style="font-size: xx-large;">(_REPORT_NAME_)</span></p>
<p style="text-align: center;"><span style="font-size: large;">(_DATETIME_)</span></p>"; $logo = $header = $footer = null; - + } $idOrResult = db_process_sql_insert('treport', @@ -798,7 +806,8 @@ switch ($action) { break; case 'item_editor': $resultOperationDB = null; - $report = db_get_row_filter('treport', array('id_report' => $idReport)); + $report = db_get_row_filter('treport', + array('id_report' => $idReport)); $reportName = $report['name']; $idGroupReport = $report['id_group']; @@ -871,11 +880,27 @@ switch ($action) { $values['top_n_value'] = get_parameter('max_values'); $good_format = true; break; + case 'availability': + // HACK it is saved in show_graph field. + // Show interfaces instead the modules + $values['show_graph'] = + get_parameter('checkbox_show_address_agent'); + $good_format = true; + break; + case 'simple_graph': + case 'simple_baseline_graph': + // HACK it is saved in show_graph field. + $values['show_graph'] = + (int)get_parameter('time_compare_overlapped'); + $values['period'] = get_parameter('period'); + $good_format = true; + break; default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('radiobutton_max_min_avg',0); $values['top_n_value'] = get_parameter('quantity'); $values['text'] = get_parameter('text'); + $values['show_graph'] = get_parameter('combo_graph_options'); $good_format = true; } @@ -907,7 +932,6 @@ switch ($action) { $values['order_uptodown'] = get_parameter ('radiobutton_order_uptodown'); $values['exception_condition'] = (int)get_parameter('exception_condition', 0); $values['exception_condition_value'] = get_parameter('exception_condition_value'); - $values['show_graph'] = get_parameter('combo_graph_options'); $values['id_module_group'] = get_parameter('combo_modulegroup'); $values['id_group'] = get_parameter ('combo_group'); $values['server_name'] = get_parameter ('server_name'); @@ -1087,11 +1111,27 @@ switch ($action) { $values['top_n_value'] = get_parameter('max_values'); $good_format = true; break; + case 'availability': + // HACK it is saved in show_graph field. + // Show interfaces instead the modules + $values['show_graph'] = + get_parameter('checkbox_show_address_agent'); + $good_format = true; + break; + case 'simple_graph': + case 'simple_baseline_graph': + // HACK it is saved in show_graph field. + $values['show_graph'] = + (int)get_parameter('time_compare_overlapped'); + $values['period'] = get_parameter('period'); + $good_format = true; + break; default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('radiobutton_max_min_avg',0); $values['top_n_value'] = get_parameter('quantity'); $values['text'] = get_parameter('text'); + $values['show_graph'] = get_parameter('combo_graph_options'); $good_format = true; } @@ -1139,7 +1179,6 @@ switch ($action) { $values['order_uptodown'] = get_parameter ('radiobutton_order_uptodown',0); $values['exception_condition'] = (int)get_parameter('radiobutton_exception_condition', 0); $values['exception_condition_value'] = get_parameter('exception_condition_value'); - $values['show_graph'] = get_parameter('combo_graph_options'); $values['id_module_group'] = get_parameter('combo_modulegroup'); $values['id_group'] = get_parameter ('combo_group'); $values['server_name'] = get_parameter ('server_name'); @@ -1577,7 +1616,7 @@ switch ($action) { switch ($activeTab) { case 'main': $buttons['list_reports']['active'] = true; - $subsection = ' » '.__('Custom reporting'); + $subsection = ' » ' . __('Custom reporting'); break; default: $subsection = reporting_enterprise_add_subsection_main($activeTab, $buttons); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index a867dff6f6..9b52588a0b 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -2031,7 +2031,7 @@ function modules_relation_exists ($id_module, $id_module_other = false) { */ function modules_add_relation ($id_module_a, $id_module_b) { $result = false; - + if (!modules_relation_exists($id_module_a, $id_module_b) && $id_module_a > 0 && $id_module_b > 0) { $values = array( 'module_a' => $id_module_a, @@ -2039,7 +2039,7 @@ function modules_add_relation ($id_module_a, $id_module_b) { ); $result = db_process_sql_insert('tmodule_relationship', $values); } - + return $result; } @@ -2052,7 +2052,7 @@ function modules_add_relation ($id_module_a, $id_module_b) { */ function modules_delete_relation ($id_relation) { $result = db_process_sql_delete('tmodule_relationship', array('id' => $id_relation)); - + return $result; } @@ -2067,11 +2067,125 @@ function modules_change_relation_lock ($id_relation) { $old_value = (int) db_get_value('disable_update', 'tmodule_relationship', 'id', $id_relation); $new_value = $old_value === 1 ? 0 : 1; - $result = db_process_sql_update('tmodule_relationship', - array('disable_update' => $new_value), - array('id' => $id_relation)); - + $result = db_process_sql_update( + 'tmodule_relationship', + array('disable_update' => $new_value), + array('id' => $id_relation)); + return ($result !== false ? $new_value : $old_value); } + + +function modules_get_count_datas($id_agent_module, $date_init, $date_end) { + $interval = modules_get_interval ($id_agent_module); + + // TODO REMOVE THE TIME IN PLANNED DOWNTIME + + if (!is_numeric($date_init)) { + $date_init = strtotime($date_init); + } + + if (!is_numeric($date_end)) { + $date_end = strtotime($date_end); + } + + $first_date = modules_get_first_contact_date($id_agent_module); + + if ($date_init < $first_date) { + $date_init = $first_date; + } + + $diff = $date_end - $date_init; + + return ($diff / $interval); +} + +function modules_get_data_with_value($id_agent_module, $date_init, + $date_end, $value, $split_interval = false) { + + global $config; + + // TODO REMOVE THE TIME IN PLANNED DOWNTIME + + // TODO FOR OTHER KIND OF DATA + + if (!is_numeric($date_init)) { + $date_init = strtotime($date_init); + } + + if (!is_numeric($date_end)) { + $date_end = strtotime($date_end); + } + + $sql = " + SELECT * + FROM tagente_datos + WHERE + datos = " . (int)$value . " + AND id_agente_modulo = " . (int)$id_agent_module . " + AND (utimestamp >= " . $date_init . " AND utimestamp <= " . $date_end . ")"; + + $data = db_get_all_rows_sql($sql, + $config['history_db_enabled']); + + if (empty($data)) { + $data = array(); + } + + if ($split_interval) { + $temp = array(); + $previous_utimestamp = false; + foreach ($data as $row) { + if ($previous_utimestamp === false) { + $previous_utimestamp = $row['utimestamp']; + + $temp[] = $row; + } + else { + $diff = $row['utimestamp'] - $previous_utimestamp; + + $interval = modules_get_interval($id_agent_module); + + if ($diff > $interval) { + $fake_count = (int)($diff / $interval); + + $fake = $row; + for ($iterator = 1; $iterator <= $fake_count; $iterator++) { + $fake['utimestamp'] = $previous_utimestamp + ($iterator * $interval); + $temp[] = $fake; + } + } + else { + $temp[] = $row; + } + + $previous_utimestamp = $row['utimestamp']; + + $data = $temp; + } + } + } + + return $data; +} + +function modules_get_first_contact_date($id_agent_module) { + global $config; + + // TODO REMOVE THE TIME IN PLANNED DOWNTIME + + // TODO FOR OTHER KIND OF DATA + + $sql = " + SELECT utimestamp + FROM tagente_datos + WHERE id_agente_modulo = " . (int)($id_agent_module) . " + ORDER BY utimestamp ASC + LIMIT 1"; + + $first_date = db_get_sql($sql, 0, $config['history_db_enabled']); + + return $first_date; +} ?> diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index db326bada3..f0047e953d 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -155,6 +155,12 @@ function reporting_make_reporting_data($id_report, $date, $time, $report, $content); break; + case 'availability': + $report['contents'][] = + reporting_availability( + $report, + $content); + break; case 'sql': $report['contents'][] = reporting_sql( $report, @@ -608,6 +614,232 @@ function reporting_sql($report, $content) { return reporting_check_structure_content($return); } +function reporting_availability($report, $content) { + + global $config; + + $return = array(); + $return['type'] = 'availability'; + $return['subtype'] = $content['group_by_agent']; + $return['resume'] = $content['show_resume']; + + if (empty($content['name'])) { + $content['name'] = __('Availability'); + } + + $return['title'] = $content['name']; + $return["description"] = $content["description"]; + $return["date"] = reporting_get_date_text( + $report, + $content); + + if ($content['show_graph']) { + $return['kind_availability'] = "address"; + } + else { + $return['kind_availability'] = "module"; + } + + + $sql = sprintf(" + SELECT id_agent_module, + server_name, operation + FROM treport_content_item + WHERE id_report_content = %d", + $content['id_rc']); + + $items = db_process_sql ($sql); + + + $data = array(); + + $avg = 0; + $min = null; + $min_text = ""; + $max = null; + $max_text = ""; + $count = 0; + foreach ($items as $item) { + //aaMetaconsole connection + $server_name = $item ['server_name']; + if (($config ['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) != NOERR) { + //ui_print_error_message ("Error connecting to ".$server_name); + continue; + } + } + + if (modules_is_disable_agent($item['id_agent_module'])) { + continue; + } + + $row = array(); + + $text = ""; + + // HACK it is saved in show_graph field. + // Show interfaces instead the modules + if ($content['show_graph']) { + $text = $row['availability_item'] = agents_get_address( + modules_get_agentmodule_agent($item['id_agent_module'])); + + if (empty($text)) { + $text = $row['availability_item'] = __('No Address'); + } + } + else { + $text = $row['availability_item'] = modules_get_agentmodule_name( + $item['id_agent_module']); + } + $row['agent'] = modules_get_agentmodule_agent_name( + $item['id_agent_module']); + + $text = $row['agent'] . " (" . $text . ")"; + + $count_checks = modules_get_count_datas( + $item['id_agent_module'], + $report["datetime"] - $content['period'], + $report["datetime"]); + + + if (empty($count_checks)) { + $row['checks'] = __('Unknown'); + $row['failed'] = __('Unknown'); + $row['fail'] = __('Unknown'); + $row['poling_time'] = __('Unknown'); + $row['time_unavaliable'] = __('Unknown'); + $row['ok'] = __('Unknown'); + + $percent_ok = 0; + } + else { + $count_fails = count( + modules_get_data_with_value( + $item['id_agent_module'], + $report["datetime"] - $content['period'], + $report["datetime"], + 0, true)); + $percent_ok = (($count_checks - $count_fails) * 100) / $count_checks; + $percent_fail = 100 - $percent_ok; + + $row['ok'] = format_numeric($percent_ok, 2) . " %"; + $row['fail'] = format_numeric($percent_fail, 2) . " %"; + $row['checks'] = format_numeric($count_checks, 2); + $row['failed'] = format_numeric($count_fails ,2); + $row['poling_time'] = human_time_description_raw( + ($count_checks - $count_fails) * modules_get_interval($item['id_agent_module']), + true); + $row['time_unavaliable'] = "-"; + if ($count_fails > 0) { + $row['time_unavaliable'] = human_time_description_raw( + $count_fails * modules_get_interval($item['id_agent_module']), + true); + } + } + + $data[] = $row; + + + $avg = (($avg * $count) + $percent_ok) / ($count + 1); + if (is_null($min)) { + $min = $percent_ok; + $min_text = $text; + } + else { + if ($min > $percent_ok) { + $min = $percent_ok; + $min_text = $text; + } + } + if (is_null($max)) { + $max = $percent_ok; + $max_text = $text; + } + else { + if ($max < $percent_ok) { + $max = $percent_ok; + $max_text = $text; + } + } + + //Restore dbconnection + if (($config ['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + metaconsole_restore_db(); + } + + $count++; + } + + + switch ($content['order_uptodown']) { + case REPORT_ITEM_ORDER_BY_AGENT_NAME: + $temp = array(); + foreach ($data as $row) { + $i = 0; + foreach ($temp as $t_row) { + if (strcmp($row['agent'], $t_row['agent']) < 0) { + break; + } + + $i++; + } + + array_splice($temp, $i, 0, array($row)); + } + + $data = $temp; + break; + case REPORT_ITEM_ORDER_BY_ASCENDING: + $temp = array(); + foreach ($data as $row) { + $i = 0; + foreach ($temp as $t_row) { + if (strcmp($row['availability_item'], $t_row['availability_item']) < 0) { + break; + } + + $i++; + } + + array_splice($temp, $i, 0, array($row)); + } + + $data = $temp; + break; + case REPORT_ITEM_ORDER_BY_DESCENDING: + $temp = array(); + foreach ($data as $row) { + $i = 0; + foreach ($temp as $t_row) { + + if (strcmp($row['availability_item'], $t_row['availability_item']) > 0) { + break; + } + + $i++; + } + + array_splice($temp, $i, 0, array($row)); + } + + $data = $temp; + break; + } + + + $return["data"] = $data; + $return["resume"] = array(); + $return["resume"]['min_text'] = $min_text; + $return["resume"]['min'] = $min; + $return["resume"]['avg'] = $avg; + $return["resume"]['max_text'] = $max_text; + $return["resume"]['max'] = $max; + + + return reporting_check_structure_content($return); +} + function reporting_general($report, $content) { global $config; @@ -992,6 +1224,12 @@ function reporting_simple_graph($report, $content, $type = 'dinamic', } else { + // HACK it is saved in show_graph field. + $time_compare_overlapped = false; + if ($content['show_graph']) { + $time_compare_overlapped = 'overlapped'; + } + $return['chart'] = grafico_modulo_sparse( $content['id_agent_module'], $content['period'], @@ -1013,7 +1251,7 @@ function reporting_simple_graph($report, $content, $type = 'dinamic', 1, false, '', - false, + $time_compare_overlapped, true); } break; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 207d7499a6..c45d7b99f4 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -125,6 +125,9 @@ function reporting_html_print_report($report, $mini = false) { } switch ($item['type']) { + case 'availability': + reporting_html_availability($table, $item); + break; case 'general': reporting_html_general($table, $item); break; @@ -343,6 +346,93 @@ function reporting_html_text(&$table, $item) { $table->data['data']['cell'] = $item['data']; } +function reporting_html_availability(&$table, $item) { + + if (!empty($item["data"])) { + $table1->width = '99%'; + $table1->data = array (); + $table1->head = array (); + $table1->head[0] = __('Agent'); + // HACK it is saved in show_graph field. + // Show interfaces instead the modules + if ($item['kind_availability'] == 'address') { + $table1->head[1] = __('IP Address'); + } + else { + $table1->head[1] = __('Module'); + } + $table1->head[2] = __('# Checks'); + $table1->head[3] = __('# Failed'); + $table1->head[4] = __('% Fail'); + $table1->head[5] = __('Poling time'); + $table1->head[6] = __('Time unavailable'); + $table1->head[7] = __('% Ok'); + + $table1->style[0] = 'text-align: left'; + $table1->style[1] = 'text-align: left'; + $table1->style[2] = 'text-align: right'; + $table1->style[3] = 'text-align: right'; + $table1->style[4] = 'text-align: right'; + $table1->style[5] = 'text-align: right'; + $table1->style[6] = 'text-align: right'; + $table1->style[7] = 'text-align: right'; + + foreach ($item['data'] as $row) { + $table_row = array(); + $table_row[] = $row['agent']; + $table_row[] = $row['availability_item']; + $table_row[] = $row['checks']; + $table_row[] = $row['failed']; + $table_row[] = $row['fail']; + $table_row[] = $row['poling_time']; + $table_row[] = $row['time_unavaliable']; + $table_row[] = $row['ok']; + + $table1->data[] = $table_row; + } + } + else { + $table->colspan['error']['cell'] = 3; + $table->data['error']['cell'] = + __('There are no Agent/Modules defined'); + } + + $table->colspan[1][0] = 3; + $data = array(); + $data[0] = html_print_table($table1, true); + array_push ($table->data, $data); + + if ($item['resume'] && !empty($item["data"])) { + $table1->width = '99%'; + $table1->data = array (); + $table1->head = array (); + $table1->style = array(); + $table1->head['min_text'] = ''; + $table1->head['min'] = __('Min Value'); + $table1->head['avg'] = __('Average Value'); + $table1->head['max_text'] = ''; + $table1->head['max'] = __('Max Value'); + $table1->style['min_text'] = 'text-align: left'; + $table1->style['min'] = 'text-align: right'; + $table1->style['avg'] = 'text-align: right'; + $table1->style['max_text'] = 'text-align: left'; + $table1->style['max'] = 'text-align: right'; + + $table1->data[] = array( + 'min_text' => $item['resume']['min_text'], + 'min' => format_numeric($item['resume']['min'], 2) . "%", + 'avg' => format_numeric($item['resume']['avg'], 2) . "%", + 'max_text' => $item['resume']['max_text'], + 'max' => format_numeric($item['resume']['max'], 2) . "%" + ); + + $table->colspan[2][0] = 3; + $data = array(); + $data[0] = html_print_table($table1, true); + array_push ($table->data, $data); + } +} + function reporting_html_general(&$table, $item) { if (!empty($item["data"])) { diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 083d60f195..4b366b92e7 100644 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -578,7 +578,8 @@ function reports_get_report_types ($template = false, $not_editor = false) { 'name' => __('Top n')); $types['network_interfaces_report'] = array('optgroup' => __('Grouped'), 'name' => __('Network interfaces')); - + $types['availability'] = array('optgroup' => __('Grouped'), + 'name' => __('Availability')); $types['text'] = array('optgroup' => __('Text/HTML '), diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index 4d333eb3f3..448300a64b 100644 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -231,7 +231,7 @@ else { } -echo '<form method="post" action="'.$url.'&pure='.$config["pure"].'" style="margin-right: 0px;">'; +echo '<form method="post" action="' . $url . '&pure=' . $config["pure"] . '" style="margin-right: 0px;">'; html_print_table ($table); html_print_input_hidden ('id_report', $id_report); echo '</form>';