' . (int) $datelimit . ' AND utimestamp < ' . (int) $date . ' ORDER BY utimestamp ASC', $search_in_history_db); 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=0, $date = 0) { global $config; // Initialize variables if (empty ($date)) $date = get_system_time (); $datelimit = $date - $period; $search_in_history_db = db_search_in_history_db($datelimit); $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', $search_in_history_db); 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=0, $date = 0) { global $config; // Initialize variables if (empty ($date)) $date = get_system_time (); $datelimit = $date - $period; $search_in_history_db = db_search_in_history_db($datelimit); $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', $search_in_history_db); 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 = 0, $date = 0) { global $config; // Initialize variables if (empty ($date)) $date = get_system_time (); $datelimit = $date - $period; $search_in_history_db = db_search_in_history_db($datelimit); $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', $search_in_history_db); 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; if (empty($id_agent_module)) return false; // Initialize variables if (empty ($date)) { $date = get_system_time (); } if ($daysWeek === null) { $daysWeek = array(); } // Limit date to start searching data $datelimit = $date - $period; $search_in_history_db = db_search_in_history_db($datelimit); // 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, $search_in_history_db); if ($interval_data === false) { $interval_data = array (); } // Calculate planned downtime dates $downtime_dates = reporting_get_planned_downtimes_intervals($id_agent_module, $datelimit, $date); // 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; if (empty($id_agent_module)) return false; // Initialize variables if (empty ($date)) { $date = get_system_time (); } if ($daysWeek === null) { $daysWeek = array(); } // Hotfix: The edge values are confuse to the users $percent = 0; // Limit date to start searching data $datelimit = $date - $period; $search_in_history_db = db_search_in_history_db($datelimit); // 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, $search_in_history_db); 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", 'order' => 'utimestamp ASC'), array ('id_evento', 'evento', 'timestamp', 'utimestamp', 'event_type')); if ($events_unknown === false) { $events_unknown = array (); } // Add unknown periods to data for ($i = 0; isset($events_unknown[$i]); $i++) { $eu = $events_unknown[$i]; if ($eu['event_type'] == 'going_unknown') { $interval_data_indexed[$eu['utimestamp']]['data'] = 0; $interval_data_indexed[$eu['utimestamp']]['status'] = 4; // Search the corresponding recovery event. for ($j = $i+1; isset($events_unknown[$j]); $j++) { $eu = $events_unknown[$j]; if ($eu['event_type'] != 'going_unknown' && substr ($eu['event_type'], 0, 5) == 'going') { $interval_data_indexed[$eu['utimestamp']]['data'] = 0; $interval_data_indexed[$eu['utimestamp']]['status'] = 6; // Do not process read events again. $i = $j; break; } } } } // 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----------------------- // 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 ) { $previous_value = $previous_data['datos']; // if ((($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_known_status = 2; // } // else if (($previous_value >= ($min_value + $percent)) && ($previous_value <= ($max_value - $percent))) { //1 when value is OK $previous_known_status = 1; } elseif (($previous_value <= ($min_value - $percent)) || ($previous_value >= ($max_value + $percent))) { //3 when value is Wrong $previous_known_status = 3; } } // 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 { 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; $previous_known_status = 1; // Assume the module was in normal status if there is no previous data. } } // 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-------------------------- $downtime_dates = reporting_get_planned_downtimes_intervals($id_agent_module, $datelimit, $date); foreach ($downtime_dates as $downtime_date) { // Delete data of the planned downtime and put the last data on the upper limit $interval_data_indexed[$downtime_date['date_from']]['data'] = 0; $interval_data_indexed[$downtime_date['date_from']]['status'] = 5; $interval_data_indexed[$downtime_date['date_to']]['data'] = 0; $interval_data_indexed[$downtime_date['date_to']]['status'] = 4; $last_downtime_data = false; foreach ($interval_data_indexed as $idi_timestamp => $idi) { if ($idi_timestamp != $downtime_date['date_from'] && $idi_timestamp != $downtime_date['date_to'] && $idi_timestamp >= $downtime_date['date_from'] && $idi_timestamp <= $downtime_date['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[$downtime_date['date_to']]['data'] = $last_downtime_data; } } //------------------------------------------------------------------ // 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']; if (isset($data['status'])) { // Leaving unkown status. if ($data['status'] == 6) { $status = $previous_known_status; } // 4 unknown, 5 planned downtime. else { $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; } // Save the last known status. if ($status <= 3) { $previous_known_status = $status; } } if ($change == false) { $data_colors[$i]['data'] = $previous_status; $data_colors[$i]['utimestamp'] = $date - $previous_utimestamp; } return $data_colors; } /** * Get the time intervals where an agentmodule is affected by the planned downtimes. * * @param int Agent module to calculate planned downtimes intervals. * @param int Start date in utimestamp. * @param int End date in utimestamp. * @param bool Whether ot not to get the planned downtimes that affect the service associated with the agentmodule. * * @return Array with time intervals. */ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_date, $end_date, $check_services = false) { global $config; if (empty($id_agent_module)) return false; require_once ($config['homedir'] . '/include/functions_planned_downtimes.php'); $malformed_planned_downtimes = planned_downtimes_get_malformed(); if (empty($malformed_planned_downtimes)) $malformed_planned_downtimes = array(); $sql_downtime = "SELECT DISTINCT(tpdr.id), tpdr.* FROM ( SELECT tpd.* FROM tplanned_downtime tpd, tplanned_downtime_agents tpda, tagente_modulo tam WHERE tpd.id = tpda.id_downtime AND tpda.all_modules = 1 AND tpda.id_agent = tam.id_agente AND tam.id_agente_modulo = $id_agent_module UNION ALL SELECT tpd.* FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm WHERE tpd.id = tpdm.id_downtime AND tpdm.id_agent_module = $id_agent_module ) tpdr ORDER BY tpdr.id"; $downtimes = db_get_all_rows_sql($sql_downtime); if ($downtimes == false) { $downtimes = array(); } $downtime_dates = array(); foreach ($downtimes as $downtime) { $downtime_id = $downtime['id']; $downtime_type = $downtime['type_execution']; $downtime_periodicity = $downtime['type_periodicity']; if ($downtime_type == 'once') { $dates = array(); $dates['date_from'] = $downtime['date_from']; $dates['date_to'] = $downtime['date_to']; $downtime_dates[] = $dates; } else if ($downtime_type == 'periodically') { // If a planned downtime have malformed dates, its intervals aren't taken account $downtime_malformed = false; foreach ($malformed_planned_downtimes as $malformed_planned_downtime) { if ($downtime_id == $malformed_planned_downtime['id']) { $downtime_malformed = true; break; } } if ($downtime_malformed == true) { continue; } // If a planned downtime have malformed dates, its intervals aren't taken account $downtime_time_from = $downtime['periodically_time_from']; $downtime_time_to = $downtime['periodically_time_to']; $downtime_hour_from = date("H", strtotime($downtime_time_from)); $downtime_minute_from = date("i", strtotime($downtime_time_from)); $downtime_second_from = date("s", strtotime($downtime_time_from)); $downtime_hour_to = date("H", strtotime($downtime_time_to)); $downtime_minute_to = date("i", strtotime($downtime_time_to)); $downtime_second_to = date("s", strtotime($downtime_time_to)); if ($downtime_periodicity == "monthly") { $downtime_day_from = $downtime['periodically_day_from']; $downtime_day_to = $downtime['periodically_day_to']; $date_aux = strtotime(date("Y-m-01", $start_date)); $year_aux = date("Y", $date_aux); $month_aux = date("m", $date_aux); $end_year = date("Y", $end_date); $end_month = date("m", $end_date); while ($year_aux < $end_year || ($year_aux == $end_year && $month_aux <= $end_month)) { if ($downtime_day_from > $downtime_day_to) { $dates = array(); $dates['date_from'] = strtotime("$year_aux-$month_aux-$downtime_day_from $downtime_hour_from:$downtime_minute_from:$downtime_second_from"); $dates['date_to'] = strtotime(date("Y-m-t H:i:s", strtotime("$year_aux-$month_aux-28 23:59:59"))); $downtime_dates[] = $dates; $dates = array(); if ($month_aux + 1 <= 12) { $dates['date_from'] = strtotime("$year_aux-".($month_aux + 1)."-01 00:00:00"); $dates['date_to'] = strtotime("$year_aux-".($month_aux + 1)."-$downtime_day_to $downtime_hour_to:$downtime_minute_to:$downtime_second_to"); } else { $dates['date_from'] = strtotime(($year_aux + 1)."-01-01 00:00:00"); $dates['date_to'] = strtotime(($year_aux + 1)."-01-$downtime_day_to $downtime_hour_to:$downtime_minute_to:$downtime_second_to"); } $downtime_dates[] = $dates; } else { if ($downtime_day_from == $downtime_day_to && strtotime($downtime_time_from) > strtotime($downtime_time_to)) { $date_aux_from = strtotime("$year_aux-$month_aux-$downtime_day_from $downtime_hour_from:$downtime_minute_from:$downtime_second_from"); $max_day_num = date('t', $date_aux); $dates = array(); $dates['date_from'] = strtotime("$year_aux-$month_aux-$downtime_day_from $downtime_hour_from:$downtime_minute_from:$downtime_second_from"); $dates['date_to'] = strtotime("$year_aux-$month_aux-$downtime_day_from 23:59:59"); $downtime_dates[] = $dates; if ($downtime_day_to + 1 > $max_day_num) { $dates = array(); if ($month_aux + 1 <= 12) { $dates['date_from'] = strtotime("$year_aux-".($month_aux + 1)."-01 00:00:00"); $dates['date_to'] = strtotime("$year_aux-".($month_aux + 1)."-01 $downtime_hour_to:$downtime_minute_to:$downtime_second_to"); } else { $dates['date_from'] = strtotime(($year_aux + 1)."-01-01 00:00:00"); $dates['date_to'] = strtotime(($year_aux + 1)."-01-01 $downtime_hour_to:$downtime_minute_to:$downtime_second_to"); } $downtime_dates[] = $dates; } else { $dates = array(); $dates['date_from'] = strtotime("$year_aux-$month_aux-".($downtime_day_to + 1)." 00:00:00"); $dates['date_to'] = strtotime("$year_aux-$month_aux-".($downtime_day_to + 1)." $downtime_hour_to:$downtime_minute_to:$downtime_second_to"); $downtime_dates[] = $dates; } } else { $dates = array(); $dates['date_from'] = strtotime("$year_aux-$month_aux-$downtime_day_from $downtime_hour_from:$downtime_minute_from:$downtime_second_from"); $dates['date_to'] = strtotime("$year_aux-$month_aux-$downtime_day_to $downtime_hour_to:$downtime_minute_to:$downtime_second_to"); $downtime_dates[] = $dates; } } $month_aux++; if ($month_aux > 12) { $month_aux = 1; $year_aux++; } } } else if ($downtime_periodicity == "weekly") { $date_aux = $start_date; $active_days = array(); $active_days[0] = ($downtime['sunday'] == 1) ? true : false; $active_days[1] = ($downtime['monday'] == 1) ? true : false; $active_days[2] = ($downtime['tuesday'] == 1) ? true : false; $active_days[3] = ($downtime['wednesday'] == 1) ? true : false; $active_days[4] = ($downtime['thursday'] == 1) ? true : false; $active_days[5] = ($downtime['friday'] == 1) ? true : false; $active_days[6] = ($downtime['saturday'] == 1) ? true : false; while ($date_aux <= $end_date) { $weekday_num = date('w', $date_aux); if ($active_days[$weekday_num]) { $day_num = date('d', $date_aux); $month_num = date('m', $date_aux); $year_num = date('Y', $date_aux); $max_day_num = date('t', $date_aux); if (strtotime($downtime_time_from) > strtotime($downtime_time_to)) { $dates = array(); $dates['date_from'] = strtotime("$year_num-$month_num-$day_num $downtime_hour_from:$downtime_minute_from:$downtime_second_from"); $dates['date_to'] = strtotime("$year_num-$month_num-$day_num 23:59:59"); $downtime_dates[] = $dates; $dates = array(); if ($day_num + 1 > $max_day_num) { if ($month_num + 1 > 12) { $dates['date_from'] = strtotime(($year_num + 1)."-01-01 00:00:00"); $dates['date_to'] = strtotime(($year_num + 1)."-01-01 $downtime_hour_to:$downtime_minute_to:$downtime_second_to"); } else { $dates['date_from'] = strtotime("$year_num-".($month_num + 1)."-01 00:00:00"); $dates['date_to'] = strtotime("$year_num-".($month_num + 1)."-01 $downtime_hour_to:$downtime_minute_to:$downtime_second_to"); } } else { $dates['date_from'] = strtotime("$year_num-$month_num-".($day_num + 1)." 00:00:00"); $dates['date_to'] = strtotime("$year_num-$month_num-".($day_num + 1)." $downtime_hour_to:$downtime_minute_to:$downtime_second_to"); } $downtime_dates[] = $dates; } else { $dates = array(); $dates['date_from'] = strtotime("$year_num-$month_num-$day_num $downtime_hour_from:$downtime_minute_from:$downtime_second_from"); $dates['date_to'] = strtotime("$year_num-$month_num-$day_num $downtime_hour_to:$downtime_minute_to:$downtime_second_to"); $downtime_dates[] = $dates; } } $date_aux += SECONDS_1DAY; } } } } if ($check_services) { enterprise_include_once("include/functions_services.php"); if (function_exists("services_get_planned_downtimes_intervals")) { services_get_planned_downtimes_intervals($downtime_dates, $start_date, $end_date, false, $id_agent_module); } } return $downtime_dates; } /** * Get the planned downtimes that affect the passed modules on an specific datetime range. * * @param int Start date in utimestamp. * @param int End date in utimestamp. * @param array The agent modules ids. * * @return Array with the planned downtimes that are executed in any moment of the range selected and affect the * agent modules selected. */ function reporting_get_planned_downtimes ($start_date, $end_date, $id_agent_modules = false) { $start_time = date("H:i:s", $start_date); $end_time = date("H:i:s", $end_date); $start_day = date("d", $start_date); $end_day = date("d", $end_date); $start_month = date("m", $start_date); $end_month = date("m", $end_date); if ($start_date > $end_date) { return false; } if ($end_date - $start_date >= SECONDS_1MONTH) { // If the date range is larger than 1 month, every monthly planned downtime will be inside $periodically_monthly_w = "type_periodicity = 'monthly'"; } else { // Check if the range is larger than the planned downtime execution, or if its start or end // is inside the planned downtime execution. // The start and end time is very important. $periodically_monthly_w = "type_periodicity = 'monthly' AND (((periodically_day_from > '$start_day' OR (periodically_day_from = '$start_day' AND periodically_time_from >= '$start_time')) AND (periodically_day_to < '$end_day' OR (periodically_day_to = '$end_day' AND periodically_time_to <= '$end_time'))) OR ((periodically_day_from < '$start_day' OR (periodically_day_from = '$start_day' AND periodically_time_from <= '$start_time')) AND (periodically_day_to > '$start_day' OR (periodically_day_to = '$start_day' AND periodically_time_to >= '$start_time'))) OR ((periodically_day_from < '$end_day' OR (periodically_day_from = '$end_day' AND periodically_time_from <= '$end_time')) AND (periodically_day_to > '$end_day' OR (periodically_day_to = '$end_day' AND periodically_time_to >= '$end_time'))))"; } $periodically_weekly_days = array(); $date_aux = $start_date; $i = 0; if (($end_date - $start_date) >= SECONDS_1WEEK) { // If the date range is larger than 7 days, every weekly planned downtime will be inside. for ($i = 0; $i < 7; $i++) { $weekday_actual = strtolower(date('l', $date_aux)); $periodically_weekly_days[] = "($weekday_actual = 1)"; $date_aux += SECONDS_1DAY; } } else if (($end_date - $start_date) <= SECONDS_1DAY && $start_day == $end_day) { // If the date range is smaller than 1 day, the start and end days can be equal or consecutive. // If they are equal, the execution times have to be contained in the date range times or contain // the start or end time of the date range. $weekday_actual = strtolower(date('l', $start_date)); $periodically_weekly_days[] = "($weekday_actual = 1 AND ((periodically_time_from > '$start_time' AND periodically_time_to < '$end_time') OR (periodically_time_from = '$start_time' OR (periodically_time_from < '$start_time' AND periodically_time_to >= '$start_time')) OR (periodically_time_from = '$end_time' OR (periodically_time_from < '$end_time' AND periodically_time_to >= '$end_time'))))"; } else { while ($date_aux <= $end_date && $i < 7) { $weekday_actual = strtolower(date('l', $date_aux)); $day_num_actual = date('d', $date_aux); if ($date_aux == $start_date) { $periodically_weekly_days[] = "($weekday_actual = 1 AND periodically_time_to >= '$start_time')"; } else if ($day_num_actual == $end_day) { $periodically_weekly_days[] = "($weekday_actual = 1 AND periodically_time_from <= '$end_time')"; } else { $periodically_weekly_days[] = "($weekday_actual = 1)"; } $date_aux += SECONDS_1DAY; $i++; } } if (!empty($periodically_weekly_days)) { $periodically_weekly_w = "type_periodicity = 'weekly' AND (".implode(" OR ", $periodically_weekly_days).")"; $periodically_condition = "(($periodically_monthly_w) OR ($periodically_weekly_w))"; } else { $periodically_condition = "($periodically_monthly_w)"; } if ($id_agent_modules !== false) { if (empty($id_agent_modules)) return array(); $id_agent_modules_str = implode(",", $id_agent_modules); $sql_downtime = "SELECT DISTINCT(tpdr.id), tpdr.* FROM ( SELECT tpd.* FROM tplanned_downtime tpd, tplanned_downtime_agents tpda, tagente_modulo tam WHERE (tpd.id = tpda.id_downtime AND tpda.all_modules = 1 AND tpda.id_agent = tam.id_agente AND tam.id_agente_modulo IN ($id_agent_modules_str)) AND ((type_execution = 'periodically' AND $periodically_condition) OR (type_execution = 'once' AND ((date_from >= '$start_date' AND date_to <= '$end_date') OR (date_from <= '$start_date' AND date_to >= '$end_date') OR (date_from <= '$start_date' AND date_to >= '$start_date') OR (date_from <= '$end_date' AND date_to >= '$end_date')))) UNION ALL SELECT tpd.* FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm WHERE (tpd.id = tpdm.id_downtime AND tpdm.id_agent_module IN ($id_agent_modules_str)) AND ((type_execution = 'periodically' AND $periodically_condition) OR (type_execution = 'once' AND ((date_from >= '$start_date' AND date_to <= '$end_date') OR (date_from <= '$start_date' AND date_to >= '$end_date') OR (date_from <= '$start_date' AND date_to >= '$start_date') OR (date_from <= '$end_date' AND date_to >= '$end_date')))) ) tpdr ORDER BY tpdr.id"; } else { $sql_downtime = "SELECT * FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm WHERE (type_execution = 'periodically' AND $periodically_condition) OR (type_execution = 'once' AND ((date_from >= '$start_date' AND date_to <= '$end_date') OR (date_from <= '$start_date' AND date_to >= '$end_date') OR (date_from <= '$start_date' AND date_to >= '$start_date') OR (date_from <= '$end_date' AND date_to >= '$end_date')))"; } $downtimes = db_get_all_rows_sql($sql_downtime); if ($downtimes == false) { $downtimes = array(); } return $downtimes; } function reporting_get_stats_servers($tiny = true) { global $config; $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/module.png', true, array('title' => __('Total running modules'), 'width' => '25px')); $tdata[1] = '' . format_numeric($server_performance ["total_modules"]) . ''; $tdata[2] = '' . format_numeric($server_performance ["total_modules_rate"], 2) . ''; $tdata[3] = html_print_image('images/module.png', true, array('title' => __('Ratio') . ': ' . __('Modules by second'), 'width' => '16px')) . '/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; $tdata = array(); $tdata[0] = '
'.$value.'
'; array_push ($table->data, $data); break; case 'simple_baseline_graph': if (empty($item_title)) { $item_title = __('Simple baseline graph'); } reporting_header_content($mini, $content, $report, $table, $item_title, ui_print_truncate_text($agent_name, 'agent_medium', false).''; $data[0] .= html_print_image("images/module_ok.png", true) . ' ' . __('OK') . ': ' . $monitor_value.' %
'; if ($monitor_value !== __('Unknown')) { $monitor_value = format_numeric (100 - $monitor_value, 2) ; } $data[1] = ''; $data[1] .= html_print_image("images/module_critical.png", true) . ' ' .__('Not OK') . ': ' .$monitor_value.' % ' . '
'; array_push ($table->data, $data); break; case 7: case 'avg_value': if (empty($item_title)) { $item_title = __('Avg. Value'); } reporting_header_content($mini, $content, $report, $table, $item_title, ui_print_truncate_text($agent_name, 'agent_medium', false) . ''.$value.'
'; array_push ($table->data, $data); break; case 8: case 'max_value': if (empty($item_title)) { $item_title = __('Max. Value'); } reporting_header_content($mini, $content, $report, $table, $item_title, 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': if (empty($item_title)) { $item_title = __('Min. Value'); } reporting_header_content($mini, $content, $report, $table, $item_title, ui_print_truncate_text($agent_name, 'agent_medium', false) . ''.$value.'
'; array_push ($table->data, $data); break; case 10: case 'sumatory': if (empty($item_title)) { $item_title = __('Summatory'); } reporting_header_content($mini, $content, $report, $table, $item_title, ui_print_truncate_text($agent_name, 'agent_medium', false) . ''.$value.'
'; array_push ($table->data, $data); break; case 'agent_detailed_event': case 'event_report_agent': if (empty($item_title)) { $item_title = __('Agent detailed event'); } reporting_header_content($mini, $content, $report, $table, $item_title, 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']; $next_row = 1; // Put description at the end of the module (if exists) if ($content["description"] != "") { $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); $table->colspan[$next_row][0] = 3; $next_row++; } $data = array (); $table->colspan[$next_row][0] = 3; $next_row++; $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); if(!empty($data[0])) { array_push ($table->data, $data); $table->colspan[$next_row][0] = 3; $next_row++; } 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->width = '100%'; $table_event_graph->style[0] = 'text-align: center;'; $table_event_graph->head[0] = __('Events validated by user'); $table_event_graph->data[0][0] = pie3d_graph( false, $data_graph, 500, 150, __("other"), "", ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size']); $data[0] = html_print_table($table_event_graph, true); $table->colspan[$next_row][0] = 3; $next_row++; 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); $colors = get_criticity_pie_colors($data_graph); $table_event_graph = null; $table_event_graph->width = '100%'; $table_event_graph->style[0] = 'text-align: center;'; $table_event_graph->head[0] = __('Events by criticity'); $table_event_graph->data[0][0] = pie3d_graph( false, $data_graph, 500, 150, __("other"), "", ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], 1, false, $colors); $data[0] = html_print_table($table_event_graph, true); $table->colspan[$next_row][0] = 3; $next_row++; 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->width = '100%'; $table_event_graph->style[0] = 'text-align: center;'; $table_event_graph->head[0] = __('Amount events validated'); $table_event_graph->data[0][0] = pie3d_graph( false, $data_graph, 500, 150, __("other"), "", ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size']); $data[0] = html_print_table($table_event_graph, true); $table->colspan[$next_row][0] = 3; $next_row++; array_push ($table->data, $data); } break; case 'text': if (empty($item_title)) { $item_title = __('Text'); } reporting_header_content($mini, $content, $report, $table, $item_title, "", ""); $next_row = 1; if ($content["description"] != ""){ $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); $table->colspan[$next_row][0] = 3; $next_row++; } $data[0] = html_entity_decode($content['text']); array_push($table->data, $data); $table->colspan[$next_row][0] = 3; break; case 'sql': if (empty($item_title)) { $item_title = __('SQL'); } reporting_header_content($mini, $content, $report, $table, $item_title, "", ""); $next_row = 1; // Put description at the end of the module (if exists) if ($content["description"] != ""){ $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); $table->colspan[$next_row][0] = 3; $next_row++; } $table->colspan[$next_row][0] = 3; $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': if (empty($item_title)) { $item_title = __('TTO'); } reporting_header_content($mini, $content, $report, $table, $item_title, ui_print_truncate_text($agent_name, 'agent_medium', false) . ''.$tto.'
'; array_push ($table->data, $data); break; case 'MTBF': if (empty($item_title)) { $item_title = __('MTBF'); } reporting_header_content($mini, $content, $report, $table, $item_title, ui_print_truncate_text($agent_name, 'agent_medium', false) . ''.$mtbf.'
'; array_push ($table->data, $data); break; case 'MTTR': if (empty($item_title)) { $item_title = __('MTTR'); } reporting_header_content($mini, $content, $report, $table, $item_title, 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(); } if (empty($item_title)) { $item_title = __('Group report').': "'.$group_name.'"'; } reporting_header_content($mini, $content, $report, $table, $item_title); $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] = "" .
__('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++; $file_name = string2image(ui_print_truncate_text($module['name'], 'module_small', false, true, false, '...'), false, false, 6, 270, '#B1B1B1', '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 .= " |
" . __('Legend') . " | |
" . __("Orange cell when the module has fired alerts") . " | |
" . __("Red cell when the module has a critical status") . " | |
" . __("Yellow cell when the module has a warning status") . " | |
" . __("Green cell when the module has a normal status") . " | |
" . __("Grey cell when the module has an unknown status") . " |