' . (int) $datelimit . ' AND utimestamp < ' . (int) $date . ' ORDER BY utimestamp ASC', true); if ($interval_data === false) $interval_data = array (); // Uncompressed module data if ($uncompressed_module) { $min_necessary = 1; // Compressed module data } else { // Get previous data $previous_data = modules_get_previous_data ($id_agent_module, $datelimit); if ($previous_data !== false) { $previous_data['utimestamp'] = $datelimit; array_unshift ($interval_data, $previous_data); } // Get next data $next_data = modules_get_next_data ($id_agent_module, $date); if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); } $min_necessary = 2; } if (count ($interval_data) < $min_necessary) { return false; } // Set initial conditions $total = 0; $count = 0; if (! $uncompressed_module) { $previous_data = array_shift ($interval_data); // Do not count the empty start of an interval as 0 if ($previous_data['utimestamp'] != $datelimit) { $period = $date - $previous_data['utimestamp']; } } foreach ($interval_data as $data) { if (! $uncompressed_module) { $total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']); $previous_data = $data; } else { $total += $data['datos']; $count++; } } // Compressed module data if (! $uncompressed_module) { if ($period == 0) { return 0; } return $total / $period; } // Uncompressed module data if ($count == 0) { return 0; } return $total / $count; } /** * Get the maximum value of an agent module in a period of time. * * @param int Agent module id to get the maximum value. * @param int Period of time to check (in seconds) * @param int Top date to check the values. Default current time. * * @return float The maximum module value in the interval. */ function reporting_get_agentmodule_data_max ($id_agent_module, $period, $date = 0) { global $config; // Initialize variables if (empty ($date)) $date = get_system_time (); if ((empty ($period)) OR ($period == 0)) $period = $config["sla_period"]; $datelimit = $date - $period; $id_module_type = modules_get_agentmodule_type ($id_agent_module); $module_type = modules_get_moduletype_name ($id_module_type); $uncompressed_module = is_module_uncompressed ($module_type); // Get module data $interval_data = db_get_all_rows_sql ('SELECT * FROM tagente_datos WHERE id_agente_modulo = ' . (int) $id_agent_module . ' AND utimestamp > ' . (int) $datelimit . ' AND utimestamp < ' . (int) $date . ' ORDER BY utimestamp ASC', true); if ($interval_data === false) $interval_data = array (); // Uncompressed module data if ($uncompressed_module) { // Compressed module data } else { // Get previous data $previous_data = modules_get_previous_data ($id_agent_module, $datelimit); if ($previous_data !== false) { $previous_data['utimestamp'] = $datelimit; array_unshift ($interval_data, $previous_data); } // Get next data $next_data = modules_get_next_data ($id_agent_module, $date); if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); } } // Set initial conditions if (empty($iterval_data)) { $max = 0; } else { if ($uncompressed_module || $interval_data[0]['utimestamp'] == $datelimit) { $max = $interval_data[0]['datos']; } else { $max = 0; } } foreach ($interval_data as $data) { if ($data['datos'] > $max) { $max = $data['datos']; } } return $max; } /** * Get the minimum value of an agent module in a period of time. * * @param int Agent module id to get the minimum value. * @param int Period of time to check (in seconds) * @param int Top date to check the values in Unix time. Default current time. * * @return float The minimum module value of the module */ function reporting_get_agentmodule_data_min ($id_agent_module, $period, $date = 0) { global $config; // Initialize variables if (empty ($date)) $date = get_system_time (); if ((empty ($period)) OR ($period == 0)) $period = $config["sla_period"]; $datelimit = $date - $period; $id_module_type = modules_get_agentmodule_type ($id_agent_module); $module_type = modules_get_moduletype_name ($id_module_type); $uncompressed_module = is_module_uncompressed ($module_type); // Get module data $interval_data = db_get_all_rows_sql ('SELECT * FROM tagente_datos WHERE id_agente_modulo = ' . (int) $id_agent_module . ' AND utimestamp > ' . (int) $datelimit . ' AND utimestamp < ' . (int) $date . ' ORDER BY utimestamp ASC', true); if ($interval_data === false) $interval_data = array (); // Uncompressed module data if ($uncompressed_module) { $min_necessary = 1; // Compressed module data } else { // Get previous data $previous_data = modules_get_previous_data ($id_agent_module, $datelimit); if ($previous_data !== false) { $previous_data['utimestamp'] = $datelimit; array_unshift ($interval_data, $previous_data); } // Get next data $next_data = modules_get_next_data ($id_agent_module, $date); if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); } } if (count ($interval_data) < 1) { return false; } // Set initial conditions $min = $interval_data[0]['datos']; foreach ($interval_data as $data) { if ($data['datos'] < $min) { $min = $data['datos']; } } return $min; } /** * Get the sum of values of an agent module in a period of time. * * @param int Agent module id to get the sumatory. * @param int Period of time to check (in seconds) * @param int Top date to check the values. Default current time. * * @return float The sumatory of the module values in the interval. */ function reporting_get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) { global $config; // Initialize variables if (empty ($date)) $date = get_system_time (); if ((empty ($period)) OR ($period == 0)) $period = $config["sla_period"]; $datelimit = $date - $period; $id_module_type = db_get_value ('id_tipo_modulo', 'tagente_modulo','id_agente_modulo', $id_agent_module); $module_name = db_get_value ('nombre', 'ttipo_modulo', 'id_tipo', $id_module_type); $module_interval = modules_get_interval ($id_agent_module); $uncompressed_module = is_module_uncompressed ($module_name); // Wrong module type if (is_module_data_string ($module_name)) { return 0; } // Incremental modules are treated differently $module_inc = is_module_inc ($module_name); // Get module data $interval_data = db_get_all_rows_sql ('SELECT * FROM tagente_datos WHERE id_agente_modulo = ' . (int) $id_agent_module . ' AND utimestamp > ' . (int) $datelimit . ' AND utimestamp < ' . (int) $date . ' ORDER BY utimestamp ASC', true); if ($interval_data === false) $interval_data = array (); // Uncompressed module data if ($uncompressed_module) { $min_necessary = 1; // Compressed module data } else { // Get previous data $previous_data = modules_get_previous_data ($id_agent_module, $datelimit); if ($previous_data !== false) { $previous_data['utimestamp'] = $datelimit; array_unshift ($interval_data, $previous_data); } // Get next data $next_data = modules_get_next_data ($id_agent_module, $date); if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); } $min_necessary = 2; } if (count ($interval_data) < $min_necessary) { return false; } // Set initial conditions $total = 0; if (! $uncompressed_module) { $previous_data = array_shift ($interval_data); } foreach ($interval_data as $data) { if ($uncompressed_module) { $total += $data['datos']; } else if ($module_inc) { $total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']); } else { $total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']) / $module_interval; } $previous_data = $data; } return $total; } /** * Get SLA of a module. * * @param int Agent module to calculate SLA * @param int Period to check the SLA compliance. * @param int Minimum data value the module in the right interval * @param int Maximum data value the module in the right interval. False will * ignore max value * @param int Beginning date of the report in UNIX time (current date by default). * @param array $dayWeek Array of days week to extract as array('monday' => false, 'tuesday' => true....), and by default is null. * @param string $timeFrom Time in the day to start to extract in mysql format, by default null. * @param string $timeTo Time in the day to end to extract in mysql format, by default null. * * @return float SLA percentage of the requested module. False if no data were * found */ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0, $min_value = 1, $max_value = false, $date = 0, $daysWeek = null, $timeFrom = null, $timeTo = null) { global $config; // Initialize variables if (empty ($date)) { $date = get_system_time (); } if ((empty ($period)) OR ($period == 0)) { $period = $config["sla_period"]; } if ($daysWeek === null) { $daysWeek = array(); } // Limit date to start searching data $datelimit = $date - $period; // Get interval data $sql = sprintf ('SELECT * FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d AND utimestamp <= %d', $id_agent_module, $datelimit, $date); //Add the working times (mon - tue - wed ...) and from time to time $days = array(); //Translate to mysql week days if ($daysWeek) { foreach ($daysWeek as $key => $value) { if (!$value) { if ($key == 'monday') { $days[] = 2; } if ($key == 'tuesday') { $days[] = 3; } if ($key == 'wednesday') { $days[] = 4; } if ($key == 'thursday') { $days[] = 5; } if ($key == 'friday') { $days[] = 6; } if ($key == 'saturday') { $days[] = 7; } if ($key == 'sunday') { $days[] = 1; } } } } if (count($days) > 0) { $sql .= ' AND DAYOFWEEK(FROM_UNIXTIME(utimestamp)) NOT IN (' . implode(',', $days) . ')'; } if ($timeFrom < $timeTo) { $sql .= ' AND (TIME(FROM_UNIXTIME(utimestamp)) >= "' . $timeFrom . '" AND TIME(FROM_UNIXTIME(utimestamp)) <= "'. $timeTo . '")'; } elseif ($timeFrom > $timeTo) { $sql .= ' AND (TIME(FROM_UNIXTIME(utimestamp)) >= "' . $timeFrom . '" OR TIME(FROM_UNIXTIME(utimestamp)) <= "'. $timeTo . '")'; } $sql .= ' ORDER BY utimestamp ASC'; $interval_data = db_get_all_rows_sql ($sql, true); if ($interval_data === false) { $interval_data = array (); } //calculate planned downtime dates $id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $id_agent_module); $sql_downtime = "SELECT id_downtime FROM tplanned_downtime_agents WHERE id_agent=$id_agent"; $downtimes = db_get_all_rows_sql($sql_downtime); if ($downtimes == false) { $downtimes = array(); } $i = 0; $downtime_dates = array(); foreach ($downtimes as $downtime) { $id_downtime = $downtime['id_downtime']; $sql_date = "SELECT date_from, date_to FROM tplanned_downtime WHERE id=$id_downtime"; $date_downtime = db_get_row_sql($sql_date); if ($date_downtime != false) { $downtime_dates[$i]['date_from'] = $date_downtime['date_from']; $downtime_dates[$i]['date_to'] = $date_downtime['date_to']; $i++; } } ///// // Get previous data $previous_data = modules_get_previous_data ($id_agent_module, $datelimit); if ($previous_data !== false) { $previous_data['utimestamp'] = $datelimit; array_unshift ($interval_data, $previous_data); } // Get next data $next_data = modules_get_next_data ($id_agent_module, $date); if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); } if (count ($interval_data) < 2) { return false; } // Set initial conditions $bad_period = 0; $first_data = array_shift ($interval_data); // Do not count the empty start of an interval as 0 if ($first_data['utimestamp'] != $datelimit) { $period = $date - $first_data['utimestamp']; } $previous_utimestamp = $first_data['utimestamp']; if ((($max_value > $min_value AND ($first_data['datos'] > $max_value OR $first_data['datos'] < $min_value))) OR ($max_value <= $min_value AND $first_data['datos'] < $min_value)) { $previous_status = 1; foreach ($downtime_dates as $date_dt) { if (($date_dt['date_from'] <= $previous_utimestamp) AND ($date_dt['date_to'] >= $previous_utimestamp)) { $previous_status = 0; } } } else { $previous_status = 0; } foreach ($interval_data as $data) { // Previous status was critical if ($previous_status == 1) { $bad_period += $data['utimestamp'] - $previous_utimestamp; } if (array_key_exists('datos', $data)) { // Re-calculate previous status for the next data if ((($max_value > $min_value AND ($data['datos'] > $max_value OR $data['datos'] < $min_value))) OR ($max_value <= $min_value AND $data['datos'] < $min_value)) { $previous_status = 1; foreach ($downtime_dates as $date_dt) { if (($date_dt['date_from'] <= $data['utimestamp']) AND ($date_dt['date_to'] >= $data['utimestamp'])) { $previous_status = 0; } } } else { $previous_status = 0; } } $previous_utimestamp = $data['utimestamp']; } // Return the percentage of SLA compliance return (float) (100 - ($bad_period / $period) * 100); } /** * Get several SLA data for an agentmodule within a period divided on subperiods * * @param int Agent module to calculate SLA * @param int Period to check the SLA compliance. * @param int Minimum data value the module in the right interval * @param int Maximum data value the module in the right interval. False will * ignore max value * @param array $days Array of days week to extract as array('monday' => false, 'tuesday' => true....), and by default is null. * @param string $timeFrom Time in the day to start to extract in mysql format, by default null. * @param string $timeTo Time in the day to end to extract in mysql format, by default null. * * @return Array with values either 1, 2, 3 or 4 depending if the SLA percentage for this subperiod * is within the sla limits, on the edge, outside or with an unknown value. */ function reporting_get_agentmodule_sla_array ($id_agent_module, $period = 0, $min_value = 1, $max_value = false, $date = 0, $daysWeek = null, $timeFrom = null, $timeTo = null) { global $config; // Initialize variables if (empty ($date)) { $date = get_system_time (); } if ((empty ($period)) OR ($period == 0)) { $period = $config["sla_period"]; } if ($daysWeek === null) { $daysWeek = array(); } // Limit date to start searching data $datelimit = $date - $period; // Get interval data $sql = sprintf ('SELECT * FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d AND utimestamp <= %d', $id_agent_module, $datelimit, $date); //Add the working times (mon - tue - wed ...) and from time to time $days = array(); //Translate to mysql week days if ($daysWeek) { foreach ($daysWeek as $key => $value) { if (!$value) { if ($key == 'monday') { $days[] = 2; } if ($key == 'tuesday') { $days[] = 3; } if ($key == 'wednesday') { $days[] = 4; } if ($key == 'thursday') { $days[] = 5; } if ($key == 'friday') { $days[] = 6; } if ($key == 'saturday') { $days[] = 7; } if ($key == 'sunday') { $days[] = 1; } } } } if (count($days) > 0) { $sql .= ' AND DAYOFWEEK(FROM_UNIXTIME(utimestamp)) NOT IN (' . implode(',', $days) . ')'; } if ($timeFrom != $timeTo) { if ($timeFrom < $timeTo) { $sql .= ' AND (TIME(FROM_UNIXTIME(utimestamp)) >= "' . $timeFrom . '" AND TIME(FROM_UNIXTIME(utimestamp)) <= "'. $timeTo . '")'; } elseif ($timeFrom > $timeTo) { $sql .= ' AND (TIME(FROM_UNIXTIME(utimestamp)) >= "' . $timeFrom . '" OR TIME(FROM_UNIXTIME(utimestamp)) <= "'. $timeTo . '")'; } } $sql .= ' ORDER BY utimestamp ASC'; $interval_data = db_get_all_rows_sql ($sql, true); if ($interval_data === false) { $interval_data = array (); } // Indexing data $interval_data_indexed = array(); foreach($interval_data as $idata) { $interval_data_indexed[$idata['utimestamp']]['data'] = $idata['datos']; } //-----------Calculate unknown status events------------------------ $events_unknown = db_get_all_rows_filter ('tevento', array ('id_agentmodule' => $id_agent_module, "utimestamp > $datelimit", "utimestamp < $date", "event_type" => 'going_unknown', 'order' => 'utimestamp ASC'), array ('id_evento', 'evento', 'timestamp', 'utimestamp', 'event_type')); if ($events_unknown === false) { $events_unknown = array (); } // Add unknown periods to data foreach($events_unknown as $eu) { $interval_data_indexed[$eu['utimestamp']]['data'] = 0; $interval_data_indexed[$eu['utimestamp']]['status'] = 4; } // Get the last event before inverval to know if graph start on unknown $prev_event = db_get_row_filter ('tevento', array ('id_agentmodule' => $id_agent_module, "utimestamp <= $datelimit", 'order' => 'utimestamp DESC')); if (isset($prev_event['event_type']) && $prev_event['event_type'] == 'going_unknown') { $start_unknown = true; } else { $start_unknown = false; } //------------------------------------------------------------------ //-----------------Set limits of the interval----------------------- // If the starting of the graph is unknown we set it if ($start_unknown) { $interval_data_indexed[$datelimit]['data'] = 0; $interval_data_indexed[$datelimit]['status'] = 4; } else { // Get previous data (This adds the first data if the begin of module data is after the begin time interval) $previous_data = modules_get_previous_data ($id_agent_module, $datelimit); if ($previous_data !== false ) { $interval_data_indexed[$datelimit]['data'] = $previous_data['datos']; } else { // If there are not data befor interval set unknown $interval_data_indexed[$datelimit]['data'] = 0; $interval_data_indexed[$datelimit]['status'] = 4; } } // Get next data (This adds data before the interval of the report) $next_data = modules_get_next_data ($id_agent_module, $date); if ($next_data !== false) { $interval_data_indexed[$date]['data'] = $previous_data['datos']; } else if (count ($interval_data_indexed) > 0) { // Propagate the last known data to the end of the interval (if there is no module data at the end point) ksort($interval_data_indexed); $last_data = end($interval_data_indexed); $interval_data_indexed[$date] = $last_data; } //------------------------------------------------------------------ //--------Calculate planned downtime dates-------------------------- $id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $id_agent_module); $sql_downtime = "SELECT id_downtime FROM tplanned_downtime_agents WHERE id_agent=$id_agent"; $downtimes = db_get_all_rows_sql($sql_downtime); if ($downtimes == false) { $downtimes = array(); } $i = 0; $downtime_dates = array(); foreach ($downtimes as $downtime) { $id_downtime = $downtime['id_downtime']; $sql_date = "SELECT date_from, date_to FROM tplanned_downtime WHERE id=$id_downtime"; $date_downtime = db_get_row_sql($sql_date); if ($date_downtime != false) { // Delete data of the planned downtime and put the last data on the upper limit $interval_data_indexed[$date_downtime['date_from']]['data'] = 0; $interval_data_indexed[$date_downtime['date_from']]['status'] = 5; $last_downtime_data = false; foreach ($interval_data_indexed as $idi_timestamp => $idi) { if ($idi_timestamp != $date_downtime['date_from'] && $idi_timestamp != $date_downtime['date_to'] && $idi_timestamp >= $date_downtime['date_from'] && $idi_timestamp <= $date_downtime['date_to']) { $last_downtime_data = $idi['data']; unset($interval_data_indexed[$idi_timestamp]); } } // Set the last data of the interval as limit if ($last_downtime_data !== false) { $interval_data_indexed[$date_downtime['date_to']]['data'] = $last_downtime_data; }// If there arent data into the downtime, set unknown else { $interval_data_indexed[$date_downtime['date_to']]['data'] = 0; $interval_data_indexed[$date_downtime['date_to']]['status'] = 4; } $i++; } } //------------------------------------------------------------------ // Sort the array ksort($interval_data_indexed); // We need more or equal two points if (count ($interval_data_indexed) < 2) { return false; } //Get the percentage for the limits $diff = $max_value - $min_value; // Get module type $id_module_type = db_get_value('id_tipo_modulo', 'tagente_modulo', 'id_agente_modulo', $id_agent_module); // If module is boolean don't create translation intervals (on the edge intervals) if ($id_module_type == 2 or $id_module_type == 6 or $id_module_type == 9 or $id_module_type == 18){ $percent = 0; } else { // Getting 10% of $diff --> $percent = ($diff/100)*10, so... $percent = $diff / 10; } //Set initial conditions $first_data = array_shift ($interval_data); $previous_utimestamp = $date - $period; $previous_value = $first_data ['datos']; $previous_status = 0; if (isset($first_data['status'])) { // 4 for the Unknown value and 5 for planned downtime $previous_status = $first_data['status']; } elseif ((($previous_value > ($min_value - $percent)) && ($previous_value < ($min_value + $percent))) || (($previous_value > ($max_value - $percent)) && ($previous_value < ($max_value + $percent)))) {//2 when value is within the edges $previous_status = 2; } elseif (($previous_value >= ($min_value + $percent)) && ($previous_value <= ($max_value - $percent))) { //1 when value is OK $previous_status = 1; } elseif (($previous_value <= ($min_value - $percent)) || ($previous_value >= ($max_value + $percent))) { //3 when value is Wrong $previous_status = 3; } $data_colors = array(); $i = 0; foreach ($interval_data_indexed as $utimestamp => $data) { $change = false; $value = $data['data']; //~ $value = $data['datos']; //$utimestamp = $data['utimestamp']; if (isset($data['status'])) { // 4 for the Unknown value amd 5 for planned downtime $status = $data['status']; } elseif ((($value > ($min_value - $percent)) && ($value < ($min_value + $percent))) || (($value > ($max_value - $percent)) && ($value < ($max_value + $percent)))) { //2 when value is within the edges $status = 2; } elseif (($value >= ($min_value + $percent)) && ($value <= ($max_value - $percent))) { //1 when value is OK $status = 1; } elseif (($value <= ($min_value - $percent)) || ($value >= ($max_value + $percent))) { //3 when value is Wrong $status = 3; } if ($status != $previous_status) { $change = true; $data_colors[$i]['data'] = $previous_status; $data_colors[$i]['utimestamp'] = $utimestamp - $previous_utimestamp; $i++; $previous_status = $status; $previous_utimestamp = $utimestamp; } } if ($change == false) { $data_colors[$i]['data'] = $previous_status; $data_colors[$i]['utimestamp'] = $date - $previous_utimestamp; } return $data_colors; } function reporting_get_stats_servers($tiny = true) { $server_performance = servers_get_performance(); // Alerts table $table_srv = html_get_predefined_table(); $table_srv->style[0] = $table_srv->style[2] = 'text-align: right; padding: 5px;'; $table_srv->style[1] = $table_srv->style[3] = 'text-align: left; padding: 5px;'; $tdata = array(); $tdata[0] = html_print_image('images/brick.png', true, array('title' => __('Total running modules'), 'width' => '20px')); $tdata[1] = '' . format_numeric($server_performance ["total_modules"]) . ''; $tdata[2] = '' . format_numeric($server_performance ["total_modules_rate"], 2) . ''; $tdata[3] = html_print_image('images/brick.png', true, array('title' => __('Ratio') . ': ' . __('Modules by second'), 'width' => '10px')) . '/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; $tdata = array(); $tdata[0] = '
'.$value.'
'; array_push ($table->data, $data); break; case 'simple_baseline_graph': reporting_header_content($mini, $content, $report, $table, __('Simple baseline graph'), ui_print_truncate_text($agent_name, 'agent_medium', false).''; $data[0] .= $monitor_value.' % ' . html_print_image("images/b_green.png", true, array("height" => "32", "width" => "32")) . '
'; if ($monitor_value !== __('Unknown')) { $monitor_value = format_numeric (100 - $monitor_value, 2) ; } $data[1] = ''; $data[1] .= $monitor_value.' % ' . html_print_image("images/b_red.png", true, array("height" => "32", "width" => "32")) . '
'; array_push ($table->data, $data); break; case 7: case 'avg_value': reporting_header_content($mini, $content, $report, $table, __('Avg. Value'), ui_print_truncate_text($agent_name, 'agent_medium', false) . ''.$value.'
'; array_push ($table->data, $data); break; case 8: case 'max_value': reporting_header_content($mini, $content, $report, $table, __('Max. Value'), ui_print_truncate_text($agent_name, 'agent_medium', false) . '' . format_for_graph($value, 2) . " " . $unit .'
'; array_push ($table->data, $data); break; case 9: case 'min_value': reporting_header_content($mini, $content, $report, $table, __('Min. Value'), ui_print_truncate_text($agent_name, 'agent_medium', false) . ''.$value.'
'; array_push ($table->data, $data); break; case 10: case 'sumatory': reporting_header_content($mini, $content, $report, $table, __('Summatory'), ui_print_truncate_text($agent_name, 'agent_medium', false) . ''.$value.'
'; array_push ($table->data, $data); break; case 'agent_detailed_event': case 'event_report_agent': reporting_header_content($mini, $content, $report, $table, __('Agent detailed event'), ui_print_truncate_text(agents_get_name($content['id_agent']), 'agent_medium', false)); $style = json_decode(io_safe_output($content['style']), true); $filter_event_no_validated = $style['filter_event_no_validated']; $filter_event_validated = $style['filter_event_validated']; $filter_event_critical = $style['filter_event_critical']; $filter_event_warning = $style['filter_event_warning']; $event_graph_by_agent = $style['event_graph_by_agent']; $event_graph_by_user_validator = $style['event_graph_by_user_validator']; $event_graph_by_criticity = $style['event_graph_by_criticity']; $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; // Put description at the end of the module (if exists) $table->colspan[1][0] = 3; if ($content["description"] != "") { $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); } $data = array (); $table->colspan[2][0] = 3; $data[0] = reporting_get_agents_detailed_event( $content['id_agent'], $content['period'], $report["datetime"], true, $filter_event_validated, $filter_event_critical, $filter_event_warning, $filter_event_no_validated); array_push ($table->data, $data); if ($event_graph_by_user_validator) { $data_graph = reporting_get_count_events_validated_by_user( array('id_agent' => $content['id_agent']), $content['period'], $report["datetime"], $filter_event_validated, $filter_event_critical, $filter_event_warning, $filter_event_no_validated); $table_event_graph = null; $table_event_graph->head[0] = __('Events validated by user'); $table_event_graph->data[0][0] = pie3d_graph( false, $data_graph, 500, 150, __("other"), "", $config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size']); $data[0] = html_print_table($table_event_graph, true); $table->colspan[2][0] = 3; array_push ($table->data, $data); } if ($event_graph_by_criticity) { $data_graph = reporting_get_count_events_by_criticity( array('id_agent' => $content['id_agent']), $content['period'], $report["datetime"], $filter_event_validated, $filter_event_critical, $filter_event_warning, $filter_event_no_validated); $table_event_graph = null; $table_event_graph->head[0] = __('Events by criticity'); $table_event_graph->data[0][0] = pie3d_graph( false, $data_graph, 500, 150, __("other"), "", $config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size']); $data[0] = html_print_table($table_event_graph, true); $table->colspan[2][0] = 3; array_push ($table->data, $data); } if ($event_graph_validated_vs_unvalidated) { $data_graph = reporting_get_count_events_validated( array('id_agent' => $content['id_agent']), $content['period'], $report["datetime"], $filter_event_validated, $filter_event_critical, $filter_event_warning, $filter_event_no_validated); $table_event_graph = null; $table_event_graph->head[0] = __('Amount events validated'); $table_event_graph->data[0][0] = pie3d_graph( false, $data_graph, 500, 150, __("other"), "", $config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size']); $data[0] = html_print_table($table_event_graph, true); $table->colspan[2][0] = 3; array_push ($table->data, $data); } break; case 'text': reporting_header_content($mini, $content, $report, $table, __('Text'), "", ""); if ($content["description"] != ""){ $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); } $data[0] = html_entity_decode($content['text']); array_push($table->data, $data); $table->colspan[2][0] = 2; break; case 'sql': reporting_header_content($mini, $content, $report, $table, __('SQL'), "", ""); // Put description at the end of the module (if exists) $table->colspan[0][0] = 2; if ($content["description"] != ""){ $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); } $table2->class = 'databox'; $table2->width = '100%'; //Create the head $table2->head = array(); if ($content['header_definition'] != '') { $table2->head = explode('|', $content['header_definition']); } if ($content['treport_custom_sql_id'] != 0) { switch ($config["dbtype"]) { case "mysql": $sql = io_safe_output (db_get_value_filter('`sql`', 'treport_custom_sql', array('id' => $content['treport_custom_sql_id']))); break; case "postgresql": $sql = io_safe_output (db_get_value_filter('"sql"', 'treport_custom_sql', array('id' => $content['treport_custom_sql_id']))); break; case "oracle": $sql = io_safe_output (db_get_value_filter('sql', 'treport_custom_sql', array('id' => $content['treport_custom_sql_id']))); break; } } else { $sql = io_safe_output ($content['external_source']); } // Do a security check on SQL coming from the user $sql = check_sql ($sql); if($sql != '') { $result = db_get_all_rows_sql($sql); if ($result === false) { $result = array(); } if (isset($result[0])) { if (count($result[0]) > count($table2->head)) { $table2->head = array_pad($table2->head, count($result[0]), ' '); } } $table2->data = array(); foreach ($result as $row) { array_push($table2->data, $row); } } else { $table2->data = array(); array_push($table2->data, array("id_user" => "'.$ttr.'
'; array_push ($table->data, $data); break; case 'TTO': reporting_header_content($mini, $content, $report, $table, __('TTO'), ui_print_truncate_text($agent_name, 'agent_medium', false) . ''.$tto.'
'; array_push ($table->data, $data); break; case 'MTBF': reporting_header_content($mini, $content, $report, $table, __('MTBF'), ui_print_truncate_text($agent_name, 'agent_medium', false) . ''.$mtbf.'
'; array_push ($table->data, $data); break; case 'MTTR': reporting_header_content($mini, $content, $report, $table, __('MTTR'), ui_print_truncate_text($agent_name, 'agent_medium', false) . ''.$mttr.'
'; array_push ($table->data, $data); break; case 'group_report': $group_name = groups_get_name($content['id_group'], true); $group_stats = reporting_get_group_stats($content['id_group']); // Get events of the last 8 hours $events = events_get_group_events ($content['id_group'], 28800, $report['datetime']); if($events === false) { $events = array(); } reporting_header_content($mini, $content, $report, $table, __('Group report').': "'.$group_name.'"'); $table->colspan[1][0] = 3; if ($content["description"] != "") { $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); } $table->colspan[2][0] = 3; $table->data[2][0] = html_print_table($table2, true) . "" .
__('Total') . " |
" .
__('Unknown') . " |
|||||
" .
__('Agents') . " |
" .
$group_stats['total_agents'] . " |
" .
$group_stats['agents_unknown'] . " |
||||
" .
__('Total') . " |
" .
__('Normal') . " |
" .
__('Critical') . " |
" .
__('Warning') . " |
" .
__('Unknown') . " |
" .
__('Not init') . " |
|
" .
__('Monitors') . " |
" .
$group_stats['monitor_checks'] . " |
" .
$group_stats['monitor_ok'] ." |
" .
$group_stats['monitor_critical'] . " |
" .
$group_stats['monitor_warning'] . " |
" .
$group_stats['monitor_unknown'] . " |
" .
$group_stats['monitor_not_init'] . " |
" .
__('Defined') . " |
" .
__('Fired') . " |
|||||
" .
__('Alerts') . " |
" .
$group_stats['monitor_alerts'] . " |
" .
$group_stats['monitor_alerts_fired'] . " |
||||
" .
__('Last 8 hours') . " |
||||||
" .
__('Events') . " |
" .
count($events)." |
".__("Agents")." / ".__("Modules")." | "; $nmodules = 0; foreach ($modules_by_name as $module) { $nmodules++; // Don't use pagination /*if($nmodules > $block) { //Will show only the (block) first modules continue; }*/ $file_name = string2image(ui_print_truncate_text($module['name'], 'module_small', false, true, false, '...'), false, false, 6, 270, '#90B165', 'FFF', 4, 0); $table_data .= '' . html_print_image($file_name, true, array('title' => $module['name']))." | "; } // Dont use pagination /*if ($block < $nmodules) { $table_data .= "... | "; }*/ $filter_agents = false; if ($id_group > 0) { $filter_agents = array('id_grupo' => $id_group); } // Prepare pagination ui_pagination ((int)count(agents_get_agents ($filter_agents))); $table_data .= "
---|---|---|
".html_print_image($file_name, true, array('title' => $agent['nombre']))." | "; $agent_modules = agents_get_modules($agent['id_agente']); $nmodules = 0; foreach ($modules_by_name as $module) { $nmodules++; // Don't use pagination /*if ($nmodules > $block) { continue; }*/ $match = false; foreach($module['id'] as $module_id){ if (!$match && array_key_exists($module_id,$agent_modules)) { $status = modules_get_agentmodule_status($module_id); $table_data .= ""; $win_handle = dechex(crc32($module_id.$module["name"])); $graph_type = return_graphtype (modules_get_agentmodule_type($module_id)); switch ($status) { case 0: $table_data .= ui_print_status_image ('module_ok.png', $module['name']." in ".$agent['nombre'].": ".__('NORMAL'), true, array('width' => '20px', 'height' => '20px')); break; case 1: $table_data .= ui_print_status_image ('module_critical.png', $module['name']." in ".$agent['nombre'].": ".__('CRITICAL'), true, array('width' => '20px', 'height' => '20px')); break; case 2: $table_data .= ui_print_status_image ('module_warning.png', $module['name']." in ".$agent['nombre'].": ".__('WARNING'), true, array('width' => '20px', 'height' => '20px')); break; case 3: $table_data .= ui_print_status_image ('module_unknown.png', $module['name']." in ".$agent['nombre'].": ".__('UNKNOWN'), true, array('width' => '20px', 'height' => '20px')); break; case 4: $table_data .= ui_print_status_image ('module_alertsfired.png', $module['name']." in ".$agent['nombre'].": ".__('ALERTS FIRED'), true, array('width' => '20px', 'height' => '20px')); break; } $table_data .= " | "; $match = true; } } if(!$match) { $table_data .= ""; } } $table_data .= " |
" . __("The colours meaning:") . "