'.__('There was a problem loading agent').''; return; } $is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente)); if($is_extra === ENTERPRISE_NOT_HOOK) { $is_extra = false; } if (! check_acl ($config["id_user"], $agent["id_grupo"], "AR") && !$is_extra) { db_pandora_audit("ACL Violation", "Trying to access Agent General Information"); require_once ("general/noaccess.php"); return; } echo '
'; echo ''; //Agent name echo ''; if ($agent['disabled']) { $cellName = "" . ui_print_agent_name ($agent["id_agente"], true, 500, "text-transform: uppercase;", true) . ui_print_help_tip(__('Disabled'), true) . ""; } else { $cellName = ui_print_agent_name ($agent["id_agente"], true, 500, "text-transform: uppercase;", true); } echo ''; //Addresses echo ''; echo ''; // Agent Interval echo ''; echo ''; // Comments echo ''; echo ''; // Agent version echo ''; echo ''; // Position Information if ($config['activate_gis']) { $dataPositionAgent = gis_get_data_last_position_agent($agent['id_agente']); echo ''; echo ''; } // If the url description is setted if ($agent['url_address'] != '') { echo ''; echo ''; } // Last contact echo ''; // Timezone Offset if ($agent['timezone_offset'] != 0) { echo ''; echo ''; } // Next contact (agent) $progress = agents_get_next_contact($id_agente); echo ''; echo ''; // Custom fields $fields = db_get_all_rows_filter('tagent_custom_fields', array('display_on_front' => 1)); if ($fields === false) { $fields = array (); } if ($fields) { foreach ($fields as $field) { echo ''; $custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente)); if ($custom_value === false || $custom_value == '') { $custom_value = '-'.__('empty').'-'; } echo ''; } } //End of table echo '
'.__('Agent name').''.$cellName.'
'.__('IP Address').''; $ips = array(); $addresses = agents_get_addresses ($id_agente); $address = agents_get_address($id_agente); foreach($addresses as $k => $add) { if($add == $address) { unset($addresses[$k]); } } echo $address; if (!empty($addresses)) { ui_print_help_tip(__('Other IP addresses').':
'.implode('
',$addresses)); } echo '
'.__('Interval').''.human_time_description_raw ($agent["intervalo"]).'
'.__('Description').''.$agent["comentarios"].'
'.__('Agent Version'). ''.$agent["agent_version"].'
'.__('Position (Long, Lat)'). ''; if ($dataPositionAgent === false) { echo __('There is no GIS data.'); } else { echo ''; if ($dataPositionAgent['description'] != "") echo $dataPositionAgent['description']; else echo $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude']; echo ""; } echo '
'.__('Url address').'' . $agent["url_address"] . '
'.__('Last contact')." / ".__('Remote').''; ui_print_timestamp ($agent["ultimo_contacto"]); echo " / "; if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") { echo __('Never'); } else { echo $agent["ultimo_contacto_remoto"]; } echo '
'.__('Timezone Offset'). ''.$agent["timezone_offset"].'
'.__('Next agent contact').'' . progress_bar($progress, 200, 20) . '
'.$field['name'] . ui_print_help_tip (__('Custom field'), true).''.$custom_value.'
'; // Blank space below title, DONT remove this, this // Breaks the layout when Flash charts are enabled :-o echo '
 
'; //Floating div echo '
'; if ($config["agentaccess"]) { echo ''.__('Agent access rate (24h)').'
'; graphic_agentaccess($id_agente, 280, 110, 86400); } echo '
'; graph_graphic_agentevents ($id_agente, 290, 15, 86400, ''); echo '
'; echo '
'; echo '
'; html_print_submit_button (__('Go to agent detail'), 'upd_button', false, 'class="sub upd"'); echo '
'; echo '
'; return; } function treeview_printTree($type) { global $config; $search_free = get_parameter('search_free', ''); $select_status = get_parameter('status', -1); echo ''; echo ''; echo '
'; //Get all groups $avariableGroups = users_get_groups (); //db_get_all_rows_in_table('tgrupo', 'nombre'); //Get all groups with agents $full_groups = db_get_all_rows_sql("SELECT DISTINCT tagente.id_grupo FROM tagente, tagente_estado WHERE tagente.id_agente = tagente_estado.id_agente AND tagente_estado.utimestamp != 0 UNION SELECT tagente.id_grupo FROM tagente WHERE disabled = 0 AND id_agente NOT IN (SELECT tagente.id_agente FROM tagente, tagente_modulo WHERE tagente.id_agente = tagente_modulo.id_agente AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 group by tagente.id_agente having COUNT(*) > 0)"); $fgroups = array(); foreach ($full_groups as $fg) { $fgroups[$fg['id_grupo']] = ""; } // We only want groups with agents, so we need the intesect of both arrays. // Not for policies, we need all groups if ($type != 'policies') $avariableGroups = array_intersect_key($avariableGroups, $fgroups); $avariableGroupsIds = implode(',',array_keys($avariableGroups)); if($avariableGroupsIds == '') { $avariableGroupsIds == -1; } if ($type !== 'policies') { // Filter groups by agent status switch ($select_status) { case NORMAL: foreach ($avariableGroups as $group_name) { $id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"'); $num_ok = groups_agent_ok($id_group); if ($num_ok <= 0) unset($avariableGroups[$id_group]); } break; case WARNING: foreach ($avariableGroups as $group_name) { $id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"'); $num_warning = groups_agent_warning($id_group); if ($num_warning <= 0) unset($avariableGroups[$id_group]); } break; case CRITICAL: foreach ($avariableGroups as $group_name) { $id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"'); $num_critical = groups_agent_critical($id_group); if ($num_critical <= 0) unset($avariableGroups[$id_group]); } break; case UNKNOWN: foreach ($avariableGroups as $group_name) { $id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"'); $num_unknown = groups_agent_unknown($id_group); if ($num_unknown <= 0) unset($avariableGroups[$id_group]); } break; } // If there are not groups display error and return if (empty($avariableGroups)) { ui_print_error_message("There aren't agents in this agrupation"); echo '
'; return; } } if ($search_free != '') { $sql_search = " AND id_grupo IN (SELECT id_grupo FROM tagente WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; } else { $sql_search =''; } switch ($type) { default: case 'os': //Skip agent with all modules in not init status $sql_search .= " AND id_agente NOT IN (SELECT tagente_estado.id_agente FROM tagente_estado GROUP BY id_agente HAVING SUM(utimestamp) = 0)"; $sql = agents_get_agents(array ( 'order' => 'nombre COLLATE utf8_general_ci ASC', 'disabled' => 0, 'status' => $select_status, 'search' => $sql_search), array ('tagente.id_os'), 'AR', false, true); $sql_os = sprintf("SELECT * FROM tconfig_os WHERE id_os IN (%s)", $sql); $list = db_get_all_rows_sql($sql_os); break; case 'group': $stringAvariableGroups = ( implode(', ', array_map( create_function('&$itemA', '{ return "\'" . $itemA . "\'"; }'), $avariableGroups ) ) ); switch ($config["dbtype"]) { case "mysql": case "postgresql": $list = db_get_all_rows_sql("SELECT * FROM tgrupo WHERE nombre IN (" . $stringAvariableGroups . ") $sql_search"); break; case "oracle": $list = db_get_all_rows_sql("SELECT * FROM tgrupo WHERE dbms_lob.substr(nombre,4000,1) IN (" . $stringAvariableGroups . ")"); break; } break; case 'module_group': //Skip agents which only have not init modules $sql_search .= " AND id_agente NOT IN (SELECT tagente_estado.id_agente FROM tagente_estado GROUP BY id_agente HAVING SUM(utimestamp) = 0)"; $sql = agents_get_agents(array ( 'order' => 'nombre COLLATE utf8_general_ci ASC', 'disabled' => 0, 'status' => $select_status, 'search' => $sql_search), array ('id_agente'), 'AR', false, true); // Skip agents without modules $sql .= ' AND id_agente IN (SELECT tagente.id_agente FROM tagente, tagente_modulo WHERE tagente.id_agente = tagente_modulo.id_agente AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 GROUP BY tagente.id_agente HAVING COUNT(*) > 0)'; $sql_module_groups = sprintf("SELECT * FROM tmodule_group WHERE id_mg IN (SELECT id_module_group FROM tagente_modulo WHERE id_agente IN (%s))", $sql); $list = db_get_all_rows_sql($sql_module_groups); if ($list == false) { $list = array(); } array_push($list, array('id_mg' => 0, 'name' => 'Not assigned')); break; case 'policies': $avariableGroups = users_get_groups (); $groups_id = array_keys($avariableGroups); $groups = implode(',',$groups_id); if ($search_free != '') { $sql = "SELECT DISTINCT tpolicies.id, tpolicies.name FROM tpolicies, tpolicy_modules, tagente_estado, tagente, tagente_modulo WHERE tagente.id_agente = tagente_estado.id_agente AND tagente_modulo.id_agente = tagente_estado.id_agente AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_policy_module != 0 AND tpolicy_modules.id = tagente_modulo.id_policy_module AND tpolicies.id = tpolicy_modules.id_policy AND tagente.id_grupo IN ($groups) AND tagente.nombre LIKE '%$search_free%' AND tagente.disabled = 0 AND tagente_modulo.disabled = 0"; $list = db_get_all_rows_sql($sql); if ($list === false) $list = array(); $element = 0; switch ($select_status) { case NORMAL: foreach ($list as $policy_element) { $policy_agents_ok = policies_agents_ok($policy_element['id']); if ($policy_agents_ok <= 0) unset($list[$element]); $element++; } break; case CRITICAL: foreach ($list as $policy_element) { $policy_agents_critical = policies_agents_critical($policy_element['id']); if ($policy_agents_critical <= 0) unset($list[$element]); $element++; } break; case WARNING: foreach ($list as $policy_element) { $policy_agents_warning = policies_agents_warning($policy_element['id']); if ($policy_agents_warning <= 0) unset($list[$element]); $element++; } break; case UNKNOWN: foreach ($list as $policy_element) { $policy_agents_unknown = policies_agents_unknown($policy_element['id']); if ($policy_agents_unknown <= 0) unset($list[$element]); $element++; } break; } if ($list === false) $list = array(); array_push($list, array('id' => 0, 'name' => 'No policy')); } else { $list = db_get_all_rows_sql("SELECT DISTINCT tpolicies.id, tpolicies.name FROM tpolicies, tpolicy_modules, tagente_estado, tagente, tagente_modulo WHERE tagente.id_agente = tagente_estado.id_agente AND tagente_modulo.id_agente = tagente_estado.id_agente AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_policy_module != 0 AND tpolicy_modules.id = tagente_modulo.id_policy_module AND tpolicies.id = tpolicy_modules.id_policy AND tagente.id_grupo IN ($groups) AND tagente.disabled = 0 AND tagente_modulo.disabled = 0"); $element = 0; switch ($select_status) { case NORMAL: foreach ($list as $policy_element) { $policy_agents_ok = policies_agents_ok($policy_element['id']); if ($policy_agents_ok <= 0) unset($list[$element]); $element++; } break; case CRITICAL: foreach ($list as $policy_element) { $policy_agents_critical = policies_agents_critical($policy_element['id']); if ($policy_agents_critical <= 0) unset($list[$element]); $element++; } break; case WARNING: foreach ($list as $policy_element) { $policy_agents_warning = policies_agents_warning($policy_element['id']); if ($policy_agents_warning <= 0) unset($list[$element]); $element++; } break; case UNKNOWN: foreach ($list as $policy_element) { $policy_agents_unknown = policies_agents_unknown($policy_element['id']); if ($policy_agents_unknown <= 0) unset($list[$element]); $element++; } break; } if ($list === false) $list = array(); array_push($list, array('id' => 0, 'name' => 'No policy')); } break; case 'module': $avariableGroupsIds = implode(',',array_keys($avariableGroups)); if($avariableGroupsIds == ''){ $avariableGroupsIds == -1; } if ($search_free != '') { $sql_search = " AND t1.id_agente IN (SELECT id_agente FROM tagente WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; } else { $sql_search = ''; } if ($select_status != -1) $sql_search .= " AND estado = " . $select_status . " "; switch ($config["dbtype"]) { case "mysql": case "postgresql": $list = db_get_all_rows_sql('SELECT t1.nombre FROM tagente_modulo t1, tagente t2, tagente_estado t3 WHERE t1.id_agente = t2.id_agente AND t1.id_agente_modulo = t3.id_agente_modulo AND t2.disabled = 0 AND t1.disabled = 0 AND t3.utimestamp !=0 AND t2.id_grupo in (' . $avariableGroupsIds . ')' . $sql_search.' GROUP BY t1.nombre ORDER BY t1.nombre'); break; case "oracle": $list = db_get_all_rows_sql(' SELECT dbms_lob.substr(t1.nombre,4000,1) as nombre FROM tagente_modulo t1, tagente t2, tagente_estado t3 WHERE t1.id_agente = t2.id_agente AND t2.id_grupo in (' . $avariableGroupsIds . ') AND t1.id_agente_modulo = t3.id_agente_modulo AND t2.disabled = 0 AND t1.disabled = 0 AND t3.utimestamp !=0 GROUP BY dbms_lob.substr(t1.nombre,4000,1) ORDER BY dbms_lob.substr(t1.nombre,4000,1) ASC'); break; } break; } if ($list === false) { ui_print_error_message("There aren't agents in this agrupation"); echo ''; echo ''; } else { echo "\n"; echo ''; echo ''; echo '
 
'; echo ''; echo ''; } } ?>