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-26 12:37:14 +02:00
parent 3061a93fea
commit ca5b9bd62f
5 changed files with 81 additions and 4 deletions

View File

@ -492,6 +492,16 @@ $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

@ -453,7 +453,9 @@ function config_update_config () {
$error_update[] = __('Show the group name instead the group icon.');
if (!config_update_value ('custom_graph_widht', get_parameter('custom_graph_widht')))
$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.');
$interval_values = get_parameter ('interval_values');
// Add new interval value if is provided
@ -1201,7 +1203,10 @@ 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);
}

View File

@ -1683,6 +1683,8 @@ 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);
@ -1719,6 +1721,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

@ -598,7 +598,26 @@ foreach ($modules as $module) {
}
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"])){

View File

@ -1204,7 +1204,26 @@ 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"])) {