diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 625f4a4af5..b09cfe3a81 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2013-03-08 Miguel de Dios + + *include/constants.php, include/functions_reporting.php, + godmode/reporting/reporting_builder.item_editor.php, + godmode/reporting/reporting_builder.php: into the report element + "exception" added more conditions and rewrote the code. + + Fixes: #3607172 + 2013-03-08 Sergio Martin * include/ajax/events.php diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 71f534f67e..6590593670 100644 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -58,7 +58,7 @@ $order_uptodown = 0; $show_resume = 0; $top_n = 0; $top_n_value = 10; -$exception_condition = 0; +$exception_condition = REPORT_EXCEPTION_CONDITION_EVERYTHING; $exception_condition_value = 10; $modulegroup = 0; $period = 86400; @@ -931,7 +931,20 @@ html_print_input_hidden('id_item', $idItem); __('Everything'), + REPORT_EXCEPTION_CONDITION_GE => __('Greater or equal (>=)'), + REPORT_EXCEPTION_CONDITION_LE => __('Less or equal (<=)'), + REPORT_EXCEPTION_CONDITION_L => __('Less (<)'), + REPORT_EXCEPTION_CONDITION_G => __('Greater (>)'), + REPORT_EXCEPTION_CONDITION_E => __('Equal (=)'), + REPORT_EXCEPTION_CONDITION_NE => __('Not equal (!=)'), + REPORT_EXCEPTION_CONDITION_OK => __('OK'), + REPORT_EXCEPTION_CONDITION_NOT_OK => __('Not OK') + ); + html_print_select($list_exception_condition, 'exception_condition', $exception_condition); + + /*echo ; html_print_radio_button ('radiobutton_exception_condition', 0, '', $exception_condition); echo __('>='); html_print_radio_button ('radiobutton_exception_condition', 1, '', $exception_condition); @@ -941,7 +954,7 @@ html_print_input_hidden('id_item', $idItem); html_print_radio_button ('radiobutton_exception_condition', 3, '', $exception_condition); echo __('Not OK'); html_print_radio_button ('radiobutton_exception_condition', 4, '', $exception_condition); - ?> + */?> diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 23e04611fb..1700616861 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -703,7 +703,7 @@ switch ($action) { $values['group_by_agent'] = get_parameter ('checkbox_row_group_by_agent'); $values['show_resume'] = get_parameter ('checkbox_show_resume'); $values['order_uptodown'] = get_parameter ('radiobutton_order_uptodown'); - $values['exception_condition'] = get_parameter('radiobutton_exception_condition'); + $values['exception_condition'] = get_parameter('exception_condition'); $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'); diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 9644b1ada2..b346eb4dab 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -268,4 +268,14 @@ define ('REPORT_TOP_N_AVG', 0); define ('REPORT_TOP_N_ONLY_GRAPHS', 2); define ('REPORT_TOP_N_SHOW_TABLE_GRAPS', 1); define ('REPORT_TOP_N_ONLY_TABLE', 0); + +define ('REPORT_EXCEPTION_CONDITION_EVERYTHING', 0); +define ('REPORT_EXCEPTION_CONDITION_GE', 1); +define ('REPORT_EXCEPTION_CONDITION_LE', 5); +define ('REPORT_EXCEPTION_CONDITION_L', 2); +define ('REPORT_EXCEPTION_CONDITION_G', 6); +define ('REPORT_EXCEPTION_CONDITION_E', 7); +define ('REPORT_EXCEPTION_CONDITION_NE', 8); +define ('REPORT_EXCEPTION_CONDITION_OK', 3); +define ('REPORT_EXCEPTION_CONDITION_NOT_OK', 4); ?> diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index d8677842df..b0a9b6864c 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -5121,22 +5121,35 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $title_exeption = __('Exception'); switch ($exception_condition) { - case 0: + case REPORT_EXCEPTION_CONDITION_EVERYTHING: $title_exeption .= ' - '.__('Everything'); break; - case 1: + case REPORT_EXCEPTION_CONDITION_GE: $title_exeption .= ' - '.__('Modules over or equal to').' '.$exception_condition_value; break; - case 2: + case REPORT_EXCEPTION_CONDITION_LE: + $title_exeption .= ' - '.__('Modules under or equal to').' '.$exception_condition_value; + break; + case REPORT_EXCEPTION_CONDITION_L: $title_exeption .= ' - '.__('Modules under').' '.$exception_condition_value; break; - case 3: + case REPORT_EXCEPTION_CONDITION_G: + $title_exeption .= ' - '.__('Modules over').' '.$exception_condition_value; + break; + case REPORT_EXCEPTION_CONDITION_E: + $title_exeption .= ' - '.__('Equal to').' '.$exception_condition_value; + break; + case REPORT_EXCEPTION_CONDITION_NE: + $title_exeption .= ' - '.__('Not equal to').' '.$exception_condition_value; + break; + case REPORT_EXCEPTION_CONDITION_OK: $title_exeption .= ' - '.__('Modules at normal status'); break; - case 4: + case REPORT_EXCEPTION_CONDITION_NOT_OK: $title_exeption .= ' - '.__('Modules at critical or warning status'); break; } + reporting_header_content($mini, $content, $report, $table, $title_exeption); // Put description at the end of the module (if exists) @@ -5241,39 +5254,53 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f if ($value > $max) $max = $value; if ($value < $min) $min = $value; $avg += $value; + + //Skips switch ($exception_condition) { - //Display everything - case 0: + case REPORT_EXCEPTION_CONDITION_EVERYTHING: break; - //Display modules over or equal to certain value - case 1: - //Skip modules under 'value' + case REPORT_EXCEPTION_CONDITION_GE: if ($value < $exception_condition_value) { continue 2; } break; - //Display modules under a certain value - case 2: - //Skip modules over or equal to 'value' - if ($value >= $exception_condition_value) { + case REPORT_EXCEPTION_CONDITION_LE: + if ($value > $exception_condition_value) { continue 2; } break; - //Display modules at Normal status - case 3: - //Skip modules without normal status + case REPORT_EXCEPTION_CONDITION_L: + if ($value > $exception_condition_value) { + continue 2; + } + break; + case REPORT_EXCEPTION_CONDITION_G: + if ($value < $exception_condition_value) { + continue 2; + } + break; + case REPORT_EXCEPTION_CONDITION_E: + if ($value != $exception_condition_value) { + continue 2; + } + break; + case REPORT_EXCEPTION_CONDITION_NE: + if ($value == $exception_condition_value) { + continue 2; + } + break; + case REPORT_EXCEPTION_CONDITION_OK: if (modules_get_agentmodule_status($exc['id_agent_module']) != 0) { continue 2; } break; - //Display modules at critical, warning or unknown status - case 4: - //Skip modules at normal status + case REPORT_EXCEPTION_CONDITION_NOT_OK: if (modules_get_agentmodule_status($exc['id_agent_module']) == 0) { continue 2; } break; } + $i++; $data_exceptions[] = $value; $id_agent_module[] = $exc['id_agent_module']; @@ -5287,28 +5314,44 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f metaconsole_restore_db(); } } + //$i <= 0 means that there are no rows on the table, therefore no modules under the conditions defined. - if ($i<=0) { + if ($i <= 0) { $data = array (); $table->colspan[2][0] = 3; $data[0] = __('There are no'); + switch ($exception_condition) { - case 1: - $data[0] .= ' '.__('Modules over or equal to').' '.$exception_condition_value; - break; - case 2: - $data[0] .= ' '.__('Modules under').' '.$exception_condition_value; - break; - case 3: - $data[0] .= ' '.__('Modules at normal status'); - break; - case 4: - $data[0] .= ' '.__('Modules at critial or warning status'); - break; - default: + case REPORT_EXCEPTION_CONDITION_EVERYTHING: $data[0] .= ' '.__('Modules under those conditions'); break; + case REPORT_EXCEPTION_CONDITION_GE: + $data[0] .= ' '.__('Modules over or equal to').' '.$exception_condition_value; + break; + case REPORT_EXCEPTION_CONDITION_LE: + $data[0] .= ' '.__('Modules less or equal to').' '.$exception_condition_value; + break; + case REPORT_EXCEPTION_CONDITION_L: + $data[0] .= ' '.__('Modules less').' '.$exception_condition_value; + break; + case REPORT_EXCEPTION_CONDITION_G: + $data[0] .= ' '.__('Modules over').' '.$exception_condition_value; + break; + case REPORT_EXCEPTION_CONDITION_E: + $data[0] .= ' '.__('Modules equal to').' '.$exception_condition_value; + break; + case REPORT_EXCEPTION_CONDITION_NE: + $data[0] .= ' '.__('Modules not equal to').' '.$exception_condition_value; + break; + case REPORT_EXCEPTION_CONDITION_OK: + $data[0] .= ' '.__('Modules normal status'); + break; + case REPORT_EXCEPTION_CONDITION_NOT_OK: + $data[0] .= ' '.__('Modules at critial or warning status'); + break; } + + array_push ($table->data, $data); break; }