Killing pink unicorns and magic numbers.

This commit is contained in:
mdtrooper 2015-02-16 18:37:16 +01:00
parent d70c5f5811
commit 0473856048
28 changed files with 400 additions and 405 deletions

View File

@ -298,20 +298,28 @@ function mainAgentsModules() {
echo "<td style='text-align: center;'>"; echo "<td style='text-align: center;'>";
$win_handle = dechex(crc32($module_id.$module["name"])); $win_handle = dechex(crc32($module_id.$module["name"]));
$graph_type = return_graphtype (modules_get_agentmodule_type($module_id)); $graph_type = return_graphtype (modules_get_agentmodule_type($module_id));
$link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$module_id."&label=".rawurlencode(urlencode(base64_encode($module["name"])))."&refresh=600','day_".$win_handle."')"; $link ="winopeng('" .
"operation/agentes/stat_win.php?" .
"type=$graph_type&" .
"period=" . SECONDS_1DAY . "&" .
"id=" . $module_id . "&" .
"label=" . rawurlencode(
urlencode(
base64_encode($module["name"]))) . "&" .
"refresh=" . SECONDS_10MINUTES . "', 'day_".$win_handle."')";
echo '<a href="javascript:'.$link.'">'; echo '<a href="javascript:'.$link.'">';
switch ($status) { switch ($status) {
case 0: case AGENT_MODULE_STATUS_NORMAL:
ui_print_status_image ('module_ok.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px')); ui_print_status_image ('module_ok.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px'));
break; break;
case 1: case AGENT_MODULE_STATUS_CRITICAL_BAD:
ui_print_status_image ('module_critical.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px')); ui_print_status_image ('module_critical.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px'));
break; break;
case 2: case AGENT_MODULE_STATUS_WARNING:
ui_print_status_image ('module_warning.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px')); ui_print_status_image ('module_warning.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px'));
break; break;
case 3: case AGENT_MODULE_STATUS_UNKNOWN:
ui_print_status_image ('module_unknown.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px')); ui_print_status_image ('module_unknown.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px'));
break; break;
case 4: case 4:

View File

@ -156,7 +156,7 @@ if ($delete_template) {
$id = get_parameter ('id'); $id = get_parameter ('id');
$al_template = alerts_get_alert_template($id); $al_template = alerts_get_alert_template($id);
if ($al_template !== false){ if ($al_template !== false) {
// If user tries to delete a template with group=ALL then must have "PM" access privileges // If user tries to delete a template with group=ALL then must have "PM" access privileges
if ($al_template['id_group'] == 0) { if ($al_template['id_group'] == 0) {
if (! check_acl ($config['id_user'], 0, "PM")) { if (! check_acl ($config['id_user'], 0, "PM")) {

View File

@ -31,22 +31,22 @@ if (! check_acl ($config['id_user'], 0, "DM")) {
$time["all"] = get_system_time (); $time["all"] = get_system_time ();
// 1 day ago // 1 day ago
$time["1day"] = $time["all"]-86400; $time["1day"] = $time["all"] - SECONDS_1DAY;
// 3 days ago // 3 days ago
$time["3day"] = $time["all"]-(86400*3); $time["3day"] = $time["all"] - ( SECONDS_1DAY * 3);
// 1 week ago // 1 week ago
$time["1week"] = $time["all"]-(86400*7); $time["1week"] = $time["all"] - SECONDS_1WEEK;
// 2 weeks ago // 2 weeks ago
$time["2week"] = $time["all"]-(86400*14); $time["2week"] = $time["all"] - SECONDS_2WEEK;
// 1 month ago // 1 month ago
$time["1month"] = $time["all"]-(86400*30); $time["1month"] = $time["all"] - SECONDS_1MONTH;
// Three months ago // Three months ago
$time["3month"] = $time["all"]-(86400*90); $time["3month"] = $time["all"] - SECONDS_3MONTHS;
// Todo for a good DB maintenance // Todo for a good DB maintenance
/* /*

View File

@ -73,7 +73,7 @@ else {
$name = "Pandora FMS combined graph"; $name = "Pandora FMS combined graph";
$width = 550; $width = 550;
$height = 210; $height = 210;
$period = 86400; $period = SECONDS_1DAY;
//$alerts= ""; //$alerts= "";
$events = 0; $events = 0;
$factor = 1; $factor = 1;

View File

@ -63,10 +63,10 @@ $top_n_value = 10;
$exception_condition = REPORT_EXCEPTION_CONDITION_EVERYTHING; $exception_condition = REPORT_EXCEPTION_CONDITION_EVERYTHING;
$exception_condition_value = 10; $exception_condition_value = 10;
$modulegroup = 0; $modulegroup = 0;
$period = 86400; $period = SECONDS_1DAY;
// Added support for projection graphs // Added support for projection graphs
$period_pg = 432000; $period_pg = SECONDS_5DAY;
$projection_period = 432000; $projection_period = SECONDS_5DAY;
$only_display_wrong = 0; $only_display_wrong = 0;
// Added support for prediction date report // Added support for prediction date report
$min_interval = '0.00'; $min_interval = '0.00';

View File

@ -72,7 +72,7 @@ if ($get_module_detail) {
ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/"); ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/");
$module_id = (int) get_parameter('id_module'); $module_id = (int) get_parameter('id_module');
$period = (int) get_parameter("period", 86400); $period = (int) get_parameter("period", SECONDS_1DAY);
$group = agents_get_agentmodule_group ($module_id); $group = agents_get_agentmodule_group ($module_id);
$agentId = (int) get_parameter("id_agent"); $agentId = (int) get_parameter("id_agent");
$server_name = (string) get_parameter('server_name'); $server_name = (string) get_parameter('server_name');
@ -975,11 +975,26 @@ if ($list_modules) {
} else { } else {
$draw_events = 0; $draw_events = 0;
} }
$link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&amp;period=86400&amp;id=".$module["id_agente_modulo"]."&amp;label=".rawurlencode(urlencode(base64_encode($module["nombre"])))."&amp;refresh=600&amp;draw_events=$draw_events','day_".$win_handle."')"; $link ="winopeng('" .
"operation/agentes/stat_win.php?" .
"type=$graph_type&amp;" .
"period=" . SECONDS_1DAY . "&amp;" .
"id=" . $module["id_agente_modulo"] . "&amp;" .
"label=" . rawurlencode(
urlencode(
base64_encode($module["nombre"]))) . "&amp;" .
"refresh=" . SECONDS_10MINUTES . "&amp;" .
"draw_events=$draw_events', 'day_".$win_handle."')";
$data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> &nbsp;&nbsp;'; $data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> &nbsp;&nbsp;';
$server_name = ''; $server_name = '';
$data[8] .= "<a href='javascript: show_module_detail_dialog(" . $module["id_agente_modulo"] . ", ". $id_agente.", \"" . $server_name . "\", 0, 86400)'>". html_print_image ("images/binary.png", true, array ("border" => "0", "alt" => "")) . "</a>"; $data[8] .= "<a href='javascript: " .
"show_module_detail_dialog(" .
$module["id_agente_modulo"] . ", ".
$id_agente . ", " .
"\"" . $server_name . "\", " .
0 . ", " .
SECONDS_1DAY . ")'>". html_print_image ("images/binary.png", true, array ("border" => "0", "alt" => "")) . "</a>";
} }
if ($module['estado'] == 3) { if ($module['estado'] == 3) {

View File

@ -1181,7 +1181,7 @@ class Tree {
$module['statusText'] = "ok"; $module['statusText'] = "ok";
break; break;
} }
if ($statusType !== STATUS_MODULE_UNKNOWN_BALL if ($statusType !== STATUS_MODULE_UNKNOWN_BALL
&& $statusType !== STATUS_MODULE_NO_DATA_BALL) { && $statusType !== STATUS_MODULE_NO_DATA_BALL) {
if (is_numeric($module["value"])) { if (is_numeric($module["value"])) {
@ -1193,108 +1193,110 @@ class Tree {
} }
$module['statusImageHTML'] = ui_print_status_image($statusType, $statusTitle, true); $module['statusImageHTML'] = ui_print_status_image($statusType, $statusTitle, true);
// HTML of the server type image // HTML of the server type image
$module['serverTypeHTML'] = servers_show_type($module['server_type']); $module['serverTypeHTML'] = servers_show_type($module['server_type']);
// Link to the Module graph // Link to the Module graph
$graphType = return_graphtype($module['id']); $graphType = return_graphtype($module['id']);
$winHandle = dechex(crc32($module['id'] . $module['name'])); $winHandle = dechex(crc32($module['id'] . $module['name']));
if (!defined('METACONSOLE')) { if (!defined('METACONSOLE')) {
$moduleGraphURL = $config['homeurl'] . $moduleGraphURL = $config['homeurl'] .
"/operation/agentes/stat_win.php?" . "/operation/agentes/stat_win.php?" .
"type=$graphType&" . "type=$graphType&" .
"period=86400&" . "period=" . SECONDS_1DAY . "&" .
"id=" . $module['id'] . "&" . "id=" . $module['id'] . "&" .
"label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" . "label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" .
"refresh=600"; "refresh=" . SECONDS_10MINUTES;
} }
else if (!empty($server)) { else if (!empty($server)) {
$moduleGraphURL = ui_meta_get_url_console_child( $moduleGraphURL = ui_meta_get_url_console_child(
$server, null, null, null, null, $server, null, null, null, null,
"operation/agentes/stat_win.php?" . "operation/agentes/stat_win.php?" .
"type=$graph_type&" . "type=$graph_type&" .
"period=86400&" . "period=" . SECONDS_1DAY . "&" .
"id=" . $module["id"] . "&" . "id=" . $module["id"] . "&" .
"label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" . "label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" .
"refresh=600"); "refresh=" . SECONDS_10MINUTES);
} }
if (!empty($moduleGraphURL)) { if (!empty($moduleGraphURL)) {
$module['moduleGraph'] = array( $module['moduleGraph'] = array(
'url' => $moduleGraphURL, 'url' => $moduleGraphURL,
'handle' => $winHandle 'handle' => $winHandle
); );
} }
// Alerts fired image // Alerts fired image
$has_alerts = (bool) db_get_value('COUNT(DISTINCT(id_agent_module))', 'talert_template_modules', 'id_agent_module', $module['id']); $has_alerts = (bool) db_get_value(
'COUNT(DISTINCT(id_agent_module))',
'talert_template_modules', 'id_agent_module', $module['id']);
if ($has_alerts) { if ($has_alerts) {
$module['alertsImageHTML'] = html_print_image("images/bell.png", true, array("title" => __('Module alerts'))); $module['alertsImageHTML'] = html_print_image("images/bell.png", true, array("title" => __('Module alerts')));
} }
} }
protected function processModules (&$modules, $server = false) { protected function processModules (&$modules, $server = false) {
foreach ($modules as $iterator => $module) { foreach ($modules as $iterator => $module) {
$this->processModule($modules[$iterator], $server); $this->processModule($modules[$iterator], $server);
} }
} }
protected function processAgent (&$agent, $server = false) { protected function processAgent (&$agent, $server = false) {
global $config; global $config;
$agent['type'] = 'agent'; $agent['type'] = 'agent';
$agent['id'] = (int) $agent['id']; $agent['id'] = (int) $agent['id'];
$agent['name'] = $agent['name']; $agent['name'] = $agent['name'];
$agent['rootID'] = $this->rootID; $agent['rootID'] = $this->rootID;
$agent['rootType'] = $this->rootType; $agent['rootType'] = $this->rootType;
if (defined("METACONSOLE") && !empty($server)) if (defined("METACONSOLE") && !empty($server))
$agent['serverID'] = $server['id']; $agent['serverID'] = $server['id'];
// Counters // Counters
if (empty($agent['counters'])) { if (empty($agent['counters'])) {
$agent['counters'] = array(); $agent['counters'] = array();
if (isset($agent['unknown_count'])) if (isset($agent['unknown_count']))
$agent['counters']['unknown'] = $agent['unknown_count']; $agent['counters']['unknown'] = $agent['unknown_count'];
else else
$agent['counters']['unknown'] = agents_monitor_unknown($agent['id']); $agent['counters']['unknown'] = agents_monitor_unknown($agent['id']);
if (isset($agent['critical_count'])) if (isset($agent['critical_count']))
$agent['counters']['critical'] = $agent['critical_count']; $agent['counters']['critical'] = $agent['critical_count'];
else else
$agent['counters']['critical'] = agents_monitor_critical($agent['id']); $agent['counters']['critical'] = agents_monitor_critical($agent['id']);
if (isset($agent['warning_count'])) if (isset($agent['warning_count']))
$agent['counters']['warning'] = $agent['warning_count']; $agent['counters']['warning'] = $agent['warning_count'];
else else
$agent['counters']['warning'] = agents_monitor_warning($agent['id']); $agent['counters']['warning'] = agents_monitor_warning($agent['id']);
if (isset($agent['notinit_count'])) if (isset($agent['notinit_count']))
$agent['counters']['not_init'] = $agent['notinit_count']; $agent['counters']['not_init'] = $agent['notinit_count'];
else else
$agent['counters']['not_init'] = agents_monitor_notinit($agent['id']); $agent['counters']['not_init'] = agents_monitor_notinit($agent['id']);
if (isset($agent['normal_count'])) if (isset($agent['normal_count']))
$agent['counters']['ok'] = $agent['normal_count']; $agent['counters']['ok'] = $agent['normal_count'];
else else
$agent['counters']['ok'] = agents_monitor_ok($agent['id']); $agent['counters']['ok'] = agents_monitor_ok($agent['id']);
if (isset($agent['total_count'])) if (isset($agent['total_count']))
$agent['counters']['total'] = $agent['total_count']; $agent['counters']['total'] = $agent['total_count'];
else else
$agent['counters']['total'] = agents_monitor_total($agent['id']); $agent['counters']['total'] = agents_monitor_total($agent['id']);
if (isset($agent['fired_count'])) if (isset($agent['fired_count']))
$agent['counters']['alerts'] = $agent['fired_count']; $agent['counters']['alerts'] = $agent['fired_count'];
else else
$agent['counters']['alerts'] = agents_get_alerts_fired($agent['id']); $agent['counters']['alerts'] = agents_get_alerts_fired($agent['id']);
} }
// Status image // Status image
$agent['statusImageHTML'] = agents_tree_view_status_img_ball( $agent['statusImageHTML'] = agents_tree_view_status_img_ball(
$agent['counters']['critical'], $agent['counters']['critical'],
@ -1302,14 +1304,14 @@ class Tree {
$agent['counters']['unknown'], $agent['counters']['unknown'],
$agent['counters']['total'], $agent['counters']['total'],
$agent['counters']['not_init']); $agent['counters']['not_init']);
// Alerts fired image // Alerts fired image
$agent["alertImageHTML"] = agents_tree_view_alert_img_ball($agent['counters']['alerts']); $agent["alertImageHTML"] = agents_tree_view_alert_img_ball($agent['counters']['alerts']);
// Quiet image // Quiet image
if (isset($agent['quiet']) && $agent['quiet']) if (isset($agent['quiet']) && $agent['quiet'])
$agent['quietImageHTML'] = html_print_image("/images/dot_green.disabled.png", true, array("title" => __('Quiet'))); $agent['quietImageHTML'] = html_print_image("/images/dot_green.disabled.png", true, array("title" => __('Quiet')));
// Status // Status
$agent['statusRaw'] = agents_get_status($agent['id']); $agent['statusRaw'] = agents_get_status($agent['id']);
switch ($agent['statusRaw']) { switch ($agent['statusRaw']) {
@ -1343,7 +1345,7 @@ class Tree {
break; break;
case 'live': case 'live':
$agent['searchChildren'] = 0; $agent['searchChildren'] = 0;
// if ($searchChildren) // if ($searchChildren)
// $agent['children'] = $this->getModules($agent['id'], $modulesFilter); // $agent['children'] = $this->getModules($agent['id'], $modulesFilter);
break; break;
@ -1361,7 +1363,7 @@ class Tree {
} }
} }
} }
protected function processAgents (&$agents, $server = false) { protected function processAgents (&$agents, $server = false) {
if (!empty($agents)) { if (!empty($agents)) {
foreach ($agents as $iterator => $agent) { foreach ($agents as $iterator => $agent) {
@ -1369,9 +1371,9 @@ class Tree {
} }
} }
} }
public function getData() { public function getData() {
if (! $this->strictACL) { if (! $this->strictACL) {
switch ($this->type) { switch ($this->type) {
case 'os': case 'os':
@ -1408,17 +1410,17 @@ class Tree {
} }
} }
} }
protected function getDataExtended () { protected function getDataExtended () {
// Override this method to add new types // Override this method to add new types
} }
private function getDataAgent () { private function getDataAgent () {
$processed_items = array(); $processed_items = array();
// Module names // Module names
if ($this->id == -1) { if ($this->id == -1) {
} }
// Agents // Agents
else { else {
@ -1429,52 +1431,52 @@ class Tree {
} }
else { else {
$items = array(); $items = array();
if ($this->serverID !== false) { if ($this->serverID !== false) {
$server = metaconsole_get_servers($this->serverID); $server = metaconsole_get_servers($this->serverID);
if (metaconsole_connect($server) == NOERR) { if (metaconsole_connect($server) == NOERR) {
db_clean_cache(); db_clean_cache();
$newItems = $this->getItems(); $newItems = $this->getItems();
$this->processModules($newItems, $server); $this->processModules($newItems, $server);
$items = array_merge($items, $newItems); $items = array_merge($items, $newItems);
metaconsole_restore_db(); metaconsole_restore_db();
} }
} }
if (!empty($items)) if (!empty($items))
usort($items, array("Tree", "cmpSortNames")); usort($items, array("Tree", "cmpSortNames"));
$processed_items = $items; $processed_items = $items;
} }
} }
$this->tree = $processed_items; $this->tree = $processed_items;
} }
private function getDataStrict () { private function getDataStrict () {
global $config; global $config;
require_once($config['homedir']."/include/functions_groups.php"); require_once($config['homedir']."/include/functions_groups.php");
$processed_items = array(); $processed_items = array();
// Groups and tags // Groups and tags
if ($this->id == -1) { if ($this->id == -1) {
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
$items = group_get_data($config['id_user'], $this->strictACL, $this->acltags, false, 'tree'); $items = group_get_data($config['id_user'], $this->strictACL, $this->acltags, false, 'tree');
// Build the group and tag hierarchy // Build the group and tag hierarchy
$processed_items = array(); $processed_items = array();
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
if (empty($item['_parent_id_'])) { if (empty($item['_parent_id_'])) {
unset($items[$key]); unset($items[$key]);
$item['id'] = $item['_id_']; $item['id'] = $item['_id_'];
$item['name'] = $item['_name_']; $item['name'] = $item['_name_'];
if (isset($item['_is_tag_']) && $item['_is_tag_']) { if (isset($item['_is_tag_']) && $item['_is_tag_']) {
$item['type'] = 'tag'; $item['type'] = 'tag';
$item['rootType'] = 'tag'; $item['rootType'] = 'tag';
@ -1483,11 +1485,11 @@ class Tree {
$item['type'] = 'group'; $item['type'] = 'group';
$item['rootType'] = 'group'; $item['rootType'] = 'group';
$item['parent'] = $item['_parent_id_']; $item['parent'] = $item['_parent_id_'];
if (!empty($item['_iconImg_'])) if (!empty($item['_iconImg_']))
$item['iconHTML'] = $item['_iconImg_']; $item['iconHTML'] = $item['_iconImg_'];
} }
if (isset($item['_agents_unknown_'])) if (isset($item['_agents_unknown_']))
$item['total_unknown_count'] = $item['_agents_unknown_']; $item['total_unknown_count'] = $item['_agents_unknown_'];
if (isset($item['_agents_critical_'])) if (isset($item['_agents_critical_']))
@ -1502,9 +1504,9 @@ class Tree {
$item['total_count'] = $item['_total_agents_']; $item['total_count'] = $item['_total_agents_'];
if (isset($item['_monitors_alerts_fired_'])) if (isset($item['_monitors_alerts_fired_']))
$item['total_fired_count'] = $item['_monitors_alerts_fired_']; $item['total_fired_count'] = $item['_monitors_alerts_fired_'];
$processed_item = $this->getProcessedItem($item, false, $items); $processed_item = $this->getProcessedItem($item, false, $items);
if (!empty($processed_item) if (!empty($processed_item)
&& isset($processed_item['counters']) && isset($processed_item['counters'])
&& isset($processed_item['counters']['total']) && isset($processed_item['counters']['total'])
@ -1516,24 +1518,24 @@ class Tree {
} }
else { else {
$unmerged_items = array(); $unmerged_items = array();
$servers = metaconsole_get_servers(); $servers = metaconsole_get_servers();
foreach ($servers as $server) { foreach ($servers as $server) {
if (metaconsole_connect($server) != NOERR) if (metaconsole_connect($server) != NOERR)
continue; continue;
db_clean_cache(); db_clean_cache();
$items = group_get_data($config['id_user'], $this->strictACL, $this->acltags, false, 'tree'); $items = group_get_data($config['id_user'], $this->strictACL, $this->acltags, false, 'tree');
// Build the group hierarchy // Build the group hierarchy
$processed_items = array(); $processed_items = array();
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
if (empty($item['_parent_id_'])) { if (empty($item['_parent_id_'])) {
unset($items[$key]); unset($items[$key]);
$item['id'] = $item['_id_']; $item['id'] = $item['_id_'];
$item['name'] = $item['_name_']; $item['name'] = $item['_name_'];
if (isset($item['_is_tag_']) && $item['_is_tag_']) { if (isset($item['_is_tag_']) && $item['_is_tag_']) {
$item['type'] = 'tag'; $item['type'] = 'tag';
$item['rootType'] = 'tag'; $item['rootType'] = 'tag';
@ -1542,11 +1544,11 @@ class Tree {
$item['type'] = 'group'; $item['type'] = 'group';
$item['rootType'] = 'group'; $item['rootType'] = 'group';
$item['parent'] = $item['_parent_id_']; $item['parent'] = $item['_parent_id_'];
if (!empty($item['_iconImg_'])) if (!empty($item['_iconImg_']))
$item['iconHTML'] = $item['_iconImg_']; $item['iconHTML'] = $item['_iconImg_'];
} }
if (isset($item['_agents_unknown_'])) if (isset($item['_agents_unknown_']))
$item['total_unknown_count'] = $item['_agents_unknown_']; $item['total_unknown_count'] = $item['_agents_unknown_'];
if (isset($item['_agents_critical_'])) if (isset($item['_agents_critical_']))
@ -1561,12 +1563,12 @@ class Tree {
$item['total_count'] = $item['_total_agents_']; $item['total_count'] = $item['_total_agents_'];
if (isset($item['_monitors_alerts_fired_'])) if (isset($item['_monitors_alerts_fired_']))
$item['total_fired_count'] = $item['_monitors_alerts_fired_']; $item['total_fired_count'] = $item['_monitors_alerts_fired_'];
$processed_items[] = $this->getProcessedItem($item, $server, $items); $processed_items[] = $this->getProcessedItem($item, $server, $items);
} }
} }
$unmerged_items += $processed_items; $unmerged_items += $processed_items;
metaconsole_restore_db(); metaconsole_restore_db();
} }
@ -1582,26 +1584,26 @@ class Tree {
} }
else { else {
$rootIDs = $this->rootID; $rootIDs = $this->rootID;
$items = array(); $items = array();
foreach ($rootIDs as $serverID => $rootID) { foreach ($rootIDs as $serverID => $rootID) {
$server = metaconsole_get_servers($serverID); $server = metaconsole_get_servers($serverID);
if (metaconsole_connect($server) != NOERR) if (metaconsole_connect($server) != NOERR)
continue; continue;
db_clean_cache(); db_clean_cache();
$this->rootID = $rootID; $this->rootID = $rootID;
$newItems = $this->getItems(); $newItems = $this->getItems();
$this->processAgents($newItems, $server); $this->processAgents($newItems, $server);
$items = array_merge($items, $newItems); $items = array_merge($items, $newItems);
metaconsole_restore_db(); metaconsole_restore_db();
} }
$this->rootID = $rootIDs; $this->rootID = $rootIDs;
if (!empty($items)) if (!empty($items))
usort($items, array("Tree", "cmpSortNames")); usort($items, array("Tree", "cmpSortNames"));
$processed_items = $items; $processed_items = $items;
} }
} }
@ -1611,19 +1613,19 @@ class Tree {
private function getDataGroup() { private function getDataGroup() {
$processed_items = array(); $processed_items = array();
// Groups // Groups
if ($this->id == -1) { if ($this->id == -1) {
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
$items = $this->getItems(); $items = $this->getItems();
// Build the group hierarchy // Build the group hierarchy
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
if (empty($item['parent'])) { if (empty($item['parent'])) {
unset($items[$key]); unset($items[$key]);
$processed_item = $this->getProcessedItem($item, false, $items); $processed_item = $this->getProcessedItem($item, false, $items);
if (!empty($processed_item) if (!empty($processed_item)
&& isset($processed_item['counters']) && isset($processed_item['counters'])
&& isset($processed_item['counters']['total']) && isset($processed_item['counters']['total'])
@ -1634,7 +1636,7 @@ class Tree {
} }
else { else {
$servers = metaconsole_get_servers(); $servers = metaconsole_get_servers();
$item_list = array(); $item_list = array();
foreach ($servers as $server) { foreach ($servers as $server) {
if (metaconsole_connect($server) != NOERR) if (metaconsole_connect($server) != NOERR)
@ -1654,7 +1656,7 @@ class Tree {
} }
$item_list = array_merge($item_list, $processed_items); $item_list = array_merge($item_list, $processed_items);
metaconsole_restore_db(); metaconsole_restore_db();
} }
@ -1670,19 +1672,19 @@ class Tree {
} }
else { else {
$rootIDs = $this->rootID; $rootIDs = $this->rootID;
$items = array(); $items = array();
foreach ($rootIDs as $serverID => $rootID) { foreach ($rootIDs as $serverID => $rootID) {
$server = metaconsole_get_servers($serverID); $server = metaconsole_get_servers($serverID);
if (metaconsole_connect($server) != NOERR) if (metaconsole_connect($server) != NOERR)
continue; continue;
db_clean_cache(); db_clean_cache();
$this->rootID = $rootID; $this->rootID = $rootID;
$newItems = $this->getItems(); $newItems = $this->getItems();
$this->processAgents($newItems, $server); $this->processAgents($newItems, $server);
$items = array_merge($items, $newItems); $items = array_merge($items, $newItems);
metaconsole_restore_db(); metaconsole_restore_db();
} }
$this->rootID = $rootIDs; $this->rootID = $rootIDs;
@ -1696,57 +1698,57 @@ class Tree {
$this->tree = $processed_items; $this->tree = $processed_items;
} }
private function getDataTag() { private function getDataTag() {
$processed_items = array(); $processed_items = array();
// Tags // Tags
if ($this->id == -1) { if ($this->id == -1) {
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
$items = $this->getItems(); $items = $this->getItems();
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
$counters = $this->getCounters($item['id']); $counters = $this->getCounters($item['id']);
if (!empty($counters)) { if (!empty($counters)) {
foreach ($counters as $type => $value) { foreach ($counters as $type => $value) {
$item[$type] = $value; $item[$type] = $value;
} }
} }
$processed_item = $this->getProcessedItem($item); $processed_item = $this->getProcessedItem($item);
$processed_items[] = $processed_item; $processed_items[] = $processed_item;
} }
} }
else { else {
$servers = metaconsole_get_servers(); $servers = metaconsole_get_servers();
$item_list = array(); $item_list = array();
foreach ($servers as $server) { foreach ($servers as $server) {
if (metaconsole_connect($server) != NOERR) if (metaconsole_connect($server) != NOERR)
continue; continue;
db_clean_cache(); db_clean_cache();
$items = $this->getItems(); $items = $this->getItems();
$processed_items = array(); $processed_items = array();
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
$counters = $this->getCounters($item['id']); $counters = $this->getCounters($item['id']);
if (!empty($counters)) { if (!empty($counters)) {
foreach ($counters as $type => $value) { foreach ($counters as $type => $value) {
$item[$type] = $value; $item[$type] = $value;
} }
} }
$processed_item = $this->getProcessedItem($item, $server); $processed_item = $this->getProcessedItem($item, $server);
$processed_items[] = $processed_item; $processed_items[] = $processed_item;
} }
$item_list = array_merge($item_list, $processed_items); $item_list = array_merge($item_list, $processed_items);
metaconsole_restore_db(); metaconsole_restore_db();
} }
$processed_items = $this->getMergedItems($item_list); $processed_items = $this->getMergedItems($item_list);
} }
} }
@ -1759,26 +1761,26 @@ class Tree {
} }
else { else {
$rootIDs = $this->rootID; $rootIDs = $this->rootID;
$items = array(); $items = array();
foreach ($rootIDs as $serverID => $rootID) { foreach ($rootIDs as $serverID => $rootID) {
$server = metaconsole_get_servers($serverID); $server = metaconsole_get_servers($serverID);
if (metaconsole_connect($server) != NOERR) if (metaconsole_connect($server) != NOERR)
continue; continue;
db_clean_cache(); db_clean_cache();
$this->rootID = $rootID; $this->rootID = $rootID;
$newItems = $this->getItems(); $newItems = $this->getItems();
$this->processAgents($newItems, $server); $this->processAgents($newItems, $server);
$items = array_merge($items, $newItems); $items = array_merge($items, $newItems);
metaconsole_restore_db(); metaconsole_restore_db();
} }
$this->rootID = $rootIDs; $this->rootID = $rootIDs;
if (!empty($items)) if (!empty($items))
usort($items, array("Tree", "cmpSortNames")); usort($items, array("Tree", "cmpSortNames"));
$processed_items = $items; $processed_items = $items;
} }
} }
@ -1788,21 +1790,21 @@ class Tree {
private function getDataModules() { private function getDataModules() {
$processed_items = array(); $processed_items = array();
// Module names // Module names
if ($this->id == -1) { if ($this->id == -1) {
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
$items = $this->getItems(); $items = $this->getItems();
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
$counters = $this->getCounters($item['name']); $counters = $this->getCounters($item['name']);
if (!empty($counters)) { if (!empty($counters)) {
foreach ($counters as $type => $value) { foreach ($counters as $type => $value) {
$item[$type] = $value; $item[$type] = $value;
} }
} }
$name = str_replace(array(' ','#','/','.','(',')','¿','?','¡','!'), $name = str_replace(array(' ','#','/','.','(',')','¿','?','¡','!'),
array( '_articapandora_'.ord(' ').'_pandoraartica_', array( '_articapandora_'.ord(' ').'_pandoraartica_',
'_articapandora_'.ord('#').'_pandoraartica_', '_articapandora_'.ord('#').'_pandoraartica_',
@ -1815,35 +1817,35 @@ class Tree {
'_articapandora_'.ord('¡').'_pandoraartica_', '_articapandora_'.ord('¡').'_pandoraartica_',
'_articapandora_'.ord('!').'_pandoraartica_'), '_articapandora_'.ord('!').'_pandoraartica_'),
io_safe_output($item['name'])); io_safe_output($item['name']));
$processed_item = $this->getProcessedItem($item); $processed_item = $this->getProcessedItem($item);
$processed_item['id'] = $name; $processed_item['id'] = $name;
$processed_item['rootID'] = $name; $processed_item['rootID'] = $name;
$processed_items[] = $processed_item; $processed_items[] = $processed_item;
} }
} }
else { else {
$servers = metaconsole_get_servers(); $servers = metaconsole_get_servers();
$item_list = array(); $item_list = array();
foreach ($servers as $server) { foreach ($servers as $server) {
if (metaconsole_connect($server) != NOERR) if (metaconsole_connect($server) != NOERR)
continue; continue;
db_clean_cache(); db_clean_cache();
$items = $this->getItems(); $items = $this->getItems();
$processed_items = array(); $processed_items = array();
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
$counters = $this->getCounters($item['name']); $counters = $this->getCounters($item['name']);
if (!empty($counters)) { if (!empty($counters)) {
foreach ($counters as $type => $value) { foreach ($counters as $type => $value) {
$item[$type] = $value; $item[$type] = $value;
} }
} }
$name = str_replace(array(' ','#','/','.','(',')','¿','?','¡','!'), $name = str_replace(array(' ','#','/','.','(',')','¿','?','¡','!'),
array( '_articapandora_'.ord(' ').'_pandoraartica_', array( '_articapandora_'.ord(' ').'_pandoraartica_',
'_articapandora_'.ord('#').'_pandoraartica_', '_articapandora_'.ord('#').'_pandoraartica_',
@ -1856,18 +1858,18 @@ class Tree {
'_articapandora_'.ord('¡').'_pandoraartica_', '_articapandora_'.ord('¡').'_pandoraartica_',
'_articapandora_'.ord('!').'_pandoraartica_'), '_articapandora_'.ord('!').'_pandoraartica_'),
io_safe_output($item['name'])); io_safe_output($item['name']));
$processed_item = $this->getProcessedItem($item, $server); $processed_item = $this->getProcessedItem($item, $server);
$processed_item['id'] = $name; $processed_item['id'] = $name;
$processed_item['rootID'] = $name; $processed_item['rootID'] = $name;
$processed_items[] = $processed_item; $processed_items[] = $processed_item;
} }
$item_list = array_merge($item_list, $processed_items); $item_list = array_merge($item_list, $processed_items);
metaconsole_restore_db(); metaconsole_restore_db();
} }
$processed_items = $this->getMergedItems($item_list); $processed_items = $this->getMergedItems($item_list);
} }
} }
@ -1880,83 +1882,83 @@ class Tree {
} }
else { else {
$rootIDs = $this->rootID; $rootIDs = $this->rootID;
$items = array(); $items = array();
foreach ($rootIDs as $serverID => $rootID) { foreach ($rootIDs as $serverID => $rootID) {
$server = metaconsole_get_servers($serverID); $server = metaconsole_get_servers($serverID);
if (metaconsole_connect($server) != NOERR) if (metaconsole_connect($server) != NOERR)
continue; continue;
db_clean_cache(); db_clean_cache();
$this->rootID = $rootID; $this->rootID = $rootID;
$newItems = $this->getItems(); $newItems = $this->getItems();
$this->processAgents($newItems, $server); $this->processAgents($newItems, $server);
$items = array_merge($items, $newItems); $items = array_merge($items, $newItems);
metaconsole_restore_db(); metaconsole_restore_db();
} }
$this->rootID = $rootIDs; $this->rootID = $rootIDs;
if (!empty($items)) if (!empty($items))
usort($items, array("Tree", "cmpSortNames")); usort($items, array("Tree", "cmpSortNames"));
$processed_items = $items; $processed_items = $items;
} }
} }
$this->tree = $processed_items; $this->tree = $processed_items;
} }
private function getDataModuleGroup() { private function getDataModuleGroup() {
$processed_items = array(); $processed_items = array();
// Module groups // Module groups
if ($this->id == -1) { if ($this->id == -1) {
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
$items = $this->getItems(); $items = $this->getItems();
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
$counters = $this->getCounters($item['id']); $counters = $this->getCounters($item['id']);
if (!empty($counters)) { if (!empty($counters)) {
foreach ($counters as $type => $value) { foreach ($counters as $type => $value) {
$item[$type] = $value; $item[$type] = $value;
} }
} }
$processed_item = $this->getProcessedItem($item); $processed_item = $this->getProcessedItem($item);
$processed_items[] = $processed_item; $processed_items[] = $processed_item;
} }
} }
else { else {
$servers = metaconsole_get_servers(); $servers = metaconsole_get_servers();
$item_list = array(); $item_list = array();
foreach ($servers as $server) { foreach ($servers as $server) {
if (metaconsole_connect($server) != NOERR) if (metaconsole_connect($server) != NOERR)
continue; continue;
db_clean_cache(); db_clean_cache();
$items = $this->getItems(); $items = $this->getItems();
$processed_items = array(); $processed_items = array();
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
$counters = $this->getCounters($item['id']); $counters = $this->getCounters($item['id']);
if (!empty($counters)) { if (!empty($counters)) {
foreach ($counters as $type => $value) { foreach ($counters as $type => $value) {
$item[$type] = $value; $item[$type] = $value;
} }
} }
$processed_item = $this->getProcessedItem($item, $server); $processed_item = $this->getProcessedItem($item, $server);
$processed_items[] = $processed_item; $processed_items[] = $processed_item;
} }
$item_list = array_merge($item_list, $processed_items); $item_list = array_merge($item_list, $processed_items);
metaconsole_restore_db(); metaconsole_restore_db();
} }
$processed_items = $this->getMergedItems($item_list); $processed_items = $this->getMergedItems($item_list);
} }
} }
@ -1969,50 +1971,50 @@ class Tree {
} }
else { else {
$rootIDs = $this->rootID; $rootIDs = $this->rootID;
$items = array(); $items = array();
foreach ($rootIDs as $serverID => $rootID) { foreach ($rootIDs as $serverID => $rootID) {
$server = metaconsole_get_servers($serverID); $server = metaconsole_get_servers($serverID);
if (metaconsole_connect($server) != NOERR) if (metaconsole_connect($server) != NOERR)
continue; continue;
db_clean_cache(); db_clean_cache();
$this->rootID = $rootID; $this->rootID = $rootID;
$newItems = $this->getItems(); $newItems = $this->getItems();
$this->processAgents($newItems, $server); $this->processAgents($newItems, $server);
$items = array_merge($items, $newItems); $items = array_merge($items, $newItems);
metaconsole_restore_db(); metaconsole_restore_db();
} }
$this->rootID = $rootIDs; $this->rootID = $rootIDs;
if (!empty($items)) if (!empty($items))
usort($items, array("Tree", "cmpSortNames")); usort($items, array("Tree", "cmpSortNames"));
$processed_items = $items; $processed_items = $items;
} }
} }
$this->tree = $processed_items; $this->tree = $processed_items;
} }
private function getDataOS() { private function getDataOS() {
$processed_items = array(); $processed_items = array();
// OS // OS
if ($this->id == -1) { if ($this->id == -1) {
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
$items = $this->getItems(); $items = $this->getItems();
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
$counters = $this->getCounters($item['id']); $counters = $this->getCounters($item['id']);
if (!empty($counters)) { if (!empty($counters)) {
foreach ($counters as $type => $value) { foreach ($counters as $type => $value) {
$item[$type] = $value; $item[$type] = $value;
} }
} }
$processed_item = $this->getProcessedItem($item); $processed_item = $this->getProcessedItem($item);
$processed_item['icon'] = $item['os_icon']; $processed_item['icon'] = $item['os_icon'];
$processed_items[] = $processed_item; $processed_items[] = $processed_item;
@ -2020,34 +2022,34 @@ class Tree {
} }
else { else {
$servers = metaconsole_get_servers(); $servers = metaconsole_get_servers();
$item_list = array(); $item_list = array();
foreach ($servers as $server) { foreach ($servers as $server) {
if (metaconsole_connect($server) != NOERR) if (metaconsole_connect($server) != NOERR)
continue; continue;
db_clean_cache(); db_clean_cache();
$items = $this->getItems(); $items = $this->getItems();
$processed_items = array(); $processed_items = array();
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
$counters = $this->getCounters($item['id']); $counters = $this->getCounters($item['id']);
if (!empty($counters)) { if (!empty($counters)) {
foreach ($counters as $type => $value) { foreach ($counters as $type => $value) {
$item[$type] = $value; $item[$type] = $value;
} }
} }
$processed_item = $this->getProcessedItem($item, $server); $processed_item = $this->getProcessedItem($item, $server);
$processed_item['icon'] = $item['os_icon']; $processed_item['icon'] = $item['os_icon'];
$processed_items[] = $processed_item; $processed_items[] = $processed_item;
} }
$item_list = array_merge($item_list, $processed_items); $item_list = array_merge($item_list, $processed_items);
metaconsole_restore_db(); metaconsole_restore_db();
} }
$processed_items = $this->getMergedItems($item_list); $processed_items = $this->getMergedItems($item_list);
} }
} }
@ -2060,30 +2062,30 @@ class Tree {
} }
else { else {
$rootIDs = $this->rootID; $rootIDs = $this->rootID;
$items = array(); $items = array();
foreach ($rootIDs as $serverID => $rootID) { foreach ($rootIDs as $serverID => $rootID) {
$server = metaconsole_get_servers($serverID); $server = metaconsole_get_servers($serverID);
if (metaconsole_connect($server) != NOERR) if (metaconsole_connect($server) != NOERR)
continue; continue;
db_clean_cache(); db_clean_cache();
$this->rootID = $rootID; $this->rootID = $rootID;
$newItems = $this->getItems(); $newItems = $this->getItems();
$this->processAgents($newItems, $server); $this->processAgents($newItems, $server);
$items = array_merge($items, $newItems); $items = array_merge($items, $newItems);
metaconsole_restore_db(); metaconsole_restore_db();
} }
$this->rootID = $rootIDs; $this->rootID = $rootIDs;
if (!empty($items)) if (!empty($items))
usort($items, array("Tree", "cmpSortNames")); usort($items, array("Tree", "cmpSortNames"));
$processed_items = $items; $processed_items = $items;
} }
} }
$this->tree = $processed_items; $this->tree = $processed_items;
} }

View File

@ -217,47 +217,47 @@ define('VISUAL_MAP_WIZARD_PARENTS_AGENT_RELANTIONSHIP', 2);
/* Service constants */ /* Service constants */
//Status //Status
define('SERVICE_STATUS_UNKNOWN', -1); define('SERVICE_STATUS_UNKNOWN', -1);
define('SERVICE_STATUS_NORMAL', 0); define('SERVICE_STATUS_NORMAL', 0);
define('SERVICE_STATUS_CRITICAL', 1); define('SERVICE_STATUS_CRITICAL', 1);
define('SERVICE_STATUS_WARNING', 2); define('SERVICE_STATUS_WARNING', 2);
define('SERVICE_STATUS_ALERT', 4); define('SERVICE_STATUS_ALERT', 4);
//Default weights //Default weights
define('SERVICE_WEIGHT_CRITICAL', 1); define('SERVICE_WEIGHT_CRITICAL', 1);
define('SERVICE_WEIGHT_WARNING', 0.5); define('SERVICE_WEIGHT_WARNING', 0.5);
define('SERVICE_ELEMENT_WEIGHT_CRITICAL', 1); define('SERVICE_ELEMENT_WEIGHT_CRITICAL', 1);
define('SERVICE_ELEMENT_WEIGHT_WARNING', 0.5); define('SERVICE_ELEMENT_WEIGHT_WARNING', 0.5);
define('SERVICE_ELEMENT_WEIGHT_OK', 0); define('SERVICE_ELEMENT_WEIGHT_OK', 0);
define('SERVICE_ELEMENT_WEIGHT_UNKNOWN', 0); define('SERVICE_ELEMENT_WEIGHT_UNKNOWN', 0);
//Modes //Modes
define('SERVICE_MODE_MANUAL', 0); define('SERVICE_MODE_MANUAL', 0);
define('SERVICE_MODE_AUTO', 1); define('SERVICE_MODE_AUTO', 1);
define('SERVICE_MODE_SIMPLE', 2); define('SERVICE_MODE_SIMPLE', 2);
/* Status images */ /* Status images */
//For modules //For modules
define ('STATUS_MODULE_OK', 'module_ok.png'); define ('STATUS_MODULE_OK', 'module_ok.png');
define ('STATUS_MODULE_CRITICAL', 'module_critical.png'); define ('STATUS_MODULE_CRITICAL', 'module_critical.png');
define ('STATUS_MODULE_WARNING', 'module_warning.png'); define ('STATUS_MODULE_WARNING', 'module_warning.png');
define ('STATUS_MODULE_NO_DATA', 'module_no_data.png'); define ('STATUS_MODULE_NO_DATA', 'module_no_data.png');
define ('STATUS_MODULE_UNKNOWN', 'module_unknown.png'); define ('STATUS_MODULE_UNKNOWN', 'module_unknown.png');
//For agents //For agents
define ('STATUS_AGENT_CRITICAL', 'agent_critical.png'); define ('STATUS_AGENT_CRITICAL', 'agent_critical.png');
define ('STATUS_AGENT_WARNING', 'agent_warning.png'); define ('STATUS_AGENT_WARNING', 'agent_warning.png');
define ('STATUS_AGENT_DOWN', 'agent_down.png'); define ('STATUS_AGENT_DOWN', 'agent_down.png');
define ('STATUS_AGENT_UNKNOWN', 'agent_unknown.png'); define ('STATUS_AGENT_UNKNOWN', 'agent_unknown.png');
define ('STATUS_AGENT_OK', 'agent_ok.png'); define ('STATUS_AGENT_OK', 'agent_ok.png');
define ('STATUS_AGENT_NO_DATA', 'agent_no_data.png'); define ('STATUS_AGENT_NO_DATA', 'agent_no_data.png');
define ('STATUS_AGENT_NO_MONITORS', 'agent_no_monitors.png'); define ('STATUS_AGENT_NO_MONITORS', 'agent_no_monitors.png');
define ('STATUS_AGENT_NOT_INIT', 'agent_notinit.png'); define ('STATUS_AGENT_NOT_INIT', 'agent_notinit.png');
//For alerts //For alerts
define ('STATUS_ALERT_FIRED', 'alert_fired.png'); define ('STATUS_ALERT_FIRED', 'alert_fired.png');
define ('STATUS_ALERT_NOT_FIRED', 'alert_not_fired.png'); define ('STATUS_ALERT_NOT_FIRED', 'alert_not_fired.png');
define ('STATUS_ALERT_DISABLED', 'alert_disabled.png'); define ('STATUS_ALERT_DISABLED', 'alert_disabled.png');
//For servers //For servers
define ('STATUS_SERVER_OK', 'server_ok.png'); define ('STATUS_SERVER_OK', 'server_ok.png');
define ('STATUS_SERVER_DOWN', 'server_down.png'); define ('STATUS_SERVER_DOWN', 'server_down.png');
/* Status images (ball) */ /* Status images (ball) */

View File

@ -1374,7 +1374,7 @@ function oracle_get_system_time() {
return $time; return $time;
if ($config["timesource"] == "sql") { if ($config["timesource"] == "sql") {
$time = db_get_sql ("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) as dt FROM dual"); $time = db_get_sql ("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) as dt FROM dual");
if (empty ($time)) { if (empty ($time)) {
return time (); return time ();
} }

View File

@ -399,10 +399,6 @@ function set_user_language() {
*/ */
function human_time_description_raw ($seconds, $exactly = false, $units = 'large') { function human_time_description_raw ($seconds, $exactly = false, $units = 'large') {
//Miguel: I think that I can kill this unicorns and magical numbers
// because this function may call without loaded the
// constants.php file.
switch ($units) { switch ($units) {
case 'large': case 'large':
$secondsString = __('seconds'); $secondsString = __('seconds');
@ -434,44 +430,44 @@ function human_time_description_raw ($seconds, $exactly = false, $units = 'large
if ($exactly) { if ($exactly) {
$returnDate = ''; $returnDate = '';
$years = floor($seconds / 31104000); $years = floor($seconds / SECONDS_1YEAR);
if ($years != 0) { if ($years != 0) {
$seconds = $seconds - ($years * 31104000); $seconds = $seconds - ($years * SECONDS_1YEAR);
$returnDate .= "$years $yearsString "; $returnDate .= "$years $yearsString ";
} }
$months = floor($seconds / 2592000); $months = floor($seconds / SECONDS_1MONTH);
if ($months != 0) { if ($months != 0) {
$seconds = $seconds - ($months * 2592000); $seconds = $seconds - ($months * SECONDS_1MONTH);
$returnDate .= "$months $monthsString "; $returnDate .= "$months $monthsString ";
} }
$days = floor($seconds / 86400); $days = floor($seconds / SECONDS_1DAY);
if ($days != 0) { if ($days != 0) {
$seconds = $seconds - ($days * 86400); $seconds = $seconds - ($days * SECONDS_1DAY);
$returnDate .= "$days $daysString "; $returnDate .= "$days $daysString ";
} }
$returnTime = ''; $returnTime = '';
$hours = floor($seconds / 3600); $hours = floor($seconds / SECONDS_1HOUR);
if ($hours != 0) { if ($hours != 0) {
$seconds = $seconds - ($hours * 3600); $seconds = $seconds - ($hours * SECONDS_1HOUR);
$returnTime .= "$hours $hoursString "; $returnTime .= "$hours $hoursString ";
} }
$mins = floor($seconds / 60); $mins = floor($seconds / SECONDS_1MINUTE);
if ($mins != 0) { if ($mins != 0) {
$seconds = $seconds - ($mins * 60); $seconds = $seconds - ($mins * SECONDS_1MINUTE);
if ($hours == 0) { if ($hours == 0) {
$returnTime .= "$mins $minutesString "; $returnTime .= "$mins $minutesString ";
@ -512,26 +508,26 @@ function human_time_description_raw ($seconds, $exactly = false, $units = 'large
} }
if ($seconds < 60) if ($seconds < SECONDS_1MINUTE)
return format_numeric ($seconds, 0)." " . $secondsString; return format_numeric ($seconds, 0)." " . $secondsString;
if ($seconds < 3600) { if ($seconds < SECONDS_1HOUR) {
$minutes = floor($seconds / 60); $minutes = floor($seconds / 60);
$seconds = $seconds % 60; $seconds = $seconds % SECONDS_1MINUTE;
if ($seconds == 0) if ($seconds == 0)
return $minutes.' ' . $minutesString; return $minutes.' ' . $minutesString;
$seconds = sprintf ("%02d", $seconds); $seconds = sprintf ("%02d", $seconds);
return $minutes.' '. $minutesString . ' ' .$seconds.' ' . $secondsString; return $minutes.' '. $minutesString . ' ' .$seconds.' ' . $secondsString;
} }
if ($seconds < 86400) if ($seconds < SECONDS_1DAY)
return format_numeric ($seconds / 3600, 0)." " . $hoursString; return format_numeric ($seconds / SECONDS_1HOUR, 0)." " . $hoursString;
if ($seconds < 2592000) if ($seconds < SECONDS_1MONTH)
return format_numeric ($seconds / 86400, 0) . " " . $daysString; return format_numeric ($seconds / SECONDS_1DAY, 0) . " " . $daysString;
if ($seconds < 15552000) if ($seconds < SECONDS_6MONTHS)
return format_numeric ($seconds / 2592000, 0)." ". $monthsString; return format_numeric ($seconds / SECONDS_1MONTH, 0)." ". $monthsString;
return "+6 " . $monthsString; return "+6 " . $monthsString;
} }
@ -578,44 +574,44 @@ function human_time_description_alerts ($seconds, $exactly = false, $units = 'ti
if ($exactly) { if ($exactly) {
$returnDate = ''; $returnDate = '';
$years = floor($seconds / 31104000); $years = floor($seconds / SECONDS_1YEAR);
if ($years != 0) { if ($years != 0) {
$seconds = $seconds - ($years * 31104000); $seconds = $seconds - ($years * SECONDS_1YEAR);
$returnDate .= "$years $yearsString "; $returnDate .= "$years $yearsString ";
} }
$months = floor($seconds / 2592000); $months = floor($seconds / SECONDS_1MONTH);
if ($months != 0) { if ($months != 0) {
$seconds = $seconds - ($months * 2592000); $seconds = $seconds - ($months * SECONDS_1MONTH);
$returnDate .= "$months $monthsString "; $returnDate .= "$months $monthsString ";
} }
$days = floor($seconds / 86400); $days = floor($seconds / SECONDS_1DAY);
if ($days != 0) { if ($days != 0) {
$seconds = $seconds - ($days * 86400); $seconds = $seconds - ($days * SECONDS_1DAY);
$returnDate .= "$days $daysString "; $returnDate .= "$days $daysString ";
} }
$returnTime = ''; $returnTime = '';
$hours = floor($seconds / 3600); $hours = floor($seconds / SECONDS_1HOUR);
if ($hours != 0) { if ($hours != 0) {
$seconds = $seconds - ($hours * 3600); $seconds = $seconds - ($hours * SECONDS_1HOUR);
$returnTime .= "$hours $hoursString "; $returnTime .= "$hours $hoursString ";
} }
$mins = floor($seconds / 60); $mins = floor($seconds / SECONDS_1MINUTE);
if ($mins != 0) { if ($mins != 0) {
$seconds = $seconds - ($mins * 60); $seconds = $seconds - ($mins * SECONDS_1MINUTE);
if ($hours == 0) { if ($hours == 0) {
$returnTime .= "$mins $minutesString "; $returnTime .= "$mins $minutesString ";
@ -659,23 +655,23 @@ function human_time_description_alerts ($seconds, $exactly = false, $units = 'ti
if ($seconds < 60) if ($seconds < 60)
return format_numeric ($seconds, 0)." " . $secondsString; return format_numeric ($seconds, 0)." " . $secondsString;
if ($seconds < 3600) { if ($seconds < SECONDS_1HOUR) {
$minutes = floor($seconds / 60); $minutes = floor($seconds / SECONDS_1MINUTE);
$seconds = $seconds % 60; $seconds = $seconds % SECONDS_1MINUTE;
if ($seconds == 0) if ($seconds == 0)
return $minutes.' ' . $minutesString; return $minutes.' ' . $minutesString;
$seconds = sprintf ("%02d", $seconds); $seconds = sprintf ("%02d", $seconds);
return $minutes.' '. $minutesString . ' ' .$seconds.' ' . $secondsString; return $minutes.' '. $minutesString . ' ' .$seconds.' ' . $secondsString;
} }
if ($seconds < 86400) if ($seconds < SECONDS_1DAY)
return format_numeric ($seconds / 3600, 0)." " . $hoursString; return format_numeric ($seconds / SECONDS_1HOUR, 0)." " . $hoursString;
if ($seconds < 2592000) if ($seconds < SECONDS_1MONTH)
return format_numeric ($seconds / 86400, 0) . " " . $daysString; return format_numeric ($seconds / SECONDS_1DAY, 0) . " " . $daysString;
if ($seconds < 15552000) if ($seconds < SECONDS_6MONTHS)
return format_numeric ($seconds / 2592000, 0)." ". $monthsString; return format_numeric ($seconds / SECONDS_1MONTH, 0)." ". $monthsString;
return "+6 " . $monthsString; return "+6 " . $monthsString;
} }

View File

@ -1637,7 +1637,7 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
$status = db_get_value_filter ('count(*)', $status = db_get_value_filter ('count(*)',
'tagente', 'tagente',
array ('id_agente' => (int) $id_agent, array ('id_agente' => (int) $id_agent,
'ceil((to_date(ultimo_contacto, \'YYYY-MM-DD HH24:MI:SS\') - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)) > ' . $time)); 'ceil((to_date(ultimo_contacto, \'YYYY-MM-DD HH24:MI:SS\') - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (' . SECONDS_1DAY . ')) > ' . $time));
break; break;
} }

View File

@ -60,17 +60,17 @@ function cron_next_execution ($cron) {
} }
// Move to the next day of the month // Move to the next day of the month
$nex_time_wd += 86400; $nex_time_wd += SECONDS_1DAY;
list ($nex_mon_wd, $nex_wday) = explode (" ", date ("m w", $nex_time_wd)); list ($nex_mon_wd, $nex_wday) = explode (" ", date ("m w", $nex_time_wd));
} }
while ($mday == '*' && $nex_mon_wd == $nex_mon); while ($mday == '*' && $nex_mon_wd == $nex_mon);
$count++; $count++;
} }
while ($count < 60); while ($count < SECONDS_1MINUTE);
// Something went wrong, default to 5 minutes // Something went wrong, default to 5 minutes
return 300; return SECONDS_5MINUTES;
} }
// Get the next execution date for the given cron entry in seconds since epoch. // Get the next execution date for the given cron entry in seconds since epoch.
@ -134,13 +134,13 @@ function cron_next_execution_date ($cron, $cur_time = false) {
return $next_time; return $next_time;
} }
if ($min == '*' && $hour == '*' && $wday == '*' && $mday == '*' && $mon == '*') { if ($min == '*' && $hour == '*' && $wday == '*' && $mday == '*' && $mon == '*') {
list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + 60)); list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + SECONDS_1MINUTE));
} }
else if ($hour == '*' && $wday == '*' && $mday == '*' && $mon == '*') { else if ($hour == '*' && $wday == '*' && $mday == '*' && $mon == '*') {
list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + 3600)); list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + SECONDS_1HOUR));
} }
else if ($mday == '*' && $mon == '*') { else if ($mday == '*' && $mon == '*') {
list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + 86400)); list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + SECONDS_1DAY));
} }
else if ($mon == '*') { else if ($mon == '*') {
$nex_mon = $nex_mon + 1; $nex_mon = $nex_mon + 1;
@ -154,10 +154,10 @@ function cron_next_execution_date ($cron, $cur_time = false) {
} }
$count++; $count++;
} }
while ($count < 86400); while ($count < SECONDS_1DAY);
// Something went wrong, default to 5 minutes // Something went wrong, default to 5 minutes
return $cur_time + 300; return $cur_time + SECONDS_5MINUTES;
} }
?> ?>

View File

@ -734,7 +734,7 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0,
unknown_instructions, source, tags, custom_data, unknown_instructions, source, tags, custom_data,
server_id) server_id)
VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d, VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d,
ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)), ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (' . SECONDS_1DAY . ')),
"%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s",
"%s", "%s", %d)', "%s", "%s", %d)',
$id_agent, $id_group, $event, $status, $id_user, $id_agent, $id_group, $event, $status, $id_user,
@ -786,7 +786,7 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0,
critical_instructions, warning_instructions, critical_instructions, warning_instructions,
unknown_instructions, source, tags, custom_data) unknown_instructions, source, tags, custom_data)
VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d, VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d,
ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)), ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (' . SECONDS_1DAY . ')),
"%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s",
"%s", "%s")', "%s", "%s")',
$id_agent, $id_group, $event, $status, $id_user, $id_agent, $id_group, $event, $status, $id_user,
@ -2035,7 +2035,14 @@ function events_page_details ($event, $server = "") {
if (isset($module["module_name"])) { if (isset($module["module_name"])) {
$module_module_name = $module["module_name"]; $module_module_name = $module["module_name"];
} }
$link ="winopeng('" . $serverstring . "operation/agentes/stat_win.php?type=" . $graph_type."&period=86400&id=" . $module["id_agente_modulo"] . "&label=" . rawurlencode(urlencode(base64_encode($module_module_name))) . $hashstring . "&refresh=600','day_".$win_handle."')"; $link ="winopeng('" . $serverstring .
"operation/agentes/stat_win.php?type=" . $graph_type."&" .
"period=" . SECONDS_1DAY . "&" .
"id=" . $module["id_agente_modulo"] . "&" .
"label=" . rawurlencode(
urlencode(
base64_encode($module_module_name))) . $hashstring . "&" .
"refresh=" . SECONDS_10MINUTES . "','day_".$win_handle."')";
$data[1] = '<a href="javascript:'.$link.'">'; $data[1] = '<a href="javascript:'.$link.'">';
$data[1] .= html_print_image('images/chart_curve.png',true); $data[1] .= html_print_image('images/chart_curve.png',true);

View File

@ -604,7 +604,7 @@ function gis_add_path($layerName, $idAgent, $lastPosition = null, $history_time
$where = 'start_timestamp >= to_timestamp(ceil(date_part("epoch", CURRENT_TIMESTAMP)) - ' . $history_time . ')'; $where = 'start_timestamp >= to_timestamp(ceil(date_part("epoch", CURRENT_TIMESTAMP)) - ' . $history_time . ')';
break; break;
case "oracle": case "oracle":
$where = 'start_timestamp >= to_timestamp(\'01-01-1970 00:00:00\', \'DD-MM-YYYY HH24:MI:SS\') + NUMTODSINTERVAL((ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)) - ' . $history_time . '),\'SECOND\')'; $where = 'start_timestamp >= to_timestamp(\'01-01-1970 00:00:00\', \'DD-MM-YYYY HH24:MI:SS\') + NUMTODSINTERVAL((ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (' . SECONDS_1DAY . ')) - ' . $history_time . '),\'SECOND\')';
break; break;
} }
} }
@ -938,7 +938,7 @@ function gis_get_conection_conf($idConnection) {
* *
* @return boolean True ok and false fail. * @return boolean True ok and false fail.
*/ */
function gis_get_agent_map($agent_id, $heigth, $width, $show_history = false, $centerInAgent = true, $history_time = 86400) { function gis_get_agent_map($agent_id, $heigth, $width, $show_history = false, $centerInAgent = true, $history_time = SECONDS_1DAY) {
$defaultMap = db_get_all_rows_sql(" $defaultMap = db_get_all_rows_sql("
SELECT t1.*, t3.conection_name, t3.connection_type, SELECT t1.*, t3.conection_name, t3.connection_type,
t3.conection_data, t3.num_zoom_levels t3.conection_data, t3.num_zoom_levels

View File

@ -523,9 +523,9 @@ function servers_get_info ($id_server = -1) {
$server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]);
break; break;
case "oracle": case "oracle":
$server["lag"] = db_get_sql ("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp from trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); $server["lag"] = db_get_sql ("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp from trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]);
$server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]);
break; break;
} }
} }
@ -566,7 +566,7 @@ function servers_get_info ($id_server = -1) {
AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > current_interval"); AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > current_interval");
break; break;
case "oracle": case "oracle":
$result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente
WHERE utimestamp > 0 WHERE utimestamp > 0
AND tagente.disabled = 0 AND tagente.disabled = 0
AND tagente.id_agente = tagente_estado.id_agente AND tagente.id_agente = tagente_estado.id_agente
@ -574,8 +574,8 @@ function servers_get_info ($id_server = -1) {
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND current_interval > 0 AND current_interval > 0
AND running_by = ".$server["id_server"]." AND running_by = ".$server["id_server"]."
AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp) < ( current_interval * 10) AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp) < ( current_interval * 10)
AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) - utimestamp) * (86400)) > current_interval"); AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) - utimestamp) * (" . SECONDS_1DAY . ")) > current_interval");
break; break;
} }
} }
@ -609,7 +609,7 @@ function servers_get_info ($id_server = -1) {
AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > (current_interval * 1.1)"); AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > (current_interval * 1.1)");
break; break;
case "oracle": case "oracle":
$result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente
WHERE utimestamp > 0 WHERE utimestamp > 0
AND tagente.disabled = 0 AND tagente.disabled = 0
AND tagente.id_agente = tagente_estado.id_agente AND tagente.id_agente = tagente_estado.id_agente
@ -617,9 +617,9 @@ function servers_get_info ($id_server = -1) {
AND tagente_modulo.id_tipo_modulo < 5 AND tagente_modulo.id_tipo_modulo < 5
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND current_interval > 0 AND current_interval > 0
AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp) < ( current_interval * 10) AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp) < ( current_interval * 10)
AND running_by = ".$server["id_server"]." AND running_by = ".$server["id_server"]."
AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp) > (current_interval * 1.1)"); AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp) > (current_interval * 1.1)");
break; break;
} }
} }

View File

@ -506,25 +506,27 @@ function treeview_printTable($id_agente, $server_data = array()) {
// Blank space below title, DONT remove this, this // Blank space below title, DONT remove this, this
// Breaks the layout when Flash charts are enabled :-o // Breaks the layout when Flash charts are enabled :-o
//echo '<div id="id_div" style="height: 10px">&nbsp;</div>'; //echo '<div id="id_div" style="height: 10px">&nbsp;</div>';
if ($config["agentaccess"]) { if ($config["agentaccess"]) {
$access_graph = '<div style="margin-left: 10px;">'; $access_graph = '<div style="margin-left: 10px;">';
$access_graph .= graphic_agentaccess($id_agente, 290, 110, 86400, true); $access_graph .= graphic_agentaccess($id_agente, 290, 110,
SECONDS_1DAY, true);
$access_graph .= '</div><br>'; $access_graph .= '</div><br>';
ui_toggle($access_graph, __('Agent access rate (24h)')); ui_toggle($access_graph, __('Agent access rate (24h)'));
} }
$events_graph = '<div style="margin-left: 10px;">'; $events_graph = '<div style="margin-left: 10px;">';
$events_graph .= graph_graphic_agentevents ($id_agente, 290, 15, 86400, '', true); $events_graph .= graph_graphic_agentevents ($id_agente, 290, 15,
SECONDS_1DAY, '', true);
$events_graph .= '</div><br>'; $events_graph .= '</div><br>';
ui_toggle($events_graph, __('Events (24h)')); ui_toggle($events_graph, __('Events (24h)'));
// Table network interfaces // Table network interfaces
$network_interfaces_by_agents = agents_get_network_interfaces(array($agent)); $network_interfaces_by_agents = agents_get_network_interfaces(array($agent));
$network_interfaces = array(); $network_interfaces = array();
if (!empty($network_interfaces_by_agents) && !empty($network_interfaces_by_agents[$id_agente])) { if (!empty($network_interfaces_by_agents) && !empty($network_interfaces_by_agents[$id_agente])) {
$network_interfaces = $network_interfaces_by_agents[$id_agente]['interfaces']; $network_interfaces = $network_interfaces_by_agents[$id_agente]['interfaces'];
@ -1604,89 +1606,3 @@ function treeview_getSecondBranchSQL ($fatherType, $id, $id_father) {
return $sql; return $sql;
} }
?> ?>
<script language="javascript" type="text/javascript">
$(document).ready (function () {
/*
module_id = $('#text-id_module').val();
id_agent = $('#text-id_agent').val();
server_name = $('#text-server_name').val();
$("#submit-upd_button").click( function() {
show_module_detail_dialog(module_id, id_agent, server_name, 0, 86400);
});
$("#submit-updbutton_period").click( function() {
//refresh_period_callback();
var period = $('#period').val();
console.log(period);
show_module_detail_dialog(module_id, id_agent, server_name, 0, period);
});
*/
});
/*
// Show the modal window of an module
function show_module_detail_dialog(module_id, id_agent, server_name, offset, period) {
$.ajax({
type: "POST",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
data: "page=include/ajax/module&get_module_detail=1&server_name="+server_name+"&id_agent="+id_agent+"&id_module=" + module_id+"&offset="+offset+"&period="+period,
dataType: "html",
success: function(data){
$("#module_details_window").hide ()
.empty ()
.append (data)
.dialog ({
resizable: true,
draggable: true,
modal: true,
overlay: {
opacity: 0.5,
background: "black"
},
width: 620,
height: 500
})
.show ();
refresh_pagination_callback ();
}
});
}
function refresh_pagination_callback () {
$(".pagination").click( function() {
var classes = $(this).attr('class');
classes = classes.split(' ');
var offset_class = classes[1];
offset_class = offset_class.split('_');
var offset = offset_class[1];
var period = $('#period').val();
//console.log(period);
show_module_detail_dialog(module_id, id_agent, server_name, offset, period);
return false;
});
}
function refresh_period_callback () {
$("#submit-updbutton_period").click( function() {
var period = $('#period').val();
console.log(period);
show_module_detail_dialog(module_id, id_agent, server_name, 0, period);
return false;
});
}
*/
</script>

View File

@ -77,7 +77,7 @@ class Agent {
$agent_id = $system->getRequest('agent_id', '0'); $agent_id = $system->getRequest('agent_id', '0');
$width = $system->getRequest('width', '400'); $width = $system->getRequest('width', '400');
graph_graphic_agentevents( graph_graphic_agentevents(
$this->id, $width, 30, 86400, ui_get_full_url(false)); $this->id, $width, 30, SECONDS_1DAY, ui_get_full_url(false));
exit; exit;
} }
} }

View File

@ -23,7 +23,7 @@ check_login();
require_once('include/functions_modules.php'); require_once('include/functions_modules.php');
$module_id = get_parameter_get ("id", 0); $module_id = get_parameter_get ("id", 0);
$period = get_parameter ("period", 86400); $period = get_parameter ("period", SECONDS_1DAY);
$group = agents_get_agentmodule_group ($module_id); $group = agents_get_agentmodule_group ($module_id);
$agentId = get_parameter("id_agente"); $agentId = get_parameter("id_agente");
$freestring = get_parameter ("freestring"); $freestring = get_parameter ("freestring");

View File

@ -471,14 +471,15 @@ $table->style = array_fill(0, 3, 'vertical-align: top;');
$data = array(); $data = array();
$data[0] = html_print_table($table_agent, true); $data[0] = html_print_table($table_agent, true);
$data[0] .= '<fieldset class="databox" style="position: static;"> $data[0] .=
<legend style="text-align:left; color: #666;">' . '<fieldset class="databox" style="position: static;">
__('Events (24h)') . <legend style="text-align:left; color: #666;">' .
'</legend>' . __('Events (24h)') .
'<div style="margin: auto; text-align:center; width: 300px;">' . '</legend>' .
graph_graphic_agentevents ($id_agente, 300, 15, 86400, '', true) . '<div style="margin: auto; text-align:center; width: 300px;">' .
'</div>' . graph_graphic_agentevents ($id_agente, 300, 15, SECONDS_1DAY, '', true) .
'</fieldset>'; '</div>' .
'</fieldset>';
// ACCESS RATE GRAPH // ACCESS RATE GRAPH
$access_agent = db_get_value_sql("SELECT COUNT(id_agent) $access_agent = db_get_value_sql("SELECT COUNT(id_agent)
@ -486,14 +487,15 @@ $access_agent = db_get_value_sql("SELECT COUNT(id_agent)
WHERE id_agent = " . $id_agente); WHERE id_agent = " . $id_agente);
if ($config["agentaccess"] && $access_agent > 0) { if ($config["agentaccess"] && $access_agent > 0) {
$data[0] .= '<fieldset class="databox" style="position: static;"> $data[0] .=
<legend style="text-align:left; color: #666;">' . '<fieldset class="databox" style="position: static;">
__('Agent access rate (24h)') . <legend style="text-align:left; color: #666;">' .
'</legend>' . __('Agent access rate (24h)') .
'<div style="margin: auto; text-align:center; width: 300px;">' . '</legend>' .
graphic_agentaccess($id_agente, 300, 100, 86400, true) . '<div style="margin: auto; text-align:center; width: 300px;">' .
'</div>' . graphic_agentaccess($id_agente, 300, 100, SECONDS_1DAY, true) .
'</fieldset>'; '</div>' .
'</fieldset>';
} }
$data[1] = html_print_table($table_contact, true); $data[1] = html_print_table($table_contact, true);

View File

@ -299,15 +299,19 @@ if (empty($export_btn) || $show_form) {
//Start date selector //Start date selector
$table->data[3][0] = '<b>'.__('Begin date').'</b>'; $table->data[3][0] = '<b>'.__('Begin date').'</b>';
$table->data[3][1] = html_print_input_text ('start_date', date ("Y-m-d", get_system_time () - 86400), false, 10, 10, true); $table->data[3][1] = html_print_input_text ('start_date',
date ("Y-m-d", get_system_time () - SECONDS_1DAY), false, 10, 10, true);
$table->data[3][1] .= html_print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => "scwShow(scwID('text-start_date'),this);")); $table->data[3][1] .= html_print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => "scwShow(scwID('text-start_date'),this);"));
$table->data[3][1] .= html_print_input_text ('start_time', date ("H:i", get_system_time () - 86400), false, 10, 5, true); $table->data[3][1] .= html_print_input_text ('start_time',
date ("H:i", get_system_time () - SECONDS_1DAY), false, 10, 5, true);
//End date selector //End date selector
$table->data[4][0] = '<b>'.__('End date').'</b>'; $table->data[4][0] = '<b>'.__('End date').'</b>';
$table->data[4][1] = html_print_input_text ('end_date', date ("Y-m-d", get_system_time ()), false, 10, 10, true); $table->data[4][1] = html_print_input_text ('end_date',
date ("Y-m-d", get_system_time ()), false, 10, 10, true);
$table->data[4][1] .= html_print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => "scwShow(scwID('text-end_date'),this);")); $table->data[4][1] .= html_print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => "scwShow(scwID('text-end_date'),this);"));
$table->data[4][1] .= html_print_input_text ('end_time', date ("H:i", get_system_time ()), false, 10, 5, true); $table->data[4][1] .= html_print_input_text ('end_time',
date ("H:i", get_system_time ()), false, 10, 5, true);
//Export type //Export type
$table->data[5][0] = '<b>'.__('Export type').'</b>'; $table->data[5][0] = '<b>'.__('Export type').'</b>';

View File

@ -31,7 +31,7 @@ require_once ($config['homedir'].'/include/functions_agents.php');
ui_require_javascript_file('openlayers.pandora'); ui_require_javascript_file('openlayers.pandora');
/* Get the parameters */ /* Get the parameters */
$period = (int)get_parameter ("period", 86400); $period = (int)get_parameter ("period", SECONDS_1DAY);
$agentId = (int)get_parameter('id_agente'); $agentId = (int)get_parameter('id_agente');
$agent_name = agents_get_name($id_agente); $agent_name = agents_get_name($id_agente);
$agentData = gis_get_data_last_position_agent($id_agente); $agentData = gis_get_data_last_position_agent($id_agente);
@ -74,7 +74,7 @@ switch ($config["dbtype"]) {
break; break;
case "oracle": case "oracle":
$timestampLastOperation = db_get_value_sql( $timestampLastOperation = db_get_value_sql(
"SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) from dual"); "SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) from dual");
break; break;
} }

View File

@ -115,7 +115,7 @@ $label = base64_decode(get_parameter('label', ''));
if ($show_other) { if ($show_other) {
$avg_only = 0; $avg_only = 0;
} }
$period = get_parameter ("period", 86400); $period = get_parameter ("period", SECONDS_1DAY);
$id = get_parameter ("id", 0); $id = get_parameter ("id", 0);
$width = get_parameter ("width", 555); $width = get_parameter ("width", 555);
$height = get_parameter ("height", 245); $height = get_parameter ("height", 245);

View File

@ -1152,9 +1152,28 @@ foreach ($result as $row) {
$win_handle=dechex(crc32($row["id_agente_modulo"].$row["module_name"])); $win_handle=dechex(crc32($row["id_agente_modulo"].$row["module_name"]));
if (defined('METACONSOLE')) if (defined('METACONSOLE'))
$link ="winopeng('" . $row['server_url'] . "operation/agentes/stat_win.php?type=$graph_type&period=86400&loginhash=auto&loginhash_data=" . $row["hashdata"] . "&loginhash_user=" . str_rot13($row["user"]) . "&id=".$row["id_agente_modulo"]."&label=".rawurlencode(urlencode(base64_encode($row["module_name"])))."&refresh=600','day_".$win_handle."')"; $link ="winopeng('" .
$row['server_url'] . "operation/agentes/stat_win.php?" .
"type=$graph_type&" .
"period=" . SECONDS_1DAY . "&" .
"loginhash=auto&" .
"loginhash_data=" . $row["hashdata"] . "&" .
"loginhash_user=" . str_rot13($row["user"]) . "&" .
"id=" . $row["id_agente_modulo"] . "&" .
"label=" . rawurlencode(
urlencode(
base64_encode($row["module_name"]))) . "&" .
"refresh=" . SECONDS_10MINUTES . "', 'day_".$win_handle."')";
else else
$link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$row["id_agente_modulo"]."&label=".rawurlencode(urlencode(base64_encode($row["module_name"])))."&refresh=600','day_".$win_handle."')"; $link ="winopeng('" .
"operation/agentes/stat_win.php?" .
"type=$graph_type&" .
"period=" . SECONDS_1DAY . "&" .
"id=".$row["id_agente_modulo"]."&" .
"label=" . rawurlencode(
urlencode(
base64_encode($row["module_name"]))) . "&" .
"refresh=" . SECONDS_10MINUTES . "', 'day_".$win_handle."')";
$data[7] = '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a>'; $data[7] = '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a>';
@ -1162,13 +1181,15 @@ foreach ($result as $row) {
"show_module_detail_dialog(" . "show_module_detail_dialog(" .
$row["id_agente_modulo"] . ", ". $row["id_agente_modulo"] . ", ".
$row['id_agent'] . ", \"" . $row['id_agent'] . ", \"" .
$row['server_name'] . "\", 0, 86400)'>" . $row['server_name'] . "\", 0, " . SECONDS_1DAY . ")'>" .
html_print_image ("images/binary.png", true, html_print_image ("images/binary.png", true,
array ("border" => "0", "alt" => "")) . "</a>"; array ("border" => "0", "alt" => "")) . "</a>";
} }
$data[8] = ui_print_module_warn_value($row['max_warning'], $row['min_warning'], $row['str_warning'], $row['max_critical'], $row['min_critical'], $row['str_critical']); $data[8] = ui_print_module_warn_value($row['max_warning'],
$row['min_warning'], $row['str_warning'], $row['max_critical'],
$row['min_critical'], $row['str_critical']);
if (is_numeric($row["datos"])) { if (is_numeric($row["datos"])) {
$salida = format_numeric($row["datos"]); $salida = format_numeric($row["datos"]);

View File

@ -182,7 +182,7 @@ if ($layers != false) {
break; break;
case "oracle": case "oracle":
$timestampLastOperation = db_get_value_sql( $timestampLastOperation = db_get_value_sql(
"SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) FROM dual"); "SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) FROM dual");
break; break;
} }

View File

@ -215,7 +215,7 @@ if ($layers != false) {
break; break;
case "oracle": case "oracle":
$timestampLastOperation = db_get_value_sql( $timestampLastOperation = db_get_value_sql(
"SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) FROM dual"); "SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) FROM dual");
break; break;
} }

View File

@ -83,7 +83,7 @@ $filter['advanced_filter'] = get_parameter('advanced_filter','');
// Read chart configuration // Read chart configuration
$chart_type = get_parameter('chart_type', 'netflow_area'); $chart_type = get_parameter('chart_type', 'netflow_area');
$max_aggregates = (int) get_parameter('max_aggregates', 0); $max_aggregates = (int) get_parameter('max_aggregates', 0);
$period = (int) get_parameter('period', '86400'); $period = (int) get_parameter('period', SECONDS_1DAY);
$update_date = (int) get_parameter('update_date', 0); $update_date = (int) get_parameter('update_date', 0);
$date = get_parameter_post ('date', date (DATE_FORMAT, get_system_time ())); $date = get_parameter_post ('date', date (DATE_FORMAT, get_system_time ()));
$time = get_parameter_post ('time', date (TIME_FORMAT, get_system_time ())); $time = get_parameter_post ('time', date (TIME_FORMAT, get_system_time ()));
@ -104,7 +104,7 @@ $start_date = $end_date - $period;
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
//Header //Header
ui_print_page_header (__('Netflow live view'), "images/op_netflow.png", false, "", false, array ()); ui_print_page_header (__('Netflow live view'), "images/op_netflow.png", false, "", false, array ());
$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
if ($is_windows) { if ($is_windows) {
ui_print_error_message(__('Not supported in Windows systems')); ui_print_error_message(__('Not supported in Windows systems'));
@ -124,7 +124,7 @@ if (! defined ('METACONSOLE')) {
ui_print_error_message(sprintf(__('Make sure nfdump version 1.6.8 or newer is installed!'))); ui_print_error_message(sprintf(__('Make sure nfdump version 1.6.8 or newer is installed!')));
} }
} }
} }
else { else {
$nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')), $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')),
@ -179,7 +179,7 @@ enterprise_hook('open_meta_frame');
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=operation/netflow/nf_live_view&pure='.$pure.'">'; echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=operation/netflow/nf_live_view&pure='.$pure.'">';
echo "<table class='databox' width='99%'>"; echo "<table class='databox' width='99%'>";
if (defined ('METACONSOLE')) { if (defined ('METACONSOLE')) {
$list_servers = array(); $list_servers = array();
@ -208,10 +208,12 @@ echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&s
echo "<tr>"; echo "<tr>";
echo "<td>" . '<b>'.__('Connection').'</b>' . "</td>"; echo "<td>" . '<b>'.__('Connection').'</b>' . "</td>";
echo "<td>" . html_print_select($list_servers, 'connection_name', $connection_name, '', '', 0, true, false, false) . "</td>"; echo "<td>" . html_print_select($list_servers,
'connection_name', $connection_name, '', '', 0, true, false,
false) . "</td>";
echo "</tr>"; echo "</tr>";
} }
echo "<tr>"; echo "<tr>";
echo "<td>" . echo "<td>" .

View File

@ -53,7 +53,7 @@ $datetime = strtotime ($date . ' ' . $time);
$report["datetime"] = $datetime; $report["datetime"] = $datetime;
// Calculations in order to modify init date of the report // Calculations in order to modify init date of the report
$date_init_less = strtotime(date('Y-m-j')) - 86400; $date_init_less = strtotime(date('Y-m-j')) - SECONDS_1DAY;
$date_init = get_parameter('date_init', date(DATE_FORMAT, $date_init_less)); $date_init = get_parameter('date_init', date(DATE_FORMAT, $date_init_less));
$time_init = get_parameter('time_init', date(TIME_FORMAT, $date_init_less)); $time_init = get_parameter('time_init', date(TIME_FORMAT, $date_init_less));
$datetime_init = strtotime ($date_init.' '.$time_init); $datetime_init = strtotime ($date_init.' '.$time_init);
@ -67,18 +67,22 @@ $options = array();
$options['list_reports'] = array('active' => false, $options['list_reports'] = array('active' => false,
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'">' . 'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'">' .
html_print_image("images/report_list.png", true, array ("title" => __('Report list'))) .'</a>'); html_print_image("images/report_list.png", true,
array("title" => __('Report list'))) .'</a>');
if (check_acl ($config['id_user'], 0, "RW")) { if (check_acl ($config['id_user'], 0, "RW")) {
$options['main']['text'] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=main&action=edit&id_report=' . $id_report . '&pure='.$pure.'">' . $options['main']['text'] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=main&action=edit&id_report=' . $id_report . '&pure='.$pure.'">' .
html_print_image("images/op_reporting.png", true, array ("title" => __('Main data'))) .'</a>'; html_print_image("images/op_reporting.png", true,
array("title" => __('Main data'))) .'</a>';
$options['list_items']['text'] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=edit&id_report=' . $id_report . '&pure='.$pure.'">' . $options['list_items']['text'] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=edit&id_report=' . $id_report . '&pure='.$pure.'">' .
html_print_image("images/list.png", true, array ("title" => __('List items'))) .'</a>'; html_print_image("images/list.png", true,
array("title" => __('List items'))) .'</a>';
$options['item_editor']['text'] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=new&id_report=' . $id_report . '&pure='.$pure.'">' . $options['item_editor']['text'] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=new&id_report=' . $id_report . '&pure='.$pure.'">' .
html_print_image("images/pen.png", true, array ("title" => __('Item editor'))) .'</a>'; html_print_image("images/pen.png", true,
array("title" => __('Item editor'))) .'</a>';
if (enterprise_installed()) { if (enterprise_installed()) {
$options = reporting_enterprise_add_Tabs($options, $id_report); $options = reporting_enterprise_add_Tabs($options, $id_report);
} }

View File

@ -148,10 +148,28 @@ else {
$url = 'include/procesos.php?agente=' . $module["id_agente_modulo"]; $url = 'include/procesos.php?agente=' . $module["id_agente_modulo"];
$win_handle = dechex(crc32($module["id_agente_modulo"] . $module["module_name"])); $win_handle = dechex(crc32($module["id_agente_modulo"] . $module["module_name"]));
$link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$module["id_agente_modulo"]."&label=".rawurlencode(urlencode(base64_encode($module["module_name"])))."&refresh=600','day_".$win_handle."')"; $link ="winopeng('" .
"operation/agentes/stat_win.php?" .
"type=$graph_type&" .
"period=" . SECONDS_1DAY . "&" .
"id=" . $module["id_agente_modulo"] . "&" .
"label=" . rawurlencode(
urlencode(
base64_encode($module["module_name"]))) . "&" .
"refresh=" . SECONDS_10MINUTES . "', " .
"'day_" . $win_handle . "')";
$graphCell = '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => 0, "alt" => "")) . '</a>'; $graphCell = '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => 0, "alt" => "")) . '</a>';
$graphCell .= "&nbsp;<a href='index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=".$module["id_agente"]."&amp;tab=data_view&period=86400&amp;id=".$module["id_agente_modulo"]."'>" . html_print_image('images/binary.png', true, array("border" => "0", "alt" => "")) . "</a>"; $graphCell .= "&nbsp;" .
"<a href='index.php?" .
"sec=estado&amp;" .
"sec2=operation/agentes/ver_agente&amp;" .
"id_agente=" . $module["id_agente"] . "&amp;" .
"tab=data_view&" .
"period=" . SECONDS_1DAY . "&amp;" .
"id=" . $module["id_agente_modulo"] . "'>" .
html_print_image('images/binary.png', true,
array("border" => "0", "alt" => "")) . "</a>";
} }
if (is_numeric($module["datos"])) { if (is_numeric($module["datos"])) {