Add new option, when is active data of modules type is proc, show ok or fail. Tiquet: #1996

This commit is contained in:
m-lopez-f 2015-05-04 15:44:37 +02:00
parent a12114048b
commit 6241ae13d6
5 changed files with 81 additions and 3 deletions

View File

@ -495,6 +495,17 @@ $table->data[$row][1] = html_print_input_text ('custom_graph_widht',
$row++;
$table->data[$row][0] = __('Render data of module type is proc.');
$table->data[$row][1] = __('Yes') . ' ' .
html_print_radio_button ('render_proc', 1, '',
$config["render_proc"], true) .
'  ';
$table->data[$row][1] .= __('No') . ' ' .
html_print_radio_button ('render_proc', 0, '',
$config["render_proc"], true);
$row++;
echo '<form id="form_setup" method="post">';
html_print_input_hidden ('update_config', 1);

View File

@ -901,8 +901,26 @@ if ($list_modules) {
}
else {
if (is_numeric($module["datos"]) && !modules_is_string_type($module['id_tipo_modulo'])){
$salida = format_numeric($module["datos"]);
if ( $config["render_proc"] ){
switch($module["id_tipo_modulo"]) {
case 2:
case 6:
case 9:
case 18:
case 21:
case 31:
if ($module["datos"]>=1)
$salida ='OK';
else
$salida = 'FAIL';
break;
default:
$salida = format_numeric($module["datos"]);
break;
}
}else{
$salida = format_numeric($module["datos"]);
}
// Show units ONLY in numeric data types
if (isset($module["unit"])){
$salida .= "&nbsp;" . '<i>'. io_safe_output($module["unit"]) . '</i>';

View File

@ -461,6 +461,8 @@ function config_update_config () {
$error_update[] = __('Show the group name instead the group icon.');
if (!config_update_value ('custom_graph_widht', (int) get_parameter('custom_graph_widht', 1)))
$error_update[] = __('Default line thickness for the Custom Graph.');
if (!config_update_value ('render_proc', (int) get_parameter('render_proc', 0)))
$error_update[] = __('Render data of module type is proc.');
@ -1254,6 +1256,9 @@ function config_process_config () {
if (!isset($config['custom_graph_widht'])) {
config_update_value ('custom_graph_widht', 1);
}
if (!isset($config['render_proc'])) {
config_update_value ('render_proc', 0);
}
if (!isset($config['command_snapshot'])) {
config_update_value ('command_snapshot', 1);
@ -1364,6 +1369,7 @@ function config_check () {
if (enterprise_installed()) {
if (!is_readable ($remote_config)) {
set_pandora_error_for_header(
__('Remote configuration directory is not readble for the console') .

View File

@ -1583,6 +1583,7 @@ function modules_get_next_data ($id_agent_module, $utimestamp = 0, $string = 0)
*/
function modules_get_agentmodule_data ($id_agent_module, $period,
$date = 0, $trash=false, $conexion = false, $order = 'ASC') {
global $config;
$module = db_get_row('tagente_modulo', 'id_agente_modulo',
$id_agent_module);
@ -1619,6 +1620,28 @@ function modules_get_agentmodule_data ($id_agent_module, $period,
ORDER BY utimestamp %s",
$id_agent_module, $datelimit, $date, $order);
break;
case 2:
case 6:
case 9:
case 18:
case 21:
case 31:
if ( $config["render_proc"] ) {
$sql = sprintf ("SELECT IF(datos >= 1, 'OK', 'FAIL') as data, utimestamp
FROM tagente_datos
WHERE id_agente_modulo = %d
AND utimestamp > %d AND utimestamp <= %d
ORDER BY utimestamp %s",
$id_agent_module, $datelimit, $date, $order);
}else{
$sql = sprintf ("SELECT datos AS data, utimestamp
FROM tagente_datos
WHERE id_agente_modulo = %d
AND utimestamp > %d AND utimestamp <= %d
ORDER BY utimestamp %s",
$id_agent_module, $datelimit, $date, $order);
}
break;
default:
$sql = sprintf ("SELECT datos AS data, utimestamp
FROM tagente_datos

View File

@ -1239,7 +1239,27 @@ foreach ($result as $row) {
$row['min_critical'], $row['str_critical']);
if (is_numeric($row["datos"])) {
$salida = format_numeric($row["datos"]);
if ( $config["render_proc"] ){
switch($row["module_type"]) {
case 2:
case 6:
case 9:
case 18:
case 21:
case 31:
if ( $row["datos"] >= 1 )
$salida ='OK';
else
$salida = 'FAIL';
break;
default:
$salida = format_numeric($row["datos"]);
break;
}
}else{
$salida = format_numeric($row["datos"]);
}
// Show units ONLY in numeric data types
if (isset($row["unit"])) {