2011-03-08 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_html.php, include/functions_messages.php, include/functions_exportserver.php, include/functions_reporting.php, include/functions_gis.php, include/functions_networkmap.php, include/functions_servers.php, include/functions_api.php, include/fgraph.php, include/functions_agents.php, include/functions_db.php, include/functions_alerts.php, extensions/module_groups.php, operation/incidents/incident.php, operation/incidents/incident_detail.php, operation/search_modules.php, operation/agentes/status_monitor.php, operation/agentes/export_csv.php, operation/agentes/estado_ultimopaquete.php, operation/agentes/alerts_status.php, operation/agentes/estado_agente.php, operation/agentes/sla_view.php, operation/agentes/ver_agente.php, operation/servers/view_server_detail.php, operation/menu.php, operation/search_graphs.php, operation/snmpconsole/snmp_view.php, operation/gis_maps/ajax.php, operation/events/events_rss.php, operation/events/events_list.php, operation/search_alerts.php, operation/search_reports.php, operation/reporting/reporting_xml.php, operation/reporting/graph_viewer.php, operation/search_maps.php, operation/search_users.php, mobile/operation/agents/view_agents.php, mobile/operation/events/events.php, godmode/groups/modu_group_list.php, godmode/groups/configure_group.php, godmode/groups/group_list.php, godmode/db/db_main.php, godmode/db/db_purge.php, godmode/agentes/module_manager_editor_prediction.php, godmode/agentes/modificar_agente.php, godmode/agentes/module_manager_editor.php, godmode/agentes/planned_downtime.php, godmode/servers/manage_recontask_form.php, godmode/alerts/alert_list.list.php, godmode/users/configure_user.php, godmode/massive/massive_edit_modules.php, godmode/modules/manage_network_templates_form.php, godmode/modules/manage_network_components_form_wmi.php, godmode/reporting/visual_console_builder.php, godmode/reporting/reporting_builder.item_editor.php: changed or added in some cases the SQL queries for to be PostgreSQL standard, and cleaned source style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4074 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
e12de5ca51
commit
9185505bcf
|
@ -1,10 +1,49 @@
|
|||
2011-03-08 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_html.php, include/functions_messages.php,
|
||||
include/functions_exportserver.php, include/functions_reporting.php,
|
||||
include/functions_gis.php, include/functions_networkmap.php,
|
||||
include/functions_servers.php, include/functions_api.php,
|
||||
include/fgraph.php, include/functions_agents.php, include/functions_db.php,
|
||||
include/functions_alerts.php, extensions/module_groups.php,
|
||||
operation/incidents/incident.php, operation/incidents/incident_detail.php,
|
||||
operation/search_modules.php, operation/agentes/status_monitor.php,
|
||||
operation/agentes/export_csv.php,
|
||||
operation/agentes/estado_ultimopaquete.php,
|
||||
operation/agentes/alerts_status.php, operation/agentes/estado_agente.php,
|
||||
operation/agentes/sla_view.php, operation/agentes/ver_agente.php,
|
||||
operation/servers/view_server_detail.php, operation/menu.php,
|
||||
operation/search_graphs.php, operation/snmpconsole/snmp_view.php,
|
||||
operation/gis_maps/ajax.php, operation/events/events_rss.php,
|
||||
operation/events/events_list.php, operation/search_alerts.php,
|
||||
operation/search_reports.php, operation/reporting/reporting_xml.php,
|
||||
operation/reporting/graph_viewer.php, operation/search_maps.php,
|
||||
operation/search_users.php, mobile/operation/agents/view_agents.php,
|
||||
mobile/operation/events/events.php, godmode/groups/modu_group_list.php,
|
||||
godmode/groups/configure_group.php, godmode/groups/group_list.php,
|
||||
godmode/db/db_main.php, godmode/db/db_purge.php,
|
||||
godmode/agentes/module_manager_editor_prediction.php,
|
||||
godmode/agentes/modificar_agente.php,
|
||||
godmode/agentes/module_manager_editor.php,
|
||||
godmode/agentes/planned_downtime.php,
|
||||
godmode/servers/manage_recontask_form.php,
|
||||
godmode/alerts/alert_list.list.php, godmode/users/configure_user.php,
|
||||
godmode/massive/massive_edit_modules.php,
|
||||
godmode/modules/manage_network_templates_form.php,
|
||||
godmode/modules/manage_network_components_form_wmi.php,
|
||||
godmode/reporting/visual_console_builder.php,
|
||||
godmode/reporting/reporting_builder.item_editor.php: changed or added in
|
||||
some cases the SQL queries for to be PostgreSQL standard, and cleaned source
|
||||
style.
|
||||
|
||||
2011-03-08 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_api.php, include/functions_db.php,
|
||||
operation/incidents/incident_detail.php, godmode/agentes/agent_template.php,
|
||||
godmode/servers/manage_recontask.php, godmode/snmpconsole/snmp_alert.php,
|
||||
godmode/users/configure_profile.php: change the source code
|
||||
for to use process_sql_insert instead of the SQL (SQL write in multiple lines).
|
||||
for to use process_sql_insert instead of the SQL (SQL write in multiple
|
||||
lines).
|
||||
|
||||
2011-03-08 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ if (is_ajax ()) {
|
|||
$sql = 'SELECT *
|
||||
FROM talert_template_module_actions AS t1
|
||||
INNER JOIN talert_actions AS t2 ON t1.id_alert_action = t2.id
|
||||
WHERE t1.id_alert_template_module = ' . $template['id'] . ' OR t2.id = ' . $template['id_alert_action'] . ';';
|
||||
WHERE t1.id_alert_template_module = ' . $template['id'] . '
|
||||
OR t2.id = ' . $template['id_alert_action'] . ';';
|
||||
|
||||
$actions = get_db_all_rows_sql($sql);
|
||||
if ($actions === false) {
|
||||
|
@ -87,7 +88,7 @@ function mainModuleGroups() {
|
|||
require_once ('include/functions_reporting.php');
|
||||
|
||||
//The big query
|
||||
$sql = "select COUNT(id_agente) AS count, estado
|
||||
$sql = "SELECT COUNT(id_agente) AS count, estado
|
||||
FROM tagente_estado
|
||||
WHERE utimestamp != 0 AND id_agente IN
|
||||
(SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled IS FALSE)
|
||||
|
|
|
@ -247,7 +247,7 @@ if ($agents !== false) {
|
|||
$id_grupo = $agent["id_grupo"];
|
||||
if (! check_acl ($config["id_user"], $id_grupo, "AW"))
|
||||
continue;
|
||||
if ($color == 1){
|
||||
if ($color == 1) {
|
||||
$tdcolor = "datos";
|
||||
$color = 0;
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ if ($agents !== false) {
|
|||
$iterator++;
|
||||
// Agent name
|
||||
echo "<tr class='$rowclass'><td class='$tdcolor' width='40%'>";
|
||||
if ($agent["disabled"]){
|
||||
if ($agent["disabled"]) {
|
||||
echo "<em>";
|
||||
}
|
||||
echo '<span class="left">';
|
||||
|
@ -330,7 +330,8 @@ if ($agents !== false) {
|
|||
echo "</table>";
|
||||
pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset);
|
||||
echo "<table width='95%'><tr><td align='right'>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo "<div class='nf'>".__('There are no defined agents')."</div>";
|
||||
echo " </td></tr><tr><td>";
|
||||
}
|
||||
|
|
|
@ -67,7 +67,14 @@ if (is_ajax ()) {
|
|||
|
||||
$typeName = parseLocalModuleExtractValue('module_type',$component['data']);
|
||||
|
||||
$component['type'] = get_db_value_sql('SELECT id_tipo FROM ttipo_modulo WHERE nombre LIKE "' . $typeName . '"');
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$component['type'] = get_db_value_sql('SELECT id_tipo FROM ttipo_modulo WHERE nombre LIKE "' . $typeName . '"');
|
||||
break;
|
||||
case "postgresql":
|
||||
$component['type'] = get_db_value_sql('SELECT id_tipo FROM ttipo_modulo WHERE nombre LIKE \'' . $typeName . '\'');
|
||||
break;
|
||||
}
|
||||
|
||||
echo json_encode ($component);
|
||||
return;
|
||||
|
|
|
@ -64,7 +64,9 @@ $data[1] .= print_input_text_extended ('agent_name',$agent_name, 'text_agent_nam
|
|||
$data[1] .= '<a href="#" class="tip"> <span>' . __("Type at least two characters to search") . '</span></a> <br/>';
|
||||
$data[1] .= print_label(__("Module"),'prediction_module',true);
|
||||
if($id_agente) {
|
||||
$sql = "SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE history_data = 1 AND id_agente = ".$id_agente;
|
||||
$sql = "SELECT id_agente_modulo, nombre
|
||||
FROM tagente_modulo
|
||||
WHERE history_data = 1 AND id_agente = ".$id_agente;
|
||||
$data[1] .= print_select_from_sql($sql, 'prediction_module', $prediction_module, false, __('Select Module'), 0, true, false, true, $is_service);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -211,7 +211,15 @@ if ($create_downtime || $update_downtime) {
|
|||
$filter_cond = '';
|
||||
if($filter_group > 0)
|
||||
$filter_cond = " AND id_grupo = $filter_group ";
|
||||
$sql = sprintf ("SELECT tagente.id_agente, tagente.nombre, tagente.id_grupo FROM tagente WHERE tagente.id_agente NOT IN (SELECT tagente.id_agente FROM tagente, tplanned_downtime_agents WHERE tplanned_downtime_agents.id_agent = tagente.id_agente AND tplanned_downtime_agents.id_downtime = %d) AND disabled = 0 $filter_cond ORDER by tagente.nombre", $id_downtime);
|
||||
$sql = sprintf ("SELECT tagente.id_agente, tagente.nombre, tagente.id_grupo
|
||||
FROM tagente
|
||||
WHERE tagente.id_agente NOT IN (
|
||||
SELECT tagente.id_agente
|
||||
FROM tagente, tplanned_downtime_agents
|
||||
WHERE tplanned_downtime_agents.id_agent = tagente.id_agente
|
||||
AND tplanned_downtime_agents.id_downtime = %d
|
||||
) AND disabled = 0 $filter_cond
|
||||
ORDER by tagente.nombre", $id_downtime);
|
||||
$downtimes = get_db_all_rows_sql ($sql);
|
||||
$data = array ();
|
||||
if ($downtimes)
|
||||
|
@ -239,7 +247,12 @@ if ($create_downtime || $update_downtime) {
|
|||
//Start Overview of existing planned downtime
|
||||
echo '<h3>'.__('Agents planned for this downtime').':</h3>';
|
||||
|
||||
$sql = sprintf ("SELECT tagente.nombre, tplanned_downtime_agents.id, tagente.id_os, tagente.id_agente, tagente.id_grupo, tagente.ultimo_contacto FROM tagente, tplanned_downtime_agents WHERE tplanned_downtime_agents.id_agent = tagente.id_agente AND tplanned_downtime_agents.id_downtime = %d ",$id_downtime);
|
||||
$sql = sprintf ("SELECT tagente.nombre, tplanned_downtime_agents.id,
|
||||
tagente.id_os, tagente.id_agente, tagente.id_grupo,
|
||||
tagente.ultimo_contacto
|
||||
FROM tagente, tplanned_downtime_agents
|
||||
WHERE tplanned_downtime_agents.id_agent = tagente.id_agente
|
||||
AND tplanned_downtime_agents.id_downtime = %d ",$id_downtime);
|
||||
|
||||
$downtimes = get_db_all_rows_sql ($sql);
|
||||
if ($downtimes === false) {
|
||||
|
|
|
@ -135,7 +135,7 @@ if ($searchFlag) {
|
|||
if ($enabledisable != -1)
|
||||
$where .= " AND talert_template_modules.disabled =" . $enabledisable;
|
||||
if ($standby != -1)
|
||||
$where .= " AND talert_template_modules.standby =" . $standby;
|
||||
$where .= " AND talert_template_modules.standby = " . $standby;
|
||||
}
|
||||
|
||||
$total = get_agent_alerts_simple (array_keys ($agents), false,
|
||||
|
|
|
@ -40,7 +40,16 @@ $stat_data_string = get_db_sql ("SELECT COUNT(*) FROM tagente_datos_string WHERE
|
|||
$stat_modules = get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE id_agente_modulo != 0");
|
||||
$stat_event = get_db_sql (" SELECT COUNT(*) FROM tevento");
|
||||
$stat_agente = get_db_sql (" SELECT COUNT(*) FROM tagente");
|
||||
$stat_uknown = get_db_sql ("SELECT COUNT(*) FROM tagente WHERE ultimo_contacto < NOW() - (intervalo *2)");
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$stat_uknown = get_db_sql ("SELECT COUNT(*) FROM tagente WHERE ultimo_contacto < NOW() - (intervalo * 2)");
|
||||
break;
|
||||
case "postgresql":
|
||||
$stat_uknown = get_db_sql ("SELECT COUNT(*)
|
||||
FROM tagente
|
||||
WHERE ceil(date_part('epoch', ultimo_contacto)) < ceil(date_part('epoch', NOW())) - (intervalo * 2)");
|
||||
break;
|
||||
}
|
||||
$stat_noninit = get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE utimestamp = 0;");
|
||||
|
||||
// Todo: Recalculate this data dinamically using the capacity and total agents
|
||||
|
|
|
@ -179,8 +179,9 @@ flush ();
|
|||
|
||||
if ($id_agent > 0) { //If the agent is not All or Not selected
|
||||
$modules = get_agent_modules ($id_agent);
|
||||
$query = sprintf ("AND id_agente_modulo IN(%s)", implode (",", array_keys ($modules)));
|
||||
} else {
|
||||
$query = sprintf (" AND id_agente_modulo IN (%s)", implode (",", array_keys ($modules)));
|
||||
}
|
||||
else {
|
||||
$query = "";
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,8 @@ if ($id_group) {
|
|||
$custom_id = $group["custom_id"];
|
||||
$propagate = $group["propagate"];
|
||||
$skin = $group["id_skin"];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo "<h3 class='error'>".__('There was a problem loading group')."</h3>";
|
||||
echo "</table>";
|
||||
include ("general/footer.php");
|
||||
|
@ -57,7 +58,8 @@ if ($id_group) {
|
|||
// Header
|
||||
if ($id_group) {
|
||||
print_page_header (__("Update group"), "images/god1.png", false, "", true, "");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
print_page_header (__("Create group"), "images/god1.png", false, "", true, "");
|
||||
}
|
||||
|
||||
|
@ -113,7 +115,8 @@ if ($id_group) {
|
|||
print_input_hidden ('update_group', 1);
|
||||
print_input_hidden ('id_group', $id_group);
|
||||
print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
print_input_hidden ('create_group', 1);
|
||||
print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"');
|
||||
}
|
||||
|
|
|
@ -155,9 +155,6 @@ if ($update_group) {
|
|||
/* Delete group */
|
||||
if ($delete_group) {
|
||||
$id_group = (int) get_parameter ('id_group');
|
||||
|
||||
// $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo = %d', $id_group);
|
||||
// $agent = process_sql ($sql);
|
||||
|
||||
$usedGroup = checkUsedGroup($id_group);
|
||||
|
||||
|
|
|
@ -113,8 +113,6 @@ $table->align = array ();
|
|||
$table->align[1] = 'center';
|
||||
$table->data = array ();
|
||||
|
||||
//$groups = get_user_groups ($config['id_user']);
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM tmodule_group ";
|
||||
$groups = get_db_all_rows_sql ($sql, true);
|
||||
|
@ -123,15 +121,7 @@ $groups = get_db_all_rows_sql ($sql, true);
|
|||
foreach ($groups as $id_group ) {
|
||||
$data = array ();
|
||||
|
||||
// $group = get_db_row ('tmodule_group', 'id_mg', $id_group);
|
||||
|
||||
// if (!empty ($group["icon"]))
|
||||
// $data[0] = '<img src="images/groups_small/'.$group["icon"].'.png" border="0">';
|
||||
// else
|
||||
// $data[0] = ' ';
|
||||
$data[0] = '<strong><a href="index.php?sec=gagente&sec2=godmode/groups/configure_modu_group&id_group='.$id_group["id_mg"].'">'.printTruncateText($id_group["name"], 50).'</a></strong>';
|
||||
// $data[2] = get_group_name ($group["parent"]);
|
||||
// $data[3] = $group['disabled'] ? __('Disabled') : __('Enabled');
|
||||
$data[1] = '<a href="index.php?sec=gagente&sec2=godmode/groups/modu_group_list&id_group='.$id_group["id_mg"].'&delete_group=1" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">' . print_image("images/cross.png", true, array("border" => '0')) . '</a>';
|
||||
|
||||
array_push ($table->data, $data);
|
||||
|
|
|
@ -119,7 +119,9 @@ if ($update) {
|
|||
if($module_type != 0)
|
||||
$condition = ' AND t2.id_tipo_modulo = '.$module_type;
|
||||
|
||||
$agents_ = get_db_all_rows_sql('SELECT DISTINCT(t1.id_agente) FROM tagente t1, tagente_modulo t2 WHERE t1.id_agente = t2.id_agente');
|
||||
$agents_ = get_db_all_rows_sql('SELECT DISTINCT(t1.id_agente)
|
||||
FROM tagente t1, tagente_modulo t2
|
||||
WHERE t1.id_agente = t2.id_agente');
|
||||
foreach($agents_ as $id_agent) {
|
||||
$module_name = get_db_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent, 'id_tipo_modulo' => $module_type),'nombre');
|
||||
|
||||
|
@ -316,7 +318,8 @@ $table->data['edit5'][2] = __('Password');
|
|||
$table->data['edit5'][3] = print_input_password ('plugin_pass', '', '', 15, 60, true);
|
||||
|
||||
$table->data['edit6'][0] = __('Export target');
|
||||
$table->data['edit6'][1] = print_select_from_sql ('SELECT id, name FROM tserver_export ORDER BY name',
|
||||
$table->data['edit6'][1] = print_select_from_sql ('SELECT id, name
|
||||
FROM tserver_export ORDER BY name',
|
||||
'id_export', '', '',__('None'),'0', true, false, false);
|
||||
|
||||
/* FF stands for Flip-flop */
|
||||
|
|
|
@ -90,7 +90,8 @@ echo '<td class="datos2">';
|
|||
echo '<select name="tipo">';
|
||||
echo '<option value="' . $type . '">' . get_moduletype_name ($type);
|
||||
|
||||
$rows = get_db_all_rows_sql('SELECT id_tipo, nombre FROM ttipo_modulo WHERE categoria IN (0,1,2) ORDER BY nombre;');
|
||||
$rows = get_db_all_rows_sql('SELECT id_tipo, nombre
|
||||
FROM ttipo_modulo WHERE categoria IN (0,1,2) ORDER BY nombre;');
|
||||
if ($rows === false) {
|
||||
$rows = array();
|
||||
}
|
||||
|
|
|
@ -229,7 +229,8 @@ if ($id_np > 0) {
|
|||
echo '<div style="width:540px">';
|
||||
if ($ncgroup > 0) {
|
||||
$sql = sprintf ("SELECT id_nc, name, id_group FROM tnetwork_component WHERE id_group = %d ORDER BY name", $ncgroup);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$sql = "SELECT id_nc, name, id_group FROM tnetwork_component ORDER BY name";
|
||||
}
|
||||
|
||||
|
|
|
@ -319,7 +319,15 @@ print_input_hidden('id_item', $idItem);
|
|||
<td style="vertical-align: top;"><?php echo __('Custom graph'); ?></td>
|
||||
<td style="">
|
||||
<?php
|
||||
print_select_from_sql ('SELECT id_graph, name FROM tgraph WHERE private = 0 OR (private = 1 AND id_user = "'.$config["id_user"].'")', 'id_custom_graph', $idCustomGraph, '', '--', 0);
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = 'SELECT id_graph, name FROM tgraph WHERE private = 0 OR (private = 1 AND id_user = "'.$config["id_user"].'")';
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = 'SELECT id_graph, name FROM tgraph WHERE private = 0 OR (private = 1 AND id_user = \''.$config["id_user"].'\')';
|
||||
break;
|
||||
}
|
||||
print_select_from_sql($sql, 'id_custom_graph', $idCustomGraph, '', '--', 0);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -173,7 +173,9 @@ switch ($activeTab) {
|
|||
foreach($name_modules as $mod){
|
||||
$cont_ag = 1;
|
||||
foreach($id_agents as $ag){
|
||||
$sql = "SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 0 AND id_agente = ".$ag." AND nombre = '".$mod."'";
|
||||
$sql = "SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE delete_pending = 0 AND id_agente = ".$ag." AND nombre = '".$mod."'";
|
||||
$result = get_db_row_sql ($sql);
|
||||
$id_modules[$cont_dest] = $result['id_agente_modulo'];
|
||||
$cont_ag = $cont_ag + 1;
|
||||
|
|
|
@ -97,7 +97,9 @@ $table->data[0][1] = print_input_text ('name', $name, '', 25, 0, true);
|
|||
// Recon server
|
||||
$table->data[1][0] = "<b>".__('Recon server').'<a href="#" class="tip"> <span>'.__('You must select a Recon Server for the Task, otherwise the Recon Task will never run').'</span></a>';
|
||||
|
||||
$table->data[1][1] = print_select_from_sql ('SELECT id_server, name FROM tserver WHERE server_type = 3 ORDER BY name', "id_recon_server", $id_recon_server, '', '', '', true);
|
||||
$table->data[1][1] = print_select_from_sql ('SELECT id_server, name
|
||||
FROM tserver
|
||||
WHERE server_type = 3 ORDER BY name', "id_recon_server", $id_recon_server, '', '', '', true);
|
||||
|
||||
|
||||
$fields['network_sweep'] = __("Network sweep");
|
||||
|
|
|
@ -248,16 +248,6 @@ $table->data[2][0] = __('Language');
|
|||
$table->data[2][1] = print_select_from_sql ('SELECT id_language, name FROM tlanguage',
|
||||
'language', $user_info["language"], '', '', '', true);
|
||||
|
||||
/*
|
||||
$table->data[2][0] = __('First name');
|
||||
$table->data[2][1] = print_input_text_extended ('firstname', $user_info['firstname'],
|
||||
'', '', 30, 255, $view_mode, '', '', true);
|
||||
|
||||
$table->data[3][0] = __('Last name');
|
||||
$table->data[3][1] = print_input_text_extended ('lastname', $user_info['lastname'],
|
||||
'', '', 30, 255, $view_mode, '', '', true);
|
||||
*/
|
||||
|
||||
if ($config['user_can_update_password']) {
|
||||
$table->data[4][0] = __('Password');
|
||||
$table->data[4][1] = print_input_text_extended ('password_new', '', '', '',
|
||||
|
|
|
@ -370,10 +370,10 @@ function graphic_agentmodules ($id_agent, $width, $height) {
|
|||
global $config;
|
||||
|
||||
$data = array ();
|
||||
$sql = sprintf ('SELECT ttipo_modulo.nombre,COUNT(id_agente_modulo)
|
||||
FROM tagente_modulo,ttipo_modulo WHERE
|
||||
id_tipo_modulo = id_tipo AND id_agente = %d
|
||||
GROUP BY id_tipo_modulo', $id_agent);
|
||||
$sql = sprintf ('SELECT ttipo_modulo.nombre, COUNT(id_agente_modulo)
|
||||
FROM tagente_modulo,ttipo_modulo
|
||||
WHERE id_tipo_modulo = id_tipo AND id_agente = %d
|
||||
GROUP BY id_tipo_modulo', $id_agent);
|
||||
$modules = get_db_all_rows_sql ($sql);
|
||||
foreach ($modules as $module) {
|
||||
$data[$module['nombre']] = $module[1];
|
||||
|
@ -539,7 +539,8 @@ function grafico_incidente_prioridad () {
|
|||
|
||||
$data_tmp = array (0, 0, 0, 0, 0, 0);
|
||||
$sql = 'SELECT COUNT(id_incidencia) n_incidents, prioridad
|
||||
FROM tincidencia GROUP BY prioridad
|
||||
FROM tincidencia
|
||||
GROUP BY prioridad
|
||||
ORDER BY 2 DESC';
|
||||
$incidents = get_db_all_rows_sql ($sql);
|
||||
|
||||
|
@ -576,10 +577,10 @@ function graphic_incident_group () {
|
|||
$data = array ();
|
||||
$max_items = 5;
|
||||
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incidents, nombre
|
||||
FROM tincidencia,tgrupo
|
||||
WHERE tgrupo.id_grupo = tincidencia.id_grupo
|
||||
GROUP BY tgrupo.id_grupo ORDER BY 1 DESC LIMIT %d',
|
||||
$max_items);
|
||||
FROM tincidencia,tgrupo
|
||||
WHERE tgrupo.id_grupo = tincidencia.id_grupo
|
||||
GROUP BY tgrupo.id_grupo ORDER BY 1 DESC LIMIT %d',
|
||||
$max_items);
|
||||
$incidents = get_db_all_rows_sql ($sql);
|
||||
|
||||
if($incidents == false) {
|
||||
|
@ -611,8 +612,9 @@ function graphic_incident_user () {
|
|||
$data = array ();
|
||||
$max_items = 5;
|
||||
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incidents, id_usuario
|
||||
FROM tincidencia GROUP BY id_usuario
|
||||
ORDER BY 1 DESC LIMIT %d', $max_items);
|
||||
FROM tincidencia
|
||||
GROUP BY id_usuario
|
||||
ORDER BY 1 DESC LIMIT %d', $max_items);
|
||||
$incidents = get_db_all_rows_sql ($sql);
|
||||
|
||||
if($incidents == false) {
|
||||
|
@ -650,8 +652,9 @@ function graphic_user_activity ($width = 350, $height = 230) {
|
|||
$data = array ();
|
||||
$max_items = 5;
|
||||
$sql = sprintf ('SELECT COUNT(id_usuario) n_incidents, id_usuario
|
||||
FROM tsesion GROUP BY id_usuario
|
||||
ORDER BY 1 DESC LIMIT %d', $max_items);
|
||||
FROM tsesion
|
||||
GROUP BY id_usuario
|
||||
ORDER BY 1 DESC LIMIT %d', $max_items);
|
||||
$logins = get_db_all_rows_sql ($sql);
|
||||
|
||||
if($logins == false) {
|
||||
|
@ -684,13 +687,13 @@ function graphic_incident_source ($width = 320, $height = 200) {
|
|||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incident, origen
|
||||
FROM tincidencia GROUP BY `origen`
|
||||
ORDER BY 1 DESC LIMIT %d', $max_items);
|
||||
FROM tincidencia GROUP BY `origen`
|
||||
ORDER BY 1 DESC LIMIT %d', $max_items);
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incident, origen
|
||||
FROM tincidencia GROUP BY "origen"
|
||||
ORDER BY 1 DESC LIMIT %d', $max_items);
|
||||
FROM tincidencia GROUP BY "origen"
|
||||
ORDER BY 1 DESC LIMIT %d', $max_items);
|
||||
break;
|
||||
}
|
||||
$origins = get_db_all_rows_sql ($sql);
|
||||
|
@ -721,9 +724,10 @@ function graph_db_agentes_modulos ($width, $height) {
|
|||
|
||||
$data = array ();
|
||||
|
||||
$modules = get_db_all_rows_sql ('SELECT COUNT(id_agente_modulo),id_agente
|
||||
FROM tagente_modulo GROUP BY id_agente
|
||||
ORDER BY 1 DESC LIMIT 10');
|
||||
$modules = get_db_all_rows_sql ('SELECT COUNT(id_agente_modulo), id_agente
|
||||
FROM tagente_modulo
|
||||
GROUP BY id_agente
|
||||
ORDER BY 1 DESC LIMIT 10');
|
||||
if ($modules === false)
|
||||
$modules = array ();
|
||||
|
||||
|
@ -751,9 +755,10 @@ function grafico_eventos_usuario ($width, $height) {
|
|||
|
||||
$data = array ();
|
||||
$max_items = 5;
|
||||
$sql = sprintf ('SELECT COUNT(id_evento) events,id_usuario
|
||||
FROM tevento GROUP BY id_usuario
|
||||
ORDER BY 1 DESC LIMIT %d', $max_items);
|
||||
$sql = sprintf ('SELECT COUNT(id_evento) events, id_usuario
|
||||
FROM tevento
|
||||
GROUP BY id_usuario
|
||||
ORDER BY 1 DESC LIMIT %d', $max_items);
|
||||
$events = get_db_all_rows_sql ($sql);
|
||||
|
||||
foreach ($events as $event) {
|
||||
|
@ -819,10 +824,10 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
|
|||
$data = array ();
|
||||
$max_items = 6;
|
||||
$sql = sprintf ('SELECT COUNT(id_evento) as count_number, nombre
|
||||
FROM tevento, tagente_modulo
|
||||
WHERE id_agentmodule = id_agente_modulo
|
||||
FROM tevento, tagente_modulo
|
||||
WHERE id_agentmodule = id_agente_modulo
|
||||
AND disabled = 0 AND tevento.id_agente = %d
|
||||
GROUP BY id_agentmodule LIMIT %d', $id_agent, $max_items);
|
||||
GROUP BY id_agentmodule LIMIT %d', $id_agent, $max_items);
|
||||
$events = get_db_all_rows_sql ($sql);
|
||||
if ($events === false) {
|
||||
if (! $graphic_type) {
|
||||
|
|
|
@ -149,10 +149,13 @@ function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = fa
|
|||
|
||||
if (($id_agent === false) && ($idGroup !== false)) {
|
||||
if ($idGroup != 0) { //All group
|
||||
$subQuery = 'SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 0 AND id_agente IN (SELECT id_agente FROM tagente WHERE id_grupo = ' . $idGroup . ')';
|
||||
$subQuery = 'SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE delete_pending = 0 AND id_agente IN (SELECT id_agente FROM tagente WHERE id_grupo = ' . $idGroup . ')';
|
||||
}
|
||||
else {
|
||||
$subQuery = 'SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 0';
|
||||
$subQuery = 'SELECT id_agente_modulo
|
||||
FROM tagente_modulo WHERE delete_pending = 0';
|
||||
}
|
||||
}
|
||||
else if ($id_agent === false) {
|
||||
|
@ -540,7 +543,12 @@ function get_agents_common_modules_with_alerts ($id_agent, $filter = false, $ind
|
|||
|
||||
$where = '';
|
||||
if (! empty ($id_agent)) {
|
||||
$where = sprintf (' WHERE t2.id_agent_module = t1.id_agente_modulo AND delete_pending = 0 AND id_agente IN (%s) AND (SELECT count(nombre) FROM tagente_modulo t3, talert_template_modules t4 WHERE t4.id_agent_module = t3.id_agente_modulo AND delete_pending = 0 AND t1.nombre = t3.nombre AND id_agente IN (%s)) = (%s)', implode (",", (array) $id_agent), implode (",", (array) $id_agent), count($id_agent));
|
||||
$where = sprintf (' WHERE t2.id_agent_module = t1.id_agente_modulo AND delete_pending = 0
|
||||
AND id_agente IN (%s) AND (
|
||||
SELECT count(nombre)
|
||||
FROM tagente_modulo t3, talert_template_modules t4
|
||||
WHERE t4.id_agent_module = t3.id_agente_modulo AND delete_pending = 0
|
||||
AND t1.nombre = t3.nombre AND id_agente IN (%s)) = (%s)', implode (",", (array) $id_agent), implode (",", (array) $id_agent), count($id_agent));
|
||||
}
|
||||
|
||||
if (! empty ($filter)) {
|
||||
|
@ -611,7 +619,12 @@ function get_agents_common_modules ($id_agent, $filter = false, $indexed = true,
|
|||
|
||||
$where = '';
|
||||
if (! empty ($id_agent)) {
|
||||
$where = sprintf (' WHERE delete_pending = 0 AND id_agente IN (%s) AND (SELECT count(nombre) FROM tagente_modulo t2 WHERE delete_pending = 0 AND t1.nombre = t2.nombre AND id_agente IN (%s)) = (%s)', implode (",", (array) $id_agent), implode (",", (array) $id_agent), count($id_agent));
|
||||
$where = sprintf (' WHERE delete_pending = 0 AND id_agente IN (%s)
|
||||
AND (
|
||||
SELECT count(nombre)
|
||||
FROM tagente_modulo t2
|
||||
WHERE delete_pending = 0 AND t1.nombre = t2.nombre
|
||||
AND id_agente IN (%s)) = (%s)', implode (",", (array) $id_agent), implode (",", (array) $id_agent), count($id_agent));
|
||||
}
|
||||
|
||||
if (! empty ($filter)) {
|
||||
|
@ -622,7 +635,8 @@ function get_agents_common_modules ($id_agent, $filter = false, $indexed = true,
|
|||
array_push ($fields, $field.'="'.$value.'"');
|
||||
}
|
||||
$where .= implode (' AND ', $fields);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$where .= $filter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,8 @@ function get_event_status_group($idGroup, $type = "alert_fired", $query = 'AND 1
|
|||
|
||||
$result = get_db_all_rows_sql('SELECT id_evento
|
||||
FROM tevento
|
||||
WHERE estado = 0 AND id_agente IN (' . implode(',', $idAgents) . ') ' . $typeWhere . $query . ' ORDER BY id_evento DESC LIMIT 1');
|
||||
WHERE estado = 0 AND id_agente IN (' . implode(',', $idAgents) . ') ' . $typeWhere . $query . '
|
||||
ORDER BY id_evento DESC LIMIT 1');
|
||||
|
||||
if ($result === false) {
|
||||
return false;
|
||||
|
|
|
@ -151,9 +151,18 @@ function isInACL($ip) {
|
|||
function get_agent_module_name_last_value($agentName, $moduleName, $other = ';', $returnType)
|
||||
{
|
||||
$idAgent = get_agent_id($agentName);
|
||||
$sql = sprintf('SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente = %d AND nombre LIKE "%s"', $idAgent, $moduleName);
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = sprintf('SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente = %d AND nombre LIKE "%s"', $idAgent, $moduleName);
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = sprintf('SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente = %d AND nombre LIKE \'%s\'', $idAgent, $moduleName);
|
||||
break;
|
||||
}
|
||||
|
||||
$idModuleAgent = get_db_value_sql($sql);
|
||||
|
||||
|
@ -625,6 +634,15 @@ function set_new_agent($thrash1, $thrash2, $other, $thrash3) {
|
|||
$disabled = $other['data'][10];
|
||||
$description = $other['data'][11];
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql1 = 'SELECT name FROM tserver WHERE name LIKE "' . $nameServer . '"';
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql1 = 'SELECT name FROM tserver WHERE name LIKE \'' . $nameServer . '\'';
|
||||
break;
|
||||
}
|
||||
|
||||
if (get_agent_id ($name)) {
|
||||
returnError('agent_name_exist', 'The name of agent yet exist in DB.');
|
||||
}
|
||||
|
@ -638,7 +656,7 @@ function set_new_agent($thrash1, $thrash2, $other, $thrash3) {
|
|||
else if (get_db_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = ' . $idOS) === false) {
|
||||
returnError('id_os_not_exist', 'The OS don`t exist.');
|
||||
}
|
||||
else if (get_db_value_sql('SELECT name FROM tserver WHERE name LIKE "' . $nameServer . '"') === false) {
|
||||
else if (get_db_value_sql($sql1) === false) {
|
||||
returnError('server_not_exist', 'The Pandora Server don`t exist.');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -589,7 +589,14 @@ function get_group_agents ($id_group = 0, $search = false, $case = "lower", $noA
|
|||
unset ($search["disabled"]);
|
||||
if (isset ($search["string"])) {
|
||||
$string = safe_input ($search["string"]);
|
||||
$search_sql .= ' AND (nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%")';
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$search_sql .= ' AND (nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%")';
|
||||
break;
|
||||
case "postgresql":
|
||||
$search_sql .= ' AND (nombre COLLATE utf8_general_ci LIKE \'%'.$string.'%\' OR direccion LIKE \'%'.$string.'%\')';
|
||||
break;
|
||||
}
|
||||
|
||||
unset ($search["string"]);
|
||||
}
|
||||
|
@ -794,9 +801,9 @@ function get_agent_modules ($id_agent = null, $details = false, $filter = false,
|
|||
FROM tagente_modulo
|
||||
%s
|
||||
ORDER BY nombre',
|
||||
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
|
||||
safe_output(implode (",", (array) $details)),
|
||||
$where);
|
||||
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
|
||||
safe_output(implode (",", (array) $details)),
|
||||
$where);
|
||||
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
|
||||
|
@ -805,11 +812,11 @@ function get_agent_modules ($id_agent = null, $details = false, $filter = false,
|
|||
}
|
||||
|
||||
if (! $indexed)
|
||||
return $result;
|
||||
return $result;
|
||||
|
||||
$modules = array ();
|
||||
foreach ($result as $module) {
|
||||
if($get_not_init_modules || get_agentmodule_is_init($module['id_agente_modulo'])) {
|
||||
if ($get_not_init_modules || get_agentmodule_is_init($module['id_agente_modulo'])) {
|
||||
if (is_array ($details) || $details == '*') {
|
||||
//Just stack the information in array by ID
|
||||
$modules[$module['id_agente_modulo']] = $module;
|
||||
|
@ -836,11 +843,12 @@ function get_agent_modules_count ($id_agent = 0) {
|
|||
if (empty ($id_agent)) {
|
||||
//If the array proved empty or the agent is less than 1 (eg. -1)
|
||||
$filter = '';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$filter = sprintf (" WHERE id_agente IN (%s)", implode (",", (array) $id_agent));
|
||||
}
|
||||
|
||||
return (int) get_db_sql ("SELECT COUNT(*) FROM tagente_modulo".$filter);
|
||||
return (int) get_db_sql ("SELECT COUNT(*) FROM tagente_modulo" . $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1151,10 +1159,10 @@ function get_group_events ($id_group, $period, $date) {
|
|||
$datelimit = $date - $period;
|
||||
|
||||
$sql = sprintf ('SELECT * FROM tevento
|
||||
WHERE utimestamp > %d AND utimestamp <= %d
|
||||
AND id_grupo IN (%s)
|
||||
ORDER BY utimestamp ASC',
|
||||
$datelimit, $date, implode (",", $id_group));
|
||||
WHERE utimestamp > %d AND utimestamp <= %d
|
||||
AND id_grupo IN (%s)
|
||||
ORDER BY utimestamp ASC',
|
||||
$datelimit, $date, implode (",", $id_group));
|
||||
|
||||
return get_db_all_rows_sql ($sql);
|
||||
}
|
||||
|
@ -1180,9 +1188,12 @@ function get_agent_events ($id_agent, $period, $date = 0) {
|
|||
|
||||
$datelimit = $date - $period;
|
||||
|
||||
$sql = sprintf ('SELECT evento, event_type, criticity, count(*) as count_rep, max(timestamp) AS time2
|
||||
FROM tevento WHERE id_agente = %d AND utimestamp > %d AND utimestamp <= %d
|
||||
GROUP BY id_agentmodule, evento ORDER BY time2 DESC', $id_agent, $datelimit, $date);
|
||||
$sql = sprintf ('SELECT evento, event_type, criticity, count(*) as count_rep,
|
||||
max(timestamp) AS time2
|
||||
FROM tevento
|
||||
WHERE id_agente = %d AND utimestamp > %d AND utimestamp <= %d
|
||||
GROUP BY id_agentmodule, evento
|
||||
ORDER BY time2 DESC', $id_agent, $datelimit, $date);
|
||||
|
||||
return get_db_all_rows_sql ($sql);
|
||||
}
|
||||
|
@ -1209,7 +1220,8 @@ function get_module_events ($id_agent_module, $period, $date = 0) {
|
|||
$datelimit = $date - $period;
|
||||
|
||||
$sql = sprintf ('SELECT evento, event_type, criticity, count(*) as count_rep, max(timestamp) AS time2
|
||||
FROM tevento WHERE id_agentmodule = %d AND utimestamp > %d AND utimestamp <= %d
|
||||
FROM tevento
|
||||
WHERE id_agentmodule = %d AND utimestamp > %d AND utimestamp <= %d
|
||||
GROUP BY id_agentmodule, evento ORDER BY time2 DESC', $id_agent_module, $datelimit, $date);
|
||||
|
||||
return get_db_all_rows_sql ($sql);
|
||||
|
@ -1239,7 +1251,7 @@ function get_agent_alert_fired ($id_agent, $id_alert, $period, $date = 0) {
|
|||
$sql = sprintf ('SELECT timestamp
|
||||
FROM tevento
|
||||
WHERE id_agente = %d AND utimestamp > %d AND utimestamp <= %d
|
||||
AND id_alert_am = %d
|
||||
AND id_alert_am = %d
|
||||
ORDER BY timestamp DESC', $id_agent, $datelimit, $date, $id_alert);
|
||||
|
||||
return get_db_all_rows_sql ($sql);
|
||||
|
@ -1269,7 +1281,7 @@ function get_module_alert_fired ($id_agent_module, $id_alert, $period, $date = 0
|
|||
$sql = sprintf ('SELECT timestamp
|
||||
FROM tevento
|
||||
WHERE id_agentmodule = %d AND utimestamp > %d AND utimestamp <= %d
|
||||
AND id_alert_am = %d
|
||||
AND id_alert_am = %d
|
||||
ORDER BY timestamp DESC', $id_agent_module, $datelimit, $date, $id_alert);
|
||||
|
||||
return get_db_all_rows_sql ($sql);
|
||||
|
@ -1522,7 +1534,7 @@ function get_moduletypes ($type = "all", $rows = "nombre") {
|
|||
return array_merge (range (1,4), range (19,24));
|
||||
}
|
||||
|
||||
$sql = sprintf ("SELECT id_tipo,%s FROM ttipo_modulo", implode (",", $rows));
|
||||
$sql = sprintf ("SELECT id_tipo, %s FROM ttipo_modulo", implode (",", $rows));
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
if ($result === false) {
|
||||
return $return;
|
||||
|
@ -1564,8 +1576,6 @@ function get_agent_modules_data_count ($id_agent = 0) {
|
|||
$count["total"] = 0;
|
||||
|
||||
$query[0] = "SELECT COUNT(*) FROM tagente_datos";
|
||||
//$query[1] = "SELECT COUNT(*) FROM tagente_datos_inc";
|
||||
//$query[2] = "SELECT COUNT(*) FROM tagente_datos_string";
|
||||
|
||||
foreach ($id_agent as $agent_id) {
|
||||
//Init value
|
||||
|
@ -1614,12 +1624,13 @@ function check_alert_fired ($id_agent) {
|
|||
$sql = sprintf ("SELECT COUNT(*)
|
||||
FROM talert_template_modules, tagente_modulo
|
||||
WHERE talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
|
||||
AND times_fired > 0 AND id_agente = %d",
|
||||
AND times_fired > 0 AND id_agente = %d",
|
||||
$id_agent);
|
||||
|
||||
$value = get_db_sql ($sql);
|
||||
if ($value > 0)
|
||||
return true;
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2017,7 +2028,7 @@ function agent_add_address ($id_agent, $ip_address) {
|
|||
}
|
||||
$current_address = get_db_sql ($sql);
|
||||
if ($current_address > 0)
|
||||
return;
|
||||
return;
|
||||
|
||||
// Look for a record with this IP Address
|
||||
$id_address = (int) get_db_value ('id_a', 'taddress', 'ip', $ip_address);
|
||||
|
@ -2043,14 +2054,14 @@ function agent_delete_address ($id_agent, $ip_address) {
|
|||
|
||||
$sql = sprintf ("SELECT id_ag FROM taddress_agent, taddress
|
||||
WHERE taddress_agent.id_a = taddress.id_a AND ip = '%s'
|
||||
AND id_agent = %d",$ip_address, $id_agent);
|
||||
AND id_agent = %d", $ip_address, $id_agent);
|
||||
$id_ag = get_db_sql ($sql);
|
||||
if ($id_ag !== false) {
|
||||
process_sql_delete('taddress_agent', array('id_ag' => $id_ag));
|
||||
}
|
||||
$agent_name = get_agent_name($id_agent, "");
|
||||
pandora_audit("Agent management",
|
||||
"Deleted IP $ip_address from agent '$agent_name'");
|
||||
"Deleted IP $ip_address from agent '$agent_name'");
|
||||
|
||||
// Need to change main address?
|
||||
if (get_agent_address ($id_agent) == $ip_address) {
|
||||
|
@ -2081,11 +2092,24 @@ function get_agent_address ($id_agent) {
|
|||
* @return mixed The agent that has the IP address given. False if none were found.
|
||||
*/
|
||||
function get_agent_with_ip ($ip_address) {
|
||||
$sql = sprintf ('SELECT tagente.*
|
||||
FROM tagente, taddress, taddress_agent
|
||||
WHERE tagente.id_agente = taddress_agent.id_agent
|
||||
AND taddress_agent.id_a = taddress.id_a
|
||||
AND ip = "%s"', $ip_address);
|
||||
global $config;
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = sprintf ('SELECT tagente.*
|
||||
FROM tagente, taddress, taddress_agent
|
||||
WHERE tagente.id_agente = taddress_agent.id_agent
|
||||
AND taddress_agent.id_a = taddress.id_a
|
||||
AND ip = "%s"', $ip_address);
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = sprintf ('SELECT tagente.*
|
||||
FROM tagente, taddress, taddress_agent
|
||||
WHERE tagente.id_agente = taddress_agent.id_agent
|
||||
AND taddress_agent.id_a = taddress.id_a
|
||||
AND ip = \'%s\'', $ip_address);
|
||||
break;
|
||||
}
|
||||
|
||||
return get_db_row_sql ($sql);
|
||||
}
|
||||
|
@ -2098,9 +2122,10 @@ function get_agent_with_ip ($ip_address) {
|
|||
* @return array Array with the IP address of the given agent or an empty array.
|
||||
*/
|
||||
function get_agent_addresses ($id_agent) {
|
||||
$sql = sprintf ("SELECT ip FROM taddress_agent, taddress
|
||||
$sql = sprintf ("SELECT ip
|
||||
FROM taddress_agent, taddress
|
||||
WHERE taddress_agent.id_a = taddress.id_a
|
||||
AND id_agent = %d", $id_agent);
|
||||
AND id_agent = %d", $id_agent);
|
||||
|
||||
$ips = get_db_all_rows_sql ($sql);
|
||||
|
||||
|
@ -2861,9 +2886,9 @@ function get_module_status ($id_module = 0) {
|
|||
$status = get_db_sql ("SELECT estado
|
||||
FROM tagente_estado, tagente_modulo
|
||||
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.delete_pending = 0
|
||||
AND tagente_modulo.id_agente_modulo = ".$id_module);
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.delete_pending = 0
|
||||
AND tagente_modulo.id_agente_modulo = ".$id_module);
|
||||
|
||||
// TODO: Check any alert for that agent who has recept alerts fired
|
||||
|
||||
|
@ -2920,7 +2945,7 @@ function get_layoutdata_y ($id_layoutdata){
|
|||
*/
|
||||
function get_previous_data ($id_agent_module, $utimestamp = 0, $string = 0) {
|
||||
if (empty ($utimestamp))
|
||||
$utimestamp = time ();
|
||||
$utimestamp = time ();
|
||||
|
||||
if ($string == 1) {
|
||||
$table = 'tagente_datos_string';
|
||||
|
@ -2930,11 +2955,13 @@ function get_previous_data ($id_agent_module, $utimestamp = 0, $string = 0) {
|
|||
}
|
||||
|
||||
// 172800 = 60×60×24*2 Search up to 2 days before utimestamp
|
||||
$sql = sprintf ('SELECT * FROM ' . $table . ' WHERE id_agente_modulo = %d
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM ' . $table . '
|
||||
WHERE id_agente_modulo = %d
|
||||
AND utimestamp <= %d
|
||||
AND utimestamp >= %d
|
||||
ORDER BY utimestamp DESC',
|
||||
$id_agent_module, $utimestamp, $utimestamp - 172800);
|
||||
ORDER BY utimestamp DESC',
|
||||
$id_agent_module, $utimestamp, $utimestamp - 172800);
|
||||
|
||||
return get_db_row_sql ($sql, true);
|
||||
}
|
||||
|
@ -2950,7 +2977,7 @@ function get_previous_data ($id_agent_module, $utimestamp = 0, $string = 0) {
|
|||
*/
|
||||
function get_next_data ($id_agent_module, $utimestamp = 0, $string = 0) {
|
||||
if (empty ($utimestamp))
|
||||
$utimestamp = time ();
|
||||
$utimestamp = time ();
|
||||
|
||||
if ($string == 1) {
|
||||
$table = 'tagente_datos_string';
|
||||
|
@ -2960,12 +2987,13 @@ function get_next_data ($id_agent_module, $utimestamp = 0, $string = 0) {
|
|||
}
|
||||
|
||||
$interval = get_module_interval ($id_agent_module);
|
||||
$sql = sprintf ('SELECT * FROM tagente_datos
|
||||
WHERE id_agente_modulo = %d
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM tagente_datos
|
||||
WHERE id_agente_modulo = %d
|
||||
AND utimestamp <= %d
|
||||
AND utimestamp >= %d
|
||||
ORDER BY utimestamp ASC',
|
||||
$id_agent_module, $utimestamp + $interval, $utimestamp);
|
||||
ORDER BY utimestamp ASC',
|
||||
$id_agent_module, $utimestamp + $interval, $utimestamp);
|
||||
|
||||
return get_db_row_sql ($sql, true);
|
||||
}
|
||||
|
@ -2986,8 +3014,11 @@ function get_agentmodule_data ($id_agent_module, $period, $date = 0) {
|
|||
|
||||
$datelimit = $date - $period;
|
||||
|
||||
$sql = sprintf ("SELECT datos AS data, utimestamp FROM tagente_datos WHERE id_agente_modulo = %d
|
||||
AND utimestamp > %d AND utimestamp <= %d ORDER BY utimestamp ASC",
|
||||
$sql = sprintf ("SELECT datos AS data, utimestamp
|
||||
FROM tagente_datos
|
||||
WHERE id_agente_modulo = %d
|
||||
AND utimestamp > %d AND utimestamp <= %d
|
||||
ORDER BY utimestamp ASC",
|
||||
$id_agent_module, $datelimit, $date);
|
||||
|
||||
$values = get_db_all_rows_sql ($sql, true, false);
|
||||
|
@ -3152,9 +3183,10 @@ function delete_agent ($id_agents, $disableACL = false) {
|
|||
$where_modules = "ANY(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = ".$id_agent.")";
|
||||
|
||||
//IP address
|
||||
$sql = sprintf ("SELECT id_ag FROM taddress_agent, taddress
|
||||
$sql = sprintf ("SELECT id_ag
|
||||
FROM taddress_agent, taddress
|
||||
WHERE taddress_agent.id_a = taddress.id_a
|
||||
AND id_agent = %d",
|
||||
AND id_agent = %d",
|
||||
$id_agent);
|
||||
$addresses = get_db_all_rows_sql ($sql);
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@ function get_exportservers ($active = 1) {
|
|||
|
||||
if ($active == 1) {
|
||||
$servers = get_db_all_rows_sql ($query.' AND status = 1');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$servers = get_db_all_rows_sql ($query);
|
||||
}
|
||||
|
||||
|
|
|
@ -392,8 +392,12 @@ function getAgentsLayer($idLayer, $fields = null) {
|
|||
$select = implode(',',$fields);
|
||||
}
|
||||
|
||||
$agents = get_db_all_rows_sql('SELECT ' . $select . ' FROM tagente WHERE id_agente IN (
|
||||
SELECT tagente_id_agente FROM tgis_map_layer_has_tagente WHERE tgis_map_layer_id_tmap_layer = ' . $idLayer . ');');
|
||||
$agents = get_db_all_rows_sql('SELECT ' . $select . '
|
||||
FROM tagente
|
||||
WHERE id_agente IN (
|
||||
SELECT tagente_id_agente
|
||||
FROM tgis_map_layer_has_tagente
|
||||
WHERE tgis_map_layer_id_tmap_layer = ' . $idLayer . ');');
|
||||
|
||||
if ($agents !== false) {
|
||||
foreach ($agents as $index => $agent) {
|
||||
|
@ -431,8 +435,10 @@ function getMaps() {
|
|||
* @return An array of arrays of configuration parameters
|
||||
*/
|
||||
function getMapConf($idMap) {
|
||||
$mapConfs= get_db_all_rows_sql('SELECT tconn.*, trel.default_map_connection FROM tgis_map_connection AS tconn, tgis_map_has_tgis_map_connection AS trel
|
||||
WHERE trel.tgis_map_connection_id_tmap_connection = tconn.id_tmap_connection AND trel.tgis_map_id_tgis_map = ' . $idMap);
|
||||
$mapConfs= get_db_all_rows_sql('SELECT tconn.*, trel.default_map_connection
|
||||
FROM tgis_map_connection AS tconn, tgis_map_has_tgis_map_connection AS trel
|
||||
WHERE trel.tgis_map_connection_id_tmap_connection = tconn.id_tmap_connection
|
||||
AND trel.tgis_map_id_tgis_map = ' . $idMap);
|
||||
return $mapConfs;
|
||||
}
|
||||
|
||||
|
@ -441,7 +447,9 @@ function getMapConnection($idMapConnection) {
|
|||
}
|
||||
|
||||
function getLayers($idMap) {
|
||||
$layers = get_db_all_rows_sql('SELECT * FROM tgis_map_layer WHERE tgis_map_id_tgis_map = ' . $idMap);
|
||||
$layers = get_db_all_rows_sql('SELECT *
|
||||
FROM tgis_map_layer
|
||||
WHERE tgis_map_id_tgis_map = ' . $idMap);
|
||||
|
||||
return $layers;
|
||||
}
|
||||
|
@ -1037,26 +1045,36 @@ function getMapData($idMap) {
|
|||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$connections = get_db_all_rows_sql('SELECT t1.tgis_map_connection_id_tmap_connection AS id_conection,
|
||||
t1.default_map_connection AS `default`,
|
||||
(SELECT t2.num_zoom_levels
|
||||
FROM tgis_map_connection AS t2 WHERE t2.id_tmap_connection = t1.tgis_map_connection_id_tmap_connection) AS num_zoom_levels
|
||||
FROM tgis_map_has_tgis_map_connection AS t1 WHERE t1.tgis_map_id_tgis_map = '. $map['id_tgis_map']);
|
||||
t1.default_map_connection AS `default`, (
|
||||
SELECT t2.num_zoom_levels
|
||||
FROM tgis_map_connection AS t2
|
||||
WHERE t2.id_tmap_connection = t1.tgis_map_connection_id_tmap_connection) AS num_zoom_levels
|
||||
FROM tgis_map_has_tgis_map_connection AS t1
|
||||
WHERE t1.tgis_map_id_tgis_map = '. $map['id_tgis_map']);
|
||||
break;
|
||||
case "postgresql":
|
||||
$connections = get_db_all_rows_sql('SELECT t1.tgis_map_connection_id_tmap_connection AS id_conection,
|
||||
t1.default_map_connection AS "default",
|
||||
(SELECT t2.num_zoom_levels
|
||||
FROM tgis_map_connection AS t2 WHERE t2.id_tmap_connection = t1.tgis_map_connection_id_tmap_connection) AS num_zoom_levels
|
||||
FROM tgis_map_has_tgis_map_connection AS t1 WHERE t1.tgis_map_id_tgis_map = '. $map['id_tgis_map']);
|
||||
t1.default_map_connection AS "default", (
|
||||
SELECT t2.num_zoom_levels
|
||||
FROM tgis_map_connection AS t2
|
||||
WHERE t2.id_tmap_connection = t1.tgis_map_connection_id_tmap_connection) AS num_zoom_levels
|
||||
FROM tgis_map_has_tgis_map_connection AS t1
|
||||
WHERE t1.tgis_map_id_tgis_map = '. $map['id_tgis_map']);
|
||||
break;
|
||||
}
|
||||
$layers = get_db_all_rows_sql('SELECT id_tmap_layer, layer_name, tgrupo_id_grupo AS layer_group, view_layer AS layer_visible FROM tgis_map_layer WHERE tgis_map_id_tgis_map = ' . $map['id_tgis_map']);
|
||||
$layers = get_db_all_rows_sql('SELECT id_tmap_layer, layer_name,
|
||||
tgrupo_id_grupo AS layer_group, view_layer AS layer_visible
|
||||
FROM tgis_map_layer
|
||||
WHERE tgis_map_id_tgis_map = ' . $map['id_tgis_map']);
|
||||
if ($layers === false) $layers = array();
|
||||
|
||||
foreach ($layers as $index => $layer) {
|
||||
$agents = get_db_all_rows_sql('SELECT nombre
|
||||
FROM tagente
|
||||
WHERE id_agente IN (SELECT tagente_id_agente FROM tgis_map_layer_has_tagente WHERE tgis_map_layer_id_tmap_layer = ' . $layer['id_tmap_layer'] . ')');
|
||||
WHERE id_agente IN (
|
||||
SELECT tagente_id_agente
|
||||
FROM tgis_map_layer_has_tagente
|
||||
WHERE tgis_map_layer_id_tmap_layer = ' . $layer['id_tmap_layer'] . ')');
|
||||
if ($agents !== false)
|
||||
$layers[$index]['layer_agent_list'] = $agents;
|
||||
else
|
||||
|
|
|
@ -116,16 +116,19 @@ function print_select_style ($fields, $name, $selected = '', $style='', $script
|
|||
$output .= '<option value="'.$value.'"';
|
||||
if (is_array ($selected) && in_array ($value, $selected)) {
|
||||
$output .= ' selected="selected"';
|
||||
} elseif (is_numeric ($value) && is_numeric ($selected) && $value == $selected) {
|
||||
}
|
||||
elseif (is_numeric ($value) && is_numeric ($selected) && $value == $selected) {
|
||||
//This fixes string ($value) to int ($selected) comparisons
|
||||
$output .= ' selected="selected"';
|
||||
} elseif ($value === $selected) {
|
||||
}
|
||||
elseif ($value === $selected) {
|
||||
//Needs type comparison otherwise if $selected = 0 and $value = "string" this would evaluate to true
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
if ($label === '') {
|
||||
$output .= '>'.$value."</option>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$output .= '>'.$label."</option>";
|
||||
}
|
||||
}
|
||||
|
@ -288,10 +291,12 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing =
|
|||
$output .= '<option value="'.$value.'"';
|
||||
if (is_array ($selected) && in_array ($value, $selected)) {
|
||||
$output .= ' selected="selected"';
|
||||
} elseif (is_numeric ($value) && is_numeric ($selected) && $value == $selected) {
|
||||
}
|
||||
elseif (is_numeric ($value) && is_numeric ($selected) && $value == $selected) {
|
||||
//This fixes string ($value) to int ($selected) comparisons
|
||||
$output .= ' selected="selected"';
|
||||
} elseif ($value === $selected) {
|
||||
}
|
||||
elseif ($value === $selected) {
|
||||
//Needs type comparison otherwise if $selected = 0 and $value = "string" this would evaluate to true
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
|
@ -300,7 +305,8 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing =
|
|||
}
|
||||
if ($optlabel === '') {
|
||||
$output .= '>'.$value."</option>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$output .= '>'.$optlabel."</option>";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,9 @@ function process_message_read ($message_id, $read = true) {
|
|||
function get_message ($message_id) {
|
||||
global $config;
|
||||
|
||||
$sql = sprintf("SELECT id_usuario_origen, subject, mensaje, timestamp FROM tmensajes WHERE id_usuario_destino='%s' AND id_mensaje=%d" , $config["id_user"], $message_id);
|
||||
$sql = sprintf("SELECT id_usuario_origen, subject, mensaje, timestamp
|
||||
FROM tmensajes
|
||||
WHERE id_usuario_destino='%s' AND id_mensaje=%d" , $config["id_user"], $message_id);
|
||||
$row = get_db_row_sql ($sql);
|
||||
|
||||
if (empty ($row)) {
|
||||
|
@ -174,7 +176,8 @@ function get_message_count ($user = false, $incl_read = false) {
|
|||
} else {
|
||||
$filter = "";
|
||||
}
|
||||
$sql = sprintf("SELECT COUNT(*) FROM tmensajes WHERE id_usuario_destino='%s' %s", $user, $filter);
|
||||
$sql = sprintf("SELECT COUNT(*)
|
||||
FROM tmensajes WHERE id_usuario_destino='%s' %s", $user, $filter);
|
||||
|
||||
return (int) get_db_sql ($sql);
|
||||
}
|
||||
|
@ -199,6 +202,7 @@ function get_message_overview ($order = "status", $order_dir = "ASC") {
|
|||
case "status":
|
||||
default:
|
||||
$order = "estado";
|
||||
break;
|
||||
}
|
||||
|
||||
if ($order_dir != "ASC") {
|
||||
|
|
|
@ -205,7 +205,8 @@ function generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $font_size
|
|||
foreach ($modules as $key => $module) {
|
||||
$node_count ++;
|
||||
$agent_module = get_agentmodule($key);
|
||||
$alerts_module = get_db_sql('SELECT count(*) as num FROM talert_template_modules WHERE id_agent_module = '.$key);
|
||||
$alerts_module = get_db_sql('SELECT count(*) as num
|
||||
FROM talert_template_modules WHERE id_agent_module = '.$key);
|
||||
|
||||
if($alerts_module == 0 && $modwithalerts){
|
||||
continue;
|
||||
|
|
|
@ -61,7 +61,8 @@ function get_agentmodule_data_average ($id_agent_module, $period, $date = 0) {
|
|||
$min_necessary = 1;
|
||||
|
||||
// Compressed module data
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Get previous data
|
||||
$previous_data = get_previous_data ($id_agent_module, $datelimit);
|
||||
if ($previous_data !== false) {
|
||||
|
@ -74,7 +75,8 @@ function get_agentmodule_data_average ($id_agent_module, $period, $date = 0) {
|
|||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
} else if (count ($interval_data) > 0) {
|
||||
}
|
||||
else if (count ($interval_data) > 0) {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
|
@ -99,7 +101,8 @@ function get_agentmodule_data_average ($id_agent_module, $period, $date = 0) {
|
|||
if (! $uncompressed_module) {
|
||||
$total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']);
|
||||
$previous_data = $data;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$total += $data['datos'];
|
||||
$count++;
|
||||
}
|
||||
|
@ -313,7 +316,8 @@ function get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) {
|
|||
$min_necessary = 1;
|
||||
|
||||
// Compressed module data
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Get previous data
|
||||
$previous_data = get_previous_data ($id_agent_module, $datelimit);
|
||||
if ($previous_data !== false) {
|
||||
|
@ -326,7 +330,8 @@ function get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) {
|
|||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
} else if (count ($interval_data) > 0) {
|
||||
}
|
||||
else if (count ($interval_data) > 0) {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
|
@ -350,9 +355,11 @@ function get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) {
|
|||
foreach ($interval_data as $data) {
|
||||
if ($uncompressed_module) {
|
||||
$total += $data['datos'];
|
||||
} else if ($module_inc) {
|
||||
}
|
||||
else if ($module_inc) {
|
||||
$total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']) / $module_interval;
|
||||
}
|
||||
$previous_data = $data;
|
||||
|
@ -389,9 +396,9 @@ function get_agentmodule_sla ($id_agent_module, $period = 0, $min_value = 1, $ma
|
|||
|
||||
// Get interval data
|
||||
$sql = sprintf ('SELECT * FROM tagente_datos
|
||||
WHERE id_agente_modulo = %d
|
||||
WHERE id_agente_modulo = %d
|
||||
AND utimestamp > %d AND utimestamp <= %d',
|
||||
$id_agent_module, $datelimit, $date);
|
||||
$id_agent_module, $datelimit, $date);
|
||||
|
||||
//Add the working times (mon - tue - wed ...) and from time to time
|
||||
$days = array();
|
||||
|
@ -451,7 +458,8 @@ function get_agentmodule_sla ($id_agent_module, $period = 0, $min_value = 1, $ma
|
|||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
} else if (count ($interval_data) > 0) {
|
||||
}
|
||||
else if (count ($interval_data) > 0) {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
|
@ -554,7 +562,10 @@ function get_group_stats ($id_group = 0) {
|
|||
}
|
||||
|
||||
foreach ($id_group as $group){
|
||||
$group_stat = get_db_all_rows_sql ("SELECT * FROM tgroup_stat, tgrupo WHERE tgrupo.id_grupo = tgroup_stat.id_group AND tgroup_stat.id_group = $group ORDER BY nombre");
|
||||
$group_stat = get_db_all_rows_sql ("SELECT *
|
||||
FROM tgroup_stat, tgrupo
|
||||
WHERE tgrupo.id_grupo = tgroup_stat.id_group AND tgroup_stat.id_group = $group
|
||||
ORDER BY nombre");
|
||||
$data["monitor_checks"] += $group_stat[0]["modules"];
|
||||
$data["monitor_not_init"] += $group_stat[0]["non-init"];
|
||||
$data["monitor_unknown"] += $group_stat[0]["unknown"];
|
||||
|
@ -646,15 +657,17 @@ function get_group_stats ($id_group = 0) {
|
|||
$data["monitor_critical"] += get_db_sql ("SELECT COUNT(tagente_estado.id_agente_estado)
|
||||
FROM tagente_estado, tagente, tagente_modulo
|
||||
WHERE tagente.id_grupo = $group AND tagente.disabled = 0
|
||||
AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0 AND estado = 1 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0");
|
||||
AND tagente_estado.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0 AND estado = 1
|
||||
AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0");
|
||||
break;
|
||||
case "postgresql":
|
||||
$data["monitor_critical"] += get_db_sql ("SELECT COUNT(tagente_estado.id_agente_estado)
|
||||
FROM tagente_estado, tagente, tagente_modulo
|
||||
WHERE tagente.id_grupo = $group AND tagente.disabled = 0
|
||||
AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0 AND estado = 1 AND ((ceil(date_part('epoch', CURRENT_TIMESTAMP)) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0");
|
||||
AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0 AND estado = 1 AND ((ceil(date_part('epoch', CURRENT_TIMESTAMP)) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -663,17 +676,17 @@ function get_group_stats ($id_group = 0) {
|
|||
$data["monitor_warning"] += get_db_sql ("SELECT COUNT(tagente_estado.id_agente_estado)
|
||||
FROM tagente_estado, tagente, tagente_modulo
|
||||
WHERE tagente.id_grupo = $group AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0
|
||||
AND estado = 2 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)
|
||||
OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0");
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0
|
||||
AND estado = 2 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)
|
||||
OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0");
|
||||
break;
|
||||
case "postgresql":
|
||||
$data["monitor_warning"] += get_db_sql ("SELECT COUNT(tagente_estado.id_agente_estado)
|
||||
FROM tagente_estado, tagente, tagente_modulo
|
||||
WHERE tagente.id_grupo = $group AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0
|
||||
AND estado = 2 AND ((ceil(date_part('epoch', CURRENT_TIMESTAMP)) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)
|
||||
OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0");
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0
|
||||
AND estado = 2 AND ((ceil(date_part('epoch', CURRENT_TIMESTAMP)) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)
|
||||
OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -682,39 +695,39 @@ function get_group_stats ($id_group = 0) {
|
|||
$data["monitor_unknown"] += get_db_sql ("SELECT COUNT(tagente_estado.id_agente_estado)
|
||||
FROM tagente_estado, tagente, tagente_modulo
|
||||
WHERE tagente.id_grupo = $group AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0
|
||||
AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN(21,22,23,24,100)
|
||||
AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2)");
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0
|
||||
AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN(21,22,23,24,100)
|
||||
AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2)");
|
||||
break;
|
||||
case "postgresql":
|
||||
$data["monitor_unknown"] += get_db_sql ("SELECT COUNT(tagente_estado.id_agente_estado)
|
||||
FROM tagente_estado, tagente, tagente_modulo
|
||||
WHERE tagente.id_grupo = $group AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0
|
||||
AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN(21,22,23,24,100)
|
||||
AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2)");
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0
|
||||
AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN(21,22,23,24,100)
|
||||
AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2)");
|
||||
break;
|
||||
}
|
||||
|
||||
$data["monitor_not_init"] += get_db_sql ("SELECT COUNT(tagente_estado.id_agente_estado)
|
||||
FROM tagente_estado, tagente, tagente_modulo
|
||||
WHERE tagente.id_grupo = $group AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,24) AND utimestamp = 0");
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,24) AND utimestamp = 0");
|
||||
|
||||
$data["monitor_alerts"] += get_db_sql ("SELECT COUNT(talert_template_modules.id)
|
||||
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
|
||||
WHERE tagente.id_grupo = $group AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0 AND tagente.disabled = 0
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo");
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0 AND tagente.disabled = 0
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo");
|
||||
|
||||
$data["monitor_alerts_fired"] += get_db_sql ("SELECT COUNT(talert_template_modules.id)
|
||||
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
|
||||
WHERE tagente.id_grupo = $group AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0 AND tagente.disabled = 0
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo AND times_fired > 0");
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0 AND tagente.disabled = 0
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo AND times_fired > 0");
|
||||
}
|
||||
/*
|
||||
Monitor health (percentage)
|
||||
|
@ -2330,7 +2343,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
|
|||
$result = get_db_all_rows_sql('SELECT *
|
||||
FROM tagente_datos_string
|
||||
WHERE id_agente_modulo = ' . $content['id_agent_module'] . '
|
||||
AND utimestamp > ' . $datelimit . ' AND utimestamp <= ' . $report["datetime"]);
|
||||
AND utimestamp > ' . $datelimit . '
|
||||
AND utimestamp <= ' . $report["datetime"]);
|
||||
if ($result === false) {
|
||||
$result = array();
|
||||
}
|
||||
|
@ -2485,8 +2499,8 @@ function get_agentmodule_mtbf ($id_agent_module, $period, $date = 0) {
|
|||
// Read module configuration
|
||||
$datelimit = $date - $period;
|
||||
$module = get_db_row_sql ('SELECT max_critical, min_critical, id_tipo_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module);
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module);
|
||||
if ($module === false) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2504,10 +2518,10 @@ function get_agentmodule_mtbf ($id_agent_module, $period, $date = 0) {
|
|||
|
||||
// Get module data
|
||||
$interval_data = get_db_all_rows_sql ('SELECT * FROM tagente_datos
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
||||
' AND utimestamp > ' . (int) $datelimit .
|
||||
' AND utimestamp < ' . (int) $date .
|
||||
' ORDER BY utimestamp ASC', true);
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
||||
' AND utimestamp > ' . (int) $datelimit .
|
||||
' AND utimestamp < ' . (int) $date .
|
||||
' ORDER BY utimestamp ASC', true);
|
||||
if ($interval_data === false) $interval_data = array ();
|
||||
|
||||
// Get previous data
|
||||
|
@ -2522,7 +2536,8 @@ function get_agentmodule_mtbf ($id_agent_module, $period, $date = 0) {
|
|||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
} else if (count ($interval_data) > 0) {
|
||||
}
|
||||
else if (count ($interval_data) > 0) {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
|
@ -2542,7 +2557,8 @@ function get_agentmodule_mtbf ($id_agent_module, $period, $date = 0) {
|
|||
($critical_max <= $critical_min AND $first_data['datos'] < $critical_min)) {
|
||||
$previous_status = 1;
|
||||
$critical_count = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$previous_status = 0;
|
||||
$critical_count = 0;
|
||||
}
|
||||
|
@ -2560,7 +2576,8 @@ function get_agentmodule_mtbf ($id_agent_module, $period, $date = 0) {
|
|||
$critical_count++;
|
||||
}
|
||||
$previous_status = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$previous_status = 0;
|
||||
}
|
||||
|
||||
|
@ -2593,8 +2610,8 @@ function get_agentmodule_mttr ($id_agent_module, $period, $date = 0) {
|
|||
// Read module configuration
|
||||
$datelimit = $date - $period;
|
||||
$module = get_db_row_sql ('SELECT max_critical, min_critical, id_tipo_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module);
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module);
|
||||
if ($module === false) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2612,10 +2629,10 @@ function get_agentmodule_mttr ($id_agent_module, $period, $date = 0) {
|
|||
|
||||
// Get module data
|
||||
$interval_data = get_db_all_rows_sql ('SELECT * FROM tagente_datos
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
||||
' AND utimestamp > ' . (int) $datelimit .
|
||||
' AND utimestamp < ' . (int) $date .
|
||||
' ORDER BY utimestamp ASC', true);
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
||||
' AND utimestamp > ' . (int) $datelimit .
|
||||
' AND utimestamp < ' . (int) $date .
|
||||
' ORDER BY utimestamp ASC', true);
|
||||
if ($interval_data === false) $interval_data = array ();
|
||||
|
||||
// Get previous data
|
||||
|
@ -2630,7 +2647,8 @@ function get_agentmodule_mttr ($id_agent_module, $period, $date = 0) {
|
|||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
} else if (count ($interval_data) > 0) {
|
||||
}
|
||||
else if (count ($interval_data) > 0) {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
|
@ -2650,7 +2668,8 @@ function get_agentmodule_mttr ($id_agent_module, $period, $date = 0) {
|
|||
($critical_max <= $critical_min AND $first_data['datos'] < $critical_min)) {
|
||||
$previous_status = 1;
|
||||
$critical_count = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$previous_status = 0;
|
||||
$critical_count = 0;
|
||||
}
|
||||
|
@ -2668,7 +2687,8 @@ function get_agentmodule_mttr ($id_agent_module, $period, $date = 0) {
|
|||
$critical_count++;
|
||||
}
|
||||
$previous_status = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$previous_status = 0;
|
||||
}
|
||||
|
||||
|
@ -2700,8 +2720,8 @@ function get_agentmodule_tto ($id_agent_module, $period, $date = 0) {
|
|||
// Read module configuration
|
||||
$datelimit = $date - $period;
|
||||
$module = get_db_row_sql ('SELECT max_critical, min_critical, id_tipo_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module);
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module);
|
||||
if ($module === false) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2719,10 +2739,10 @@ function get_agentmodule_tto ($id_agent_module, $period, $date = 0) {
|
|||
|
||||
// Get module data
|
||||
$interval_data = get_db_all_rows_sql ('SELECT * FROM tagente_datos
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
||||
' AND utimestamp > ' . (int) $datelimit .
|
||||
' AND utimestamp < ' . (int) $date .
|
||||
' ORDER BY utimestamp ASC', true);
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
||||
' AND utimestamp > ' . (int) $datelimit .
|
||||
' AND utimestamp < ' . (int) $date .
|
||||
' ORDER BY utimestamp ASC', true);
|
||||
if ($interval_data === false) $interval_data = array ();
|
||||
|
||||
// Get previous data
|
||||
|
@ -2737,7 +2757,8 @@ function get_agentmodule_tto ($id_agent_module, $period, $date = 0) {
|
|||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
} else if (count ($interval_data) > 0) {
|
||||
}
|
||||
else if (count ($interval_data) > 0) {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
|
@ -2756,7 +2777,8 @@ function get_agentmodule_tto ($id_agent_module, $period, $date = 0) {
|
|||
if ((($critical_max > $critical_min AND ($first_data['datos'] > $critical_max OR $first_data['datos'] < $critical_min))) OR
|
||||
($critical_max <= $critical_min AND $first_data['datos'] < $critical_min)) {
|
||||
$previous_status = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$previous_status = 0;
|
||||
}
|
||||
|
||||
|
@ -2770,7 +2792,8 @@ function get_agentmodule_tto ($id_agent_module, $period, $date = 0) {
|
|||
if ((($critical_max > $critical_min AND ($data['datos'] > $critical_max OR $data['datos'] < $critical_min))) OR
|
||||
($critical_max <= $critical_min AND $data['datos'] < $critical_min)) {
|
||||
$previous_status = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$previous_status = 0;
|
||||
}
|
||||
|
||||
|
@ -2798,8 +2821,8 @@ function get_agentmodule_ttr ($id_agent_module, $period, $date = 0) {
|
|||
// Read module configuration
|
||||
$datelimit = $date - $period;
|
||||
$module = get_db_row_sql ('SELECT max_critical, min_critical, id_tipo_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module);
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module);
|
||||
if ($module === false) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2817,10 +2840,10 @@ function get_agentmodule_ttr ($id_agent_module, $period, $date = 0) {
|
|||
|
||||
// Get module data
|
||||
$interval_data = get_db_all_rows_sql ('SELECT * FROM tagente_datos
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
||||
' AND utimestamp > ' . (int) $datelimit .
|
||||
' AND utimestamp < ' . (int) $date .
|
||||
' ORDER BY utimestamp ASC', true);
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
||||
' AND utimestamp > ' . (int) $datelimit .
|
||||
' AND utimestamp < ' . (int) $date .
|
||||
' ORDER BY utimestamp ASC', true);
|
||||
if ($interval_data === false) $interval_data = array ();
|
||||
|
||||
// Get previous data
|
||||
|
@ -2835,7 +2858,8 @@ function get_agentmodule_ttr ($id_agent_module, $period, $date = 0) {
|
|||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
} else if (count ($interval_data) > 0) {
|
||||
}
|
||||
else if (count ($interval_data) > 0) {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
|
@ -2854,7 +2878,8 @@ function get_agentmodule_ttr ($id_agent_module, $period, $date = 0) {
|
|||
if ((($critical_max > $critical_min AND ($first_data['datos'] > $critical_max OR $first_data['datos'] < $critical_min))) OR
|
||||
($critical_max <= $critical_min AND $first_data['datos'] < $critical_min)) {
|
||||
$previous_status = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$previous_status = 0;
|
||||
}
|
||||
|
||||
|
@ -2868,7 +2893,8 @@ function get_agentmodule_ttr ($id_agent_module, $period, $date = 0) {
|
|||
if ((($critical_max > $critical_min AND ($data['datos'] > $critical_max OR $data['datos'] < $critical_min))) OR
|
||||
($critical_max <= $critical_min AND $data['datos'] < $critical_min)) {
|
||||
$previous_status = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$previous_status = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,12 +70,19 @@ function get_server_performance () {
|
|||
// Get total modules running
|
||||
|
||||
if ($config["realtimestats"] == 1){
|
||||
$data["total_remote_modules"] = get_db_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.id_modulo != 1 AND disabled = 0 AND utimestamp > 0");
|
||||
} else {
|
||||
$data["total_remote_modules"] = get_db_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo)
|
||||
FROM tagente_modulo, tagente_estado
|
||||
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND tagente_modulo.id_modulo != 1 AND disabled = 0 AND utimestamp > 0");
|
||||
}
|
||||
else {
|
||||
$data["total_remote_modules"] = get_db_sql ("SELECT SUM(my_modules) FROM tserver WHERE server_type != 0");
|
||||
}
|
||||
|
||||
$data["avg_interval_remote_modules"] = get_db_sql ("SELECT AVG(module_interval) FROM tagente_modulo, tagente_estado where tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND disabled = 0 AND id_modulo != 1 AND module_interval > 0 AND utimestamp > 0");
|
||||
$data["avg_interval_remote_modules"] = get_db_sql ("SELECT AVG(module_interval)
|
||||
FROM tagente_modulo, tagente_estado
|
||||
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND disabled = 0 AND id_modulo != 1 AND module_interval > 0 AND utimestamp > 0");
|
||||
|
||||
if ($data["total_remote_modules"] == 0)
|
||||
$data["remote_modules_rate"] = 0;
|
||||
|
@ -84,8 +91,12 @@ function get_server_performance () {
|
|||
|
||||
// For local modules (ignoring local modules with custom invervals for simplicity).
|
||||
if ($config["realtimestats"] == 1){
|
||||
$data["total_local_modules"] = get_db_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND id_modulo = 1 AND disabled = 0 AND utimestamp > 0");
|
||||
} else {
|
||||
$data["total_local_modules"] = get_db_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo)
|
||||
FROM tagente_modulo, tagente_estado
|
||||
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND id_modulo = 1 AND disabled = 0 AND utimestamp > 0");
|
||||
}
|
||||
else {
|
||||
$data["total_local_modules"] = get_db_sql ("SELECT SUM(my_modules) FROM tserver WHERE server_type = 0");
|
||||
}
|
||||
|
||||
|
@ -93,7 +104,8 @@ function get_server_performance () {
|
|||
|
||||
if ($data["avg_interval_local_modules"] > 0){
|
||||
$data["local_modules_rate"] = $data["total_local_modules"] / $data["avg_interval_local_modules"];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$data["local_modules_rate"] = 0;
|
||||
}
|
||||
|
||||
|
@ -134,63 +146,62 @@ function get_server_info ($id_server = -1) {
|
|||
|
||||
$return = array ();
|
||||
foreach ($result as $server) {
|
||||
|
||||
switch ($server['server_type']) {
|
||||
case 0:
|
||||
$server["img"] = print_image ("images/data.png", true, array ("title" => __('Data server')));
|
||||
$server["type"] = "data";
|
||||
$id_modulo = 1;
|
||||
break;
|
||||
case 1:
|
||||
$server["img"] = print_image ("images/network.png", true, array ("title" => __('Network server')));
|
||||
$server["type"] = "network";
|
||||
$id_modulo = 2;
|
||||
break;
|
||||
case 2:
|
||||
$server["img"] = print_image ("images/snmp.png", true, array ("title" => __('SNMP server')));
|
||||
$server["type"] = "snmp";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 3:
|
||||
$server["img"] = print_image ("images/recon.png", true, array ("title" => __('Recon server')));
|
||||
$server["type"] = "recon";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 4:
|
||||
$server["img"] = print_image ("images/plugin.png", true, array ("title" => __('Plugin server')));
|
||||
$server["type"] = "plugin";
|
||||
$id_modulo = 4;
|
||||
break;
|
||||
case 5:
|
||||
$server["img"] = print_image ("images/chart_bar.png", true, array ("title" => __('Prediction server')));
|
||||
$server["type"] = "prediction";
|
||||
$id_modulo = 5;
|
||||
break;
|
||||
case 6:
|
||||
$server["img"] = print_image ("images/wmi.png", true, array ("title" => __('WMI server')));
|
||||
$server["type"] = "wmi";
|
||||
$id_modulo = 6;
|
||||
break;
|
||||
case 7:
|
||||
$server["img"] = print_image ("images/server_export.png", true, array ("title" => __('Export server')));
|
||||
$server["type"] = "export";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 8:
|
||||
$server["img"] = print_image ("images/page_white_text.png", true, array ("title" => __('Inventory server')));
|
||||
$server["type"] = "inventory";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 9:
|
||||
$server["img"] = print_image ("images/world.png", true, array ("title" => __('Web server')));
|
||||
$server["type"] = "web";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
default:
|
||||
$server["img"] = '';
|
||||
$server["type"] = "unknown";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 0:
|
||||
$server["img"] = print_image ("images/data.png", true, array ("title" => __('Data server')));
|
||||
$server["type"] = "data";
|
||||
$id_modulo = 1;
|
||||
break;
|
||||
case 1:
|
||||
$server["img"] = print_image ("images/network.png", true, array ("title" => __('Network server')));
|
||||
$server["type"] = "network";
|
||||
$id_modulo = 2;
|
||||
break;
|
||||
case 2:
|
||||
$server["img"] = print_image ("images/snmp.png", true, array ("title" => __('SNMP server')));
|
||||
$server["type"] = "snmp";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 3:
|
||||
$server["img"] = print_image ("images/recon.png", true, array ("title" => __('Recon server')));
|
||||
$server["type"] = "recon";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 4:
|
||||
$server["img"] = print_image ("images/plugin.png", true, array ("title" => __('Plugin server')));
|
||||
$server["type"] = "plugin";
|
||||
$id_modulo = 4;
|
||||
break;
|
||||
case 5:
|
||||
$server["img"] = print_image ("images/chart_bar.png", true, array ("title" => __('Prediction server')));
|
||||
$server["type"] = "prediction";
|
||||
$id_modulo = 5;
|
||||
break;
|
||||
case 6:
|
||||
$server["img"] = print_image ("images/wmi.png", true, array ("title" => __('WMI server')));
|
||||
$server["type"] = "wmi";
|
||||
$id_modulo = 6;
|
||||
break;
|
||||
case 7:
|
||||
$server["img"] = print_image ("images/server_export.png", true, array ("title" => __('Export server')));
|
||||
$server["type"] = "export";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 8:
|
||||
$server["img"] = print_image ("images/page_white_text.png", true, array ("title" => __('Inventory server')));
|
||||
$server["type"] = "inventory";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 9:
|
||||
$server["img"] = print_image ("images/world.png", true, array ("title" => __('Web server')));
|
||||
$server["type"] = "web";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
default:
|
||||
$server["img"] = '';
|
||||
$server["type"] = "unknown";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($config["realtimestats"] == 0){
|
||||
|
|
|
@ -246,13 +246,16 @@ class ViewAgent {
|
|||
if ($module["estado"] == 1) {
|
||||
$status = STATUS_MODULE_CRITICAL;
|
||||
$title = __('CRITICAL');
|
||||
} elseif ($module["estado"] == 2) {
|
||||
}
|
||||
elseif ($module["estado"] == 2) {
|
||||
$status = STATUS_MODULE_WARNING;
|
||||
$title = __('WARNING');
|
||||
} elseif ($module["estado"] == 0) {
|
||||
}
|
||||
elseif ($module["estado"] == 0) {
|
||||
$status = STATUS_MODULE_OK;
|
||||
$title = __('NORMAL');
|
||||
} elseif ($module["estado"] == 3) {
|
||||
}
|
||||
elseif ($module["estado"] == 3) {
|
||||
$last_status = get_agentmodule_last_status($module['id_agente_modulo']);
|
||||
switch($last_status) {
|
||||
case 0:
|
||||
|
@ -290,17 +293,20 @@ class ViewAgent {
|
|||
case 60: $salida = "FATAL"; $style="font-weight:bold; color:red;"; break;
|
||||
}
|
||||
$salida = "<span style='$style'>$salida</span>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (is_numeric($module["datos"])){
|
||||
$salida = format_numeric($module["datos"]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$salida = "<span title='".$module['datos']."' style='white-space: nowrap;'>".substr(safe_output($module["datos"]),0,12)."</span>";
|
||||
}
|
||||
}
|
||||
$data[] = $salida;
|
||||
if ($module['estado'] == 3) {
|
||||
$lastTime = '<span class="redb">';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$lastTime = '<span>';
|
||||
}
|
||||
$lastTime .= print_timestamp ($module["utimestamp"], true, array('units' => 'tiny'));
|
||||
|
@ -316,7 +322,6 @@ class ViewAgent {
|
|||
$table->head = array();
|
||||
$table->head[0] = __('Module');
|
||||
$table->head[1] = __('Template');
|
||||
// $table->head[2] = __('Action');
|
||||
$table->head[2] = '<span title="' . __('Last fired') . '" alt="' . __('Last fired') . '">' . __('Last') . '</span>';
|
||||
$table->head[3] = '<span title="' . __('Status') . '" alt="' . __('Status') . '">' . __('S') . '</span>';
|
||||
|
||||
|
@ -475,10 +480,10 @@ class viewGraph {
|
|||
}
|
||||
else {
|
||||
$sql_body = sprintf (" FROM tagente_datos
|
||||
WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $this->idAgentModule, (get_system_time () - $this->period));
|
||||
WHERE id_agente_modulo = %d AND utimestamp > %d
|
||||
ORDER BY utimestamp DESC", $this->idAgentModule, (get_system_time () - $this->period));
|
||||
|
||||
$columns = array(
|
||||
//"Timestamp" => array("utimestamp", "format_timestamp", "align" => "center"),
|
||||
"Data" => array("datos", "format_data", "align" => "center"),
|
||||
"Time" => array("utimestamp", "format_time", "align" => "center")
|
||||
);
|
||||
|
|
|
@ -131,9 +131,6 @@ class EventsView {
|
|||
$table = null;
|
||||
$table->width = '100%';
|
||||
$table->head = array();
|
||||
// $table->head[0] = '<span title="' . __('Severity') . '" alt="' . __('Severity') . '">' . __('S') . '</span>';
|
||||
// $table->head[1] = '<span title="' . __('Group') . '" alt="' . __('Group') . '">' . __('G') . '</span>';
|
||||
// $table->head[2] = '<span title="' . __('Type') . '" alt="' . __('Type') . '">' . __('T') . '</span>';
|
||||
$table->head[3] = '<span title="' . __('Timestamp') . '" alt="' . __('Timestamp') . '">' . __('T') . '</span>';
|
||||
$table->head[4] = '<span title="' . __('Description') . '" alt="' . __('Description') . '">' . __('Des.') . '</span>';
|
||||
$table->head[5] = '<span title="' . __('Agent') . '" alt="' . __('Agent') . '">' . __('Agent') . '</span>';
|
||||
|
@ -164,27 +161,6 @@ class EventsView {
|
|||
|
||||
$table->rowclass[$iterator] = get_priority_class($row["criticity"]);
|
||||
$iterator++;
|
||||
|
||||
// $data[] = '<a href="index.php?page=events&offset=' . $offset .
|
||||
// '&ev_group=' . $ev_group . '&event_type=' . $event_type .
|
||||
// '&severity=' . $row["criticity"] . '&search=' . $search . '">' .
|
||||
// print_image ($img, true,
|
||||
// array ("class" => "image_status",
|
||||
// "width" => 15,
|
||||
// "height" => 15,
|
||||
// "title" => get_priority_name($row["criticity"]))) . '</a>';
|
||||
|
||||
// $data[] = '<a href="index.php?page=events&ev_group=' .
|
||||
// $row["id_grupo"] . '&event_type=' . $event_type .
|
||||
// '&severity='. $severity . '&search=' . $search . '">' .
|
||||
// str_replace('images/', '../images/', print_group_icon ($row["id_grupo"], true, "groups_small", '', false))
|
||||
// . '</a>';
|
||||
//
|
||||
// $data[] = '<a href="index.php?page=events&ev_group=' . $ev_group .
|
||||
// '&event_type=' . $row["event_type"] . '&severity=' . $severity .
|
||||
// '&search=' . $search . '">' .
|
||||
// str_replace('images/', '../images/', print_event_type_img($row["event_type"], true)) .
|
||||
// '</a>';
|
||||
|
||||
$data[] = print_timestamp($row["timestamp"], true, array('units' => 'tiny'));
|
||||
|
||||
|
|
|
@ -88,18 +88,36 @@ if ($alert_validate) {
|
|||
}
|
||||
|
||||
if ($free_search != '') {
|
||||
$whereAlertSimple = 'AND (' .
|
||||
'id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE "%' . $free_search . '%") OR ' .
|
||||
'id_alert_template IN (SELECT id FROM talert_templates WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $free_search . '%")) OR ' .
|
||||
'talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $free_search . '%")) OR ' .
|
||||
'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE "%' . $free_search . '%") OR ' .
|
||||
'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN (SELECT id_agente FROM tagente WHERE nombre LIKE "%' . $free_search . '%"))' .
|
||||
')';
|
||||
|
||||
$whereAlertCombined = 'AND (' .
|
||||
'name LIKE "%' . $free_search . '%" OR ' .
|
||||
'id IN (SELECT id_alert_compound FROM talert_compound_elements WHERE id_alert_template_module IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $free_search . '%"))) ' .
|
||||
')';
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$whereAlertSimple = 'AND (' .
|
||||
'id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE "%' . $free_search . '%") OR ' .
|
||||
'id_alert_template IN (SELECT id FROM talert_templates WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $free_search . '%")) OR ' .
|
||||
'talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $free_search . '%")) OR ' .
|
||||
'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE "%' . $free_search . '%") OR ' .
|
||||
'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN (SELECT id_agente FROM tagente WHERE nombre LIKE "%' . $free_search . '%"))' .
|
||||
')';
|
||||
|
||||
$whereAlertCombined = 'AND (' .
|
||||
'name LIKE "%' . $free_search . '%" OR ' .
|
||||
'id IN (SELECT id_alert_compound FROM talert_compound_elements WHERE id_alert_template_module IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $free_search . '%"))) ' .
|
||||
')';
|
||||
break;
|
||||
case "postgresql":
|
||||
$whereAlertSimple = 'AND (' .
|
||||
'id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE \'%' . $free_search . '%\') OR ' .
|
||||
'id_alert_template IN (SELECT id FROM talert_templates WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE \'%' . $free_search . '%\')) OR ' .
|
||||
'talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE \'%' . $free_search . '%\')) OR ' .
|
||||
'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE \'%' . $free_search . '%\') OR ' .
|
||||
'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN (SELECT id_agente FROM tagente WHERE nombre LIKE \'%' . $free_search . '%\'))' .
|
||||
')';
|
||||
|
||||
$whereAlertCombined = 'AND (' .
|
||||
'name LIKE "%' . $free_search . '%" OR ' .
|
||||
'id IN (SELECT id_alert_compound FROM talert_compound_elements WHERE id_alert_template_module IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE \'%' . $free_search . '%\'))) ' .
|
||||
')';
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$whereAlertSimple = '';
|
||||
|
|
|
@ -93,7 +93,8 @@ print_page_header ( __("Agent detail"), "images/bricks.png", false, "agent_statu
|
|||
|
||||
if ($group_id > 1) {
|
||||
echo '<form method="post" action="'.get_url_refresh (array ('group_id' => $group_id, 'offset' => 0)).'">';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo '<form method="post" action="'.get_url_refresh (array('offset' => 0)).'">';
|
||||
}
|
||||
|
||||
|
|
|
@ -35,9 +35,9 @@ $intervalo_agente = $agent["intervalo"];
|
|||
// Get last packet
|
||||
$sql3 = 'SELECT * FROM tagente_modulo, tagente_estado
|
||||
WHERE tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_agente = ' . $id_agente.
|
||||
' AND tagente_estado.utimestamp != 0
|
||||
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND tagente_modulo.id_agente = ' . $id_agente.
|
||||
' AND tagente_estado.utimestamp != 0
|
||||
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
ORDER BY id_module_group, nombre';
|
||||
$label_group = 0;
|
||||
$last_label = "";
|
||||
|
|
|
@ -60,9 +60,15 @@ if (isset ($_GET["agentmodule"]) && isset ($_GET["agent"]) ){
|
|||
$sql1="SELECT * FROM tdatos WHERE id_agente = $id_agent AND id_agente_modulo = $id_agentmodule";
|
||||
$tipo = get_moduletype_name (get_agentmodule_type ($id_agentmodule));
|
||||
if ($tipo == "generic_data_string")
|
||||
$sql1 = "SELECT * FROM tagente_datos_string WHERE utimestamp > $from_date AND utimestamp < $to_date AND id_agente_modulo = $id_agentmodule ORDER BY utimestamp DESC";
|
||||
$sql1 = "SELECT *
|
||||
FROM tagente_datos_string
|
||||
WHERE utimestamp > $from_date AND utimestamp < $to_date AND id_agente_modulo = $id_agentmodule
|
||||
ORDER BY utimestamp DESC";
|
||||
else
|
||||
$sql1 = "SELECT * FROM tagente_datos WHERE utimestamp > $from_date AND utimestamp < $to_date AND id_agente_modulo = $id_agentmodule ORDER BY utimestamp DESC";
|
||||
$sql1 = "SELECT *
|
||||
FROM tagente_datos
|
||||
WHERE utimestamp > $from_date AND utimestamp < $to_date AND id_agente_modulo = $id_agentmodule
|
||||
ORDER BY utimestamp DESC";
|
||||
$result1 = get_db_all_rows_sql ($sql1, true);
|
||||
if ($result1 === false) {
|
||||
$result1 = array ();
|
||||
|
|
|
@ -104,7 +104,9 @@ print_table ($table);
|
|||
unset ($table);
|
||||
|
||||
// Get all SLA report components
|
||||
$sql = "SELECT id_agent_module, sla_max, sla_min, sla_limit FROM treport_content_sla_combined WHERE id_agent_module IN (".implode (",",array_keys ($modules)).")";
|
||||
$sql = "SELECT id_agent_module, sla_max, sla_min, sla_limit
|
||||
FROM treport_content_sla_combined
|
||||
WHERE id_agent_module IN (".implode (",",array_keys ($modules)).")";
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
if ($result !== false) {
|
||||
echo "<h3>".__('User-defined SLA items')." - ".human_time_description_raw ($config["sla_period"])."</h3>";
|
||||
|
|
|
@ -79,9 +79,9 @@ $user_groups = implode (",", array_keys (get_user_groups ()));
|
|||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = '
|
||||
select distinct(nombre)
|
||||
from tagente_modulo
|
||||
where nombre <> "delete_pending" and id_agente in
|
||||
SELECT distinct(nombre)
|
||||
FROM tagente_modulo
|
||||
WHERE nombre <> "delete_pending" and id_agente in
|
||||
(
|
||||
select id_agente
|
||||
from tagente where id_grupo IN (
|
||||
|
|
|
@ -70,7 +70,8 @@ if (is_ajax ()) {
|
|||
if ($get_agent_modules_json_for_multiple_agents_id) {
|
||||
$idAgents = get_parameter('id_agent');
|
||||
|
||||
$nameModules = get_db_all_rows_sql('SELECT nombre, id_agente_modulo FROM tagente_modulo WHERE id_agente IN (' . implode(',', $idAgents) . ')');
|
||||
$nameModules = get_db_all_rows_sql('SELECT nombre, id_agente_modulo
|
||||
FROM tagente_modulo WHERE id_agente IN (' . implode(',', $idAgents) . ')');
|
||||
|
||||
echo json_encode($nameModules);
|
||||
return;
|
||||
|
@ -79,7 +80,15 @@ if (is_ajax ()) {
|
|||
if ($get_agents_json_for_multiple_modules) {
|
||||
$nameModules = get_parameter('module_name');
|
||||
|
||||
$nameAgents = get_db_all_rows_sql('SELECT DISTINCT(t1.nombre) as name FROM tagente t1, tagente_modulo t2 WHERE t1.id_agente = t2.id_agente AND t2.nombre IN (\'' . implode('\',\'', $nameModules) . '\') AND (SELECT count(t3.nombre) FROM tagente t3, tagente_modulo t4 WHERE t3.id_agente = t4.id_agente AND t1.nombre = t3.nombre AND t4.nombre IN (\'' . implode('\',\'', $nameModules) . '\')) = '.count($nameModules));
|
||||
$nameAgents = get_db_all_rows_sql('SELECT DISTINCT(t1.nombre) as name
|
||||
FROM tagente t1, tagente_modulo t2
|
||||
WHERE t1.id_agente = t2.id_agente
|
||||
AND t2.nombre IN (\'' . implode('\',\'', $nameModules) . '\')
|
||||
AND (
|
||||
SELECT count(t3.nombre)
|
||||
FROM tagente t3, tagente_modulo t4
|
||||
WHERE t3.id_agente = t4.id_agente AND t1.nombre = t3.nombre
|
||||
AND t4.nombre IN (\'' . implode('\',\'', $nameModules) . '\')) = '.count($nameModules));
|
||||
|
||||
foreach($nameAgents as $nameAgent) {
|
||||
$names[] = $nameAgent['name'];
|
||||
|
@ -93,7 +102,16 @@ if (is_ajax ()) {
|
|||
$idAgents = get_parameter('id_agent');
|
||||
$id_template = get_parameter('template');
|
||||
|
||||
$nameModules = get_db_all_rows_sql('SELECT DISTINCT(nombre) FROM tagente_modulo t1, talert_template_modules t2 WHERE t2.id_agent_module = t1.id_agente_modulo AND delete_pending = 0 AND id_agente IN (' . implode(',', $idAgents) . ') AND (SELECT count(nombre) FROM tagente_modulo t3, talert_template_modules t4 WHERE t4.id_agent_module = t3.id_agente_modulo AND delete_pending = 0 AND t1.nombre = t3.nombre AND id_agente IN (' . implode(',', $idAgents) . ')) = (' . count($idAgents) . ')');
|
||||
$nameModules = get_db_all_rows_sql('SELECT DISTINCT(nombre)
|
||||
FROM tagente_modulo t1, talert_template_modules t2
|
||||
WHERE t2.id_agent_module = t1.id_agente_modulo
|
||||
AND delete_pending = 0
|
||||
AND id_agente IN (' . implode(',', $idAgents) . ') AND (
|
||||
SELECT count(nombre)
|
||||
FROM tagente_modulo t3, talert_template_modules t4
|
||||
WHERE t4.id_agent_module = t3.id_agente_modulo
|
||||
AND delete_pending = 0 AND t1.nombre = t3.nombre
|
||||
AND id_agente IN (' . implode(',', $idAgents) . ')) = (' . count($idAgents) . ')');
|
||||
|
||||
if ($nameModules == false) {
|
||||
$nameModules = array();
|
||||
|
@ -123,7 +141,13 @@ if (is_ajax ()) {
|
|||
|
||||
$nameModules = get_db_all_rows_sql('SELECT DISTINCT(nombre)
|
||||
FROM tagente_modulo t1
|
||||
WHERE ' . $enabled . ' AND delete_pending = 0 AND id_agente IN (' . implode(',', $idAgents) . ') AND (SELECT count(nombre) FROM tagente_modulo t2 WHERE delete_pending = 0 AND t1.nombre = t2.nombre AND id_agente IN (' . implode(',', $idAgents) . ')) = (' . count($idAgents) . ')');
|
||||
WHERE ' . $enabled . '
|
||||
AND delete_pending = 0
|
||||
AND id_agente IN (' . implode(',', $idAgents) . ') AND (
|
||||
SELECT count(nombre)
|
||||
FROM tagente_modulo t2
|
||||
WHERE delete_pending = 0 AND t1.nombre = t2.nombre
|
||||
AND id_agente IN (' . implode(',', $idAgents) . ')) = (' . count($idAgents) . ')');
|
||||
|
||||
if ($nameModules == false) {
|
||||
$nameModules = array();
|
||||
|
@ -184,17 +208,16 @@ if (is_ajax ()) {
|
|||
echo '<strong>'.__('Last remote contact').':</strong> '.human_time_comparation($agent['ultimo_contacto_remoto']).'<br />';
|
||||
|
||||
$sql = sprintf ('SELECT tagente_modulo.descripcion, tagente_modulo.nombre
|
||||
FROM tagente_estado, tagente_modulo
|
||||
WHERE tagente_modulo.id_agente = %d
|
||||
FROM tagente_estado, tagente_modulo
|
||||
WHERE tagente_modulo.id_agente = %d
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_estado.estado = 1', $id_agent);
|
||||
$bad_modules = get_db_all_rows_sql ($sql);
|
||||
$sql = sprintf ('SELECT COUNT(*)
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente = %d
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente = %d
|
||||
AND disabled = 0', $id_agent);
|
||||
//AND id_tipo_modulo in (2, 6, 9, 18, 21, 100)', $id_agent);
|
||||
$total_modules = get_db_sql ($sql);
|
||||
|
||||
if ($bad_modules === false)
|
||||
|
@ -218,22 +241,22 @@ if (is_ajax ()) {
|
|||
$sql = sprintf ('SELECT COUNT(talert_template_modules.id)
|
||||
FROM talert_template_modules, tagente_modulo, tagente
|
||||
WHERE tagente.id_agente = %d
|
||||
AND tagente.disabled = 0
|
||||
AND tagente.id_agente = tagente_modulo.id_agente
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module
|
||||
AND talert_template_modules.times_fired > 0 ',
|
||||
AND tagente.disabled = 0
|
||||
AND tagente.id_agente = tagente_modulo.id_agente
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module
|
||||
AND talert_template_modules.times_fired > 0 ',
|
||||
$id_agent);
|
||||
$alert_modules = get_db_sql ($sql);
|
||||
if ($alert_modules > 0){
|
||||
$sql = sprintf ('SELECT tagente_modulo.nombre, talert_template_modules.last_fired
|
||||
FROM talert_template_modules, tagente_modulo, tagente
|
||||
WHERE tagente.id_agente = %d
|
||||
AND tagente.disabled = 0
|
||||
AND tagente.id_agente = tagente_modulo.id_agente
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module
|
||||
AND talert_template_modules.times_fired > 0 ',
|
||||
AND tagente.disabled = 0
|
||||
AND tagente.id_agente = tagente_modulo.id_agente
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module
|
||||
AND talert_template_modules.times_fired > 0 ',
|
||||
$id_agent);
|
||||
$alerts = get_db_all_rows_sql ($sql);
|
||||
echo '<strong>'.__('Alerts fired').':</strong>';
|
||||
|
|
|
@ -244,10 +244,16 @@ echo '<div id="steps_clean"> </div>';
|
|||
echo '</div>';
|
||||
|
||||
if ($group_rep == 0) {
|
||||
$sql = "SELECT * FROM tevento WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination;
|
||||
$sql = "SELECT *
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination;
|
||||
}
|
||||
else {
|
||||
$sql = "SELECT *, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep FROM tevento WHERE 1=1 ".$sql_post." GROUP BY evento, id_agentmodule ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination;
|
||||
$sql = "SELECT *, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post."
|
||||
GROUP BY evento, id_agentmodule
|
||||
ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination;
|
||||
}
|
||||
|
||||
//Extract the events by filter (or not) from db
|
||||
|
|
|
@ -166,7 +166,7 @@ $sql="SELECT tevento.id_evento AS event_id,
|
|||
tevento.utimestamp AS unix_timestamp,
|
||||
tevento.event_type AS event_type
|
||||
FROM tevento
|
||||
WHERE 1 = 1".$sql_post."
|
||||
WHERE 1 = 1" . $sql_post . "
|
||||
ORDER BY utimestamp DESC LIMIT 0 , 30";
|
||||
|
||||
$result= get_db_all_rows_sql ($sql);
|
||||
|
|
|
@ -44,14 +44,18 @@ switch ($opt) {
|
|||
$returnJSON['correct'] = 1;
|
||||
|
||||
if ($agentView == 0) {
|
||||
$flagGroupAll = get_db_all_rows_sql('SELECT tgrupo_id_grupo FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . ' AND tgrupo_id_grupo = 0;'); //group 0 = all groups
|
||||
$flagGroupAll = get_db_all_rows_sql('SELECT tgrupo_id_grupo
|
||||
FROM tgis_map_layer
|
||||
WHERE id_tmap_layer = ' . $layerId . ' AND tgrupo_id_grupo = 0;'); //group 0 = all groups
|
||||
|
||||
$defaultCoords = get_db_row_sql('SELECT default_longitude, default_latitude
|
||||
FROM tgis_map
|
||||
WHERE id_tgis_map IN (SELECT tgis_map_id_tgis_map FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . ')');
|
||||
|
||||
if ($flagGroupAll === false) {
|
||||
$idAgentsWithGISTemp = get_db_all_rows_sql('SELECT id_agente FROM tagente WHERE id_grupo IN
|
||||
$idAgentsWithGISTemp = get_db_all_rows_sql('SELECT id_agente
|
||||
FROM tagente
|
||||
WHERE id_grupo IN
|
||||
(SELECT tgrupo_id_grupo FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . ')
|
||||
OR id_agente IN
|
||||
(SELECT tagente_id_agente FROM tgis_map_layer_has_tagente WHERE tgis_map_layer_id_tmap_layer = ' . $layerId . ');');
|
||||
|
@ -72,12 +76,24 @@ switch ($opt) {
|
|||
$idAgentsWithGIS[] = $id_features;
|
||||
}
|
||||
|
||||
$agentsGISStatus = get_db_all_rows_sql('SELECT t1.nombre, id_parent, t1.id_agente AS tagente_id_agente,
|
||||
IFNULL(t2.stored_longitude, ' . $defaultCoords['default_longitude'] . ') AS stored_longitude,
|
||||
IFNULL(t2.stored_latitude, ' . $defaultCoords['default_latitude'] . ') AS stored_latitude
|
||||
FROM tagente AS t1
|
||||
LEFT JOIN tgis_data_status AS t2 ON t1.id_agente = t2.tagente_id_agente
|
||||
WHERE id_agente IN (' . implode(',', $idAgentsWithGIS) . ')');
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$agentsGISStatus = get_db_all_rows_sql('SELECT t1.nombre, id_parent, t1.id_agente AS tagente_id_agente,
|
||||
IFNULL(t2.stored_longitude, ' . $defaultCoords['default_longitude'] . ') AS stored_longitude,
|
||||
IFNULL(t2.stored_latitude, ' . $defaultCoords['default_latitude'] . ') AS stored_latitude
|
||||
FROM tagente AS t1
|
||||
LEFT JOIN tgis_data_status AS t2 ON t1.id_agente = t2.tagente_id_agente
|
||||
WHERE id_agente IN (' . implode(',', $idAgentsWithGIS) . ')');
|
||||
break;
|
||||
case "postgresql":
|
||||
$agentsGISStatus = get_db_all_rows_sql('SELECT t1.nombre, id_parent, t1.id_agente AS tagente_id_agente,
|
||||
COALESCE(t2.stored_longitude, ' . $defaultCoords['default_longitude'] . ') AS stored_longitude,
|
||||
COALESCE(t2.stored_latitude, ' . $defaultCoords['default_latitude'] . ') AS stored_latitude
|
||||
FROM tagente AS t1
|
||||
LEFT JOIN tgis_data_status AS t2 ON t1.id_agente = t2.tagente_id_agente
|
||||
WHERE id_agente IN (' . implode(',', $idAgentsWithGIS) . ')');
|
||||
break;
|
||||
}
|
||||
|
||||
if ($agentsGISStatus === false) {
|
||||
$agentsGISStatus = array();
|
||||
|
|
|
@ -181,15 +181,16 @@ $groups = get_user_groups ($config["id_user"], "IR");
|
|||
|
||||
//Select incidencts where the user has access to ($groups from
|
||||
//get_user_groups), array_keys for the id, implode to pass to SQL
|
||||
$sql = "SELECT * FROM tincidencia WHERE
|
||||
id_grupo IN (".implode (",",array_keys ($groups)).")".$filter."
|
||||
$sql = "SELECT * FROM tincidencia
|
||||
WHERE id_grupo IN (".implode (",",array_keys ($groups)).")" . $filter . "
|
||||
ORDER BY actualizacion DESC LIMIT ".$offset.",".$config["block_size"];
|
||||
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
if (empty ($result)) {
|
||||
$result = array ();
|
||||
$count = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$count = count ($result);
|
||||
}
|
||||
|
||||
|
@ -243,7 +244,8 @@ echo '</form>';
|
|||
|
||||
if ($count < 1) {
|
||||
echo '<div class="nf">'.__('No incidents match your search filter').'</div><br />';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// TOTAL incidents
|
||||
$url = "index.php?sec=incidencias&sec2=operation/incidents/incident";
|
||||
|
||||
|
|
|
@ -241,7 +241,8 @@ echo '</td><td class="datos"><b>'.__('Status').'</b></td><td class="datos">';
|
|||
|
||||
if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) {
|
||||
print_select (get_incidents_status (), "estado_form", $estado, '', '', '', false, false, false, 'w135');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
print_select (get_incidents_status (), "estado_form", $estado, '', '', '', false, false, false, 'w135', true);
|
||||
}
|
||||
echo '</td></tr>';
|
||||
|
@ -260,7 +261,8 @@ foreach ($return as $row) {
|
|||
// Only owner could change source or user with Incident management privileges
|
||||
if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) {
|
||||
print_select ($fields, "origen_form", $estado, '', '', '', false, false, false, 'w135');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
print_select ($fields, "origen_form", $estado, '', '', '', false, false, false, 'w135', true);
|
||||
}
|
||||
echo '</td><td class="datos2"><b>'.__('Group').'</b></td><td class="datos2">';
|
||||
|
|
|
@ -142,7 +142,7 @@ if (check_acl ($config['id_user'], 0, "AR")) {
|
|||
$sub = array ();
|
||||
// Show all recon servers, and generate menu for details
|
||||
|
||||
$servers = get_db_all_rows_sql ('SELECT * FROM tserver WHERE server_type = 3');
|
||||
$servers = get_db_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3');
|
||||
if ($servers === false) {
|
||||
$servers = array ();
|
||||
}
|
||||
|
|
|
@ -65,18 +65,18 @@ if ($view_graph) {
|
|||
//Increase the height to fix the leyend rise
|
||||
if ($zoom > 0) {
|
||||
switch ($zoom) {
|
||||
case 1:
|
||||
$width = 500;
|
||||
$height = 200 + count($sources) * 15;
|
||||
break;
|
||||
case 2:
|
||||
$width = 650;
|
||||
$height = 300 + count($sources) * 10;
|
||||
break;
|
||||
case 3:
|
||||
$width = 770;
|
||||
$height = 400 + count($sources) * 5;
|
||||
break;
|
||||
case 1:
|
||||
$width = 500;
|
||||
$height = 200 + count($sources) * 15;
|
||||
break;
|
||||
case 2:
|
||||
$width = 650;
|
||||
$height = 300 + count($sources) * 10;
|
||||
break;
|
||||
case 3:
|
||||
$width = 770;
|
||||
$height = 400 + count($sources) * 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -531,7 +531,7 @@ foreach ($contents as $content) {
|
|||
$result = get_db_all_rows_sql('SELECT *
|
||||
FROM tagente_datos_string
|
||||
WHERE id_agente_modulo = ' . $content['id_agent_module'] . '
|
||||
AND utimestamp > ' . $datelimit . ' AND utimestamp <= ' . $report["datetime"]);
|
||||
AND utimestamp > ' . $datelimit . ' AND utimestamp <= ' . $report["datetime"]);
|
||||
if ($result === false) {
|
||||
$result = array();
|
||||
}
|
||||
|
|
|
@ -95,13 +95,68 @@ $alerts = false;
|
|||
if($searchAlerts) {
|
||||
$agents = array_keys(get_group_agents(array_keys(get_user_groups($config["id_user"], 'AR', false))));
|
||||
|
||||
$whereAlerts = 'AND (' .
|
||||
'id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE "%' . $stringSearchSQL . '%") OR ' .
|
||||
'id_alert_template IN (SELECT id FROM talert_templates WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $stringSearchSQL . '%")) OR ' .
|
||||
'talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $stringSearchSQL . '%")) OR ' .
|
||||
'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE "%' . $stringSearchSQL . '%") OR ' .
|
||||
'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN (SELECT id_agente FROM tagente WHERE nombre LIKE "%' . $stringSearchSQL . '%"))' .
|
||||
')';
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$whereAlerts = 'AND (
|
||||
id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE "%' . $stringSearchSQL . '%") OR
|
||||
id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%' . $stringSearchSQL . '%")) OR
|
||||
talert_template_modules.id IN (
|
||||
SELECT id_alert_template_module
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%' . $stringSearchSQL . '%")) OR
|
||||
id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE nombre LIKE "%' . $stringSearchSQL . '%") OR
|
||||
id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente IN (
|
||||
SELECT id_agente
|
||||
FROM tagente
|
||||
WHERE nombre LIKE "%' . $stringSearchSQL . '%"))
|
||||
)';
|
||||
break;
|
||||
case "postgresql":
|
||||
$whereAlerts = 'AND (
|
||||
id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE \'%' . $stringSearchSQL . '%\') OR
|
||||
id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE \'%' . $stringSearchSQL . '%\')) OR
|
||||
talert_template_modules.id IN (
|
||||
SELECT id_alert_template_module
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE \'%' . $stringSearchSQL . '%\')) OR
|
||||
id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE nombre LIKE \'%' . $stringSearchSQL . '%\') OR
|
||||
id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente IN (
|
||||
SELECT id_agente
|
||||
FROM tagente
|
||||
WHERE nombre LIKE \'%' . $stringSearchSQL . '%\'))
|
||||
)';
|
||||
break;
|
||||
}
|
||||
|
||||
$alertsraw = get_agent_alerts_simple ($agents, "all_enabled", array('offset' => get_parameter ('offset',0), 'limit' => $config['block_size'], 'order' => $order['field'] . " " . $order['order']), $whereAlerts);
|
||||
|
||||
|
|
|
@ -32,12 +32,16 @@ if ($searchGraphs) {
|
|||
$graphs_condition = " AND id_graph IN (".implode(',',$usergraphs_id).")";
|
||||
}
|
||||
|
||||
$sql = "SELECT id_graph, name, description FROM tgraph WHERE (name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%')".$graphs_condition.
|
||||
" LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
|
||||
$sql = "SELECT id_graph, name, description
|
||||
FROM tgraph
|
||||
WHERE (name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%')".$graphs_condition ."
|
||||
LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
|
||||
$graphs = process_sql($sql);
|
||||
|
||||
if($graphs !== false) {
|
||||
$sql = "SELECT COUNT(id_graph) AS count FROM tgraph WHERE name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%'";
|
||||
$sql = "SELECT COUNT(id_graph) AS count
|
||||
FROM tgraph
|
||||
WHERE name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%'";
|
||||
$totalGraphs = get_db_row_sql($sql);
|
||||
$totalGraphs = $totalGraphs['count'];
|
||||
}
|
||||
|
|
|
@ -29,14 +29,16 @@ if ($searchMaps) {
|
|||
foreach($maps as $key => $map) {
|
||||
if (!check_acl ($config["id_user"], $map["id_group"], "AR")) {
|
||||
unset($maps[$key]);
|
||||
}else {
|
||||
}
|
||||
else {
|
||||
$maps_id[] = $map['id'];
|
||||
}
|
||||
}
|
||||
|
||||
if(!$maps_id) {
|
||||
$maps_condition = "";
|
||||
}else {
|
||||
}
|
||||
else {
|
||||
// Condition with the visible agents
|
||||
$maps_condition = " AND id IN (\"".implode('","',$maps_id)."\")";
|
||||
}
|
||||
|
|
|
@ -58,29 +58,54 @@ if ($searchModules) {
|
|||
$userGroups = get_user_groups($config['id_user'], 'AR', false);
|
||||
$id_userGroups = array_keys($userGroups);
|
||||
|
||||
$chunk_sql = '
|
||||
FROM tagente_modulo AS t1
|
||||
INNER JOIN tagente AS t2
|
||||
ON t2.id_agente = t1.id_agente
|
||||
INNER JOIN tgrupo AS t3
|
||||
ON t3.id_grupo = t2.id_grupo
|
||||
INNER JOIN tagente_estado AS t4
|
||||
ON t4.id_agente_modulo = t1.id_agente_modulo
|
||||
WHERE (t2.id_grupo IN (
|
||||
' . implode(',', $id_userGroups) . '
|
||||
)
|
||||
OR 0 IN (
|
||||
SELECT id_grupo
|
||||
FROM tusuario_perfil
|
||||
WHERE id_usuario = "' . $config['id_user'] . '"
|
||||
AND id_perfil IN (
|
||||
SELECT id_perfil
|
||||
FROM tperfil WHERE agent_view = 1
|
||||
)
|
||||
)
|
||||
) AND
|
||||
t1.nombre COLLATE utf8_general_ci LIKE "%' . $stringSearchSQL . '%" OR
|
||||
t3.nombre LIKE "%' . $stringSearchSQL . '%"';
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$chunk_sql = '
|
||||
FROM tagente_modulo AS t1
|
||||
INNER JOIN tagente AS t2
|
||||
ON t2.id_agente = t1.id_agente
|
||||
INNER JOIN tgrupo AS t3
|
||||
ON t3.id_grupo = t2.id_grupo
|
||||
INNER JOIN tagente_estado AS t4
|
||||
ON t4.id_agente_modulo = t1.id_agente_modulo
|
||||
WHERE (t2.id_grupo IN (' . implode(',', $id_userGroups) . ')
|
||||
OR 0 IN (
|
||||
SELECT id_grupo
|
||||
FROM tusuario_perfil
|
||||
WHERE id_usuario = "' . $config['id_user'] . '"
|
||||
AND id_perfil IN (
|
||||
SELECT id_perfil
|
||||
FROM tperfil WHERE agent_view = 1
|
||||
)
|
||||
)
|
||||
) AND
|
||||
t1.nombre COLLATE utf8_general_ci LIKE "%' . $stringSearchSQL . '%" OR
|
||||
t3.nombre LIKE "%' . $stringSearchSQL . '%"';
|
||||
break;
|
||||
case "postgresql":
|
||||
$chunk_sql = '
|
||||
FROM tagente_modulo AS t1
|
||||
INNER JOIN tagente AS t2
|
||||
ON t2.id_agente = t1.id_agente
|
||||
INNER JOIN tgrupo AS t3
|
||||
ON t3.id_grupo = t2.id_grupo
|
||||
INNER JOIN tagente_estado AS t4
|
||||
ON t4.id_agente_modulo = t1.id_agente_modulo
|
||||
WHERE (t2.id_grupo IN (' . implode(',', $id_userGroups) . ')
|
||||
OR 0 IN (
|
||||
SELECT id_grupo
|
||||
FROM tusuario_perfil
|
||||
WHERE id_usuario = \'' . $config['id_user'] . '\'
|
||||
AND id_perfil IN (
|
||||
SELECT id_perfil
|
||||
FROM tperfil WHERE agent_view = 1
|
||||
)
|
||||
)
|
||||
) AND
|
||||
t1.nombre COLLATE utf8_general_ci LIKE \'%' . $stringSearchSQL . '%\' OR
|
||||
t3.nombre LIKE \'%' . $stringSearchSQL . '%\'';
|
||||
break;
|
||||
}
|
||||
|
||||
$select = "SELECT *, t1.nombre AS module_name, t2.nombre AS agent_name ";
|
||||
$limit = " ORDER BY " . $order['field'] . " " . $order['order'] .
|
||||
|
|
|
@ -35,18 +35,23 @@ foreach($userreports as $userreport) {
|
|||
|
||||
if(!$userreports_id){
|
||||
$reports_condition = " AND 1<>1";
|
||||
}else {
|
||||
}
|
||||
else {
|
||||
$reports_condition = " AND id_report IN (".implode(',',$userreports_id).")";
|
||||
}
|
||||
|
||||
$reports = false;
|
||||
|
||||
if($searchReports) {
|
||||
$sql = "SELECT id_report, name, description FROM treport WHERE (name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%')".$reports_condition.
|
||||
$sql = "SELECT id_report, name, description
|
||||
FROM treport
|
||||
WHERE (name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%')".$reports_condition.
|
||||
" LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
|
||||
$reports = process_sql($sql);
|
||||
|
||||
$sql = "SELECT COUNT(id_report) AS count FROM treport WHERE (name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%')";
|
||||
$sql = "SELECT COUNT(id_report) AS count
|
||||
FROM treport
|
||||
WHERE (name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%')";
|
||||
$totalReports = get_db_row_sql($sql);
|
||||
$totalReports = $totalReports['count'];
|
||||
}
|
||||
|
|
|
@ -133,11 +133,12 @@ if ($searchUsers) {
|
|||
//Check ACLs
|
||||
$users_id = array();
|
||||
foreach($users as $key => $user){
|
||||
if (!check_acl ($config["id_user"], get_user_groups ($user["id_user"]), "UM") && $config["id_user"] != $user["id_user"]) {
|
||||
unset($users[$key]);
|
||||
} else {
|
||||
$users_id[] = $user["id_user"];
|
||||
}
|
||||
if (!check_acl ($config["id_user"], get_user_groups ($user["id_user"]), "UM") && $config["id_user"] != $user["id_user"]) {
|
||||
unset($users[$key]);
|
||||
}
|
||||
else {
|
||||
$users_id[] = $user["id_user"];
|
||||
}
|
||||
}
|
||||
|
||||
if(!$users_id) {
|
||||
|
|
|
@ -103,30 +103,35 @@ foreach ($recon_tasks as $task) {
|
|||
|
||||
$data[2] = human_time_description ($task["interval_sweep"]);
|
||||
|
||||
if ($task["id_recon_script"] == 0){
|
||||
$data[3] = $task["subnet"];
|
||||
} else {
|
||||
$data[3] = __("N/A");
|
||||
}
|
||||
if ($task["id_recon_script"] == 0){
|
||||
$data[3] = $task["subnet"];
|
||||
}
|
||||
else {
|
||||
$data[3] = __("N/A");
|
||||
}
|
||||
|
||||
if ($task["status"] <= 0) {
|
||||
$data[4] = __('Done');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$data[4] = __('Pending');
|
||||
}
|
||||
|
||||
if ($task["id_recon_script"] == 0){
|
||||
// Network recon task
|
||||
$data[5] = print_image ("images/network.png", true, array ("title" => __('Network recon task')))." ";
|
||||
$data[5] .= get_networkprofile_name ($task["id_network_profile"]);
|
||||
} else {
|
||||
// APP recon task
|
||||
$data[5] = print_image ("images/plugin.png", true). " ";
|
||||
$data[5] .= get_db_sql (sprintf("SELECT name FROM trecon_script WHERE id_recon_script = %d", $task["id_recon_script"]));
|
||||
}
|
||||
if ($task["id_recon_script"] == 0){
|
||||
// Network recon task
|
||||
$data[5] = print_image ("images/network.png", true, array ("title" => __('Network recon task')))." ";
|
||||
$data[5] .= get_networkprofile_name ($task["id_network_profile"]);
|
||||
}
|
||||
else {
|
||||
// APP recon task
|
||||
$data[5] = print_image ("images/plugin.png", true). " ";
|
||||
$data[5] .= get_db_sql (sprintf("SELECT name FROM trecon_script WHERE id_recon_script = %d", $task["id_recon_script"]));
|
||||
}
|
||||
|
||||
if ($task["status"] <= 0 || $task["status"] > 100) {
|
||||
$data[6] = "-";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$data[6] = print_image ("include/fgraph.php?tipo=progress&percent=".$task['status']."&height=20&width=100", true, array ("title" => __('Progress').':'.$task["status"].'%'));
|
||||
}
|
||||
|
||||
|
@ -134,7 +139,8 @@ if ($task["id_recon_script"] == 0){
|
|||
|
||||
if (check_acl ($config["id_user"], $task["id_group"], "PM")) {
|
||||
$data[8] = '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&update='.$task["id_rt"].'">'.print_image ("images/wrench_orange.png", true).'</a>';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$data[8] = '';
|
||||
}
|
||||
|
||||
|
@ -143,7 +149,8 @@ if ($task["id_recon_script"] == 0){
|
|||
|
||||
if (empty ($table->data)) {
|
||||
echo '<div class="nf">'.__("This server has no recon tasks assigned").'</div>';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
print_table ($table);
|
||||
}
|
||||
unset ($table);
|
||||
|
|
|
@ -152,34 +152,67 @@ foreach ($traps as $trap) {
|
|||
//Make query to extract traps of DB.
|
||||
$sql = "SELECT * FROM ttrap %s ORDER BY timestamp DESC LIMIT %d,%d";
|
||||
$whereSubquery = 'WHERE 1=1';
|
||||
if ($filter_agent != '')
|
||||
$whereSubquery .= ' AND source LIKE "' . $filter_agent . '"';
|
||||
|
||||
if ($filter_oid != '') {
|
||||
//Test if install the enterprise to search oid in text or oid field in ttrap.
|
||||
if ($config['enterprise_installed'])
|
||||
$whereSubquery .= ' AND (text LIKE "' . $filter_oid . '" OR oid LIKE "' . $filter_oid . '")';
|
||||
else
|
||||
$whereSubquery .= ' AND oid LIKE "' . $filter_oid . '"';
|
||||
}
|
||||
if ($filter_fired != -1)
|
||||
$whereSubquery .= ' AND alerted = ' . $filter_fired;
|
||||
if ($search_string != '')
|
||||
$whereSubquery .= ' AND value LIKE "%' . $search_string . '%"';
|
||||
|
||||
if ($filter_severity != -1) {
|
||||
//Test if install the enterprise to search oid in text or oid field in ttrap.
|
||||
if ($config['enterprise_installed'])
|
||||
$whereSubquery .= ' AND (
|
||||
(alerted = 0 AND severity = ' . $filter_severity . ') OR
|
||||
(alerted = 1 AND priority = ' . $filter_severity . '))';
|
||||
else
|
||||
$whereSubquery .= ' AND (
|
||||
(alerted = 0 AND 1 = ' . $filter_severity . ') OR
|
||||
(alerted = 1 AND priority = ' . $filter_severity . '))';
|
||||
if ($filter_agent != '') {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$whereSubquery .= ' AND source LIKE "' . $filter_agent . '"';
|
||||
break;
|
||||
case "postgresql":
|
||||
$whereSubquery .= ' AND source LIKE \'' . $filter_agent . '\'';
|
||||
break;
|
||||
}
|
||||
if ($filter_status != -1)
|
||||
$whereSubquery .= ' AND status = ' . $filter_status;
|
||||
}
|
||||
|
||||
if ($filter_oid != '') {
|
||||
//Test if install the enterprise to search oid in text or oid field in ttrap.
|
||||
if ($config['enterprise_installed']) {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$whereSubquery .= ' AND (text LIKE "' . $filter_oid . '" OR oid LIKE "' . $filter_oid . '")';
|
||||
break;
|
||||
case "postgresql":
|
||||
$whereSubquery .= ' AND (text LIKE \'' . $filter_oid . '\' OR oid LIKE \'' . $filter_oid . '\')';
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$whereSubquery .= ' AND oid LIKE "' . $filter_oid . '"';
|
||||
break;
|
||||
case "postgresql":
|
||||
$whereSubquery .= ' AND oid LIKE \'' . $filter_oid . '\'';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($filter_fired != -1)
|
||||
$whereSubquery .= ' AND alerted = ' . $filter_fired;
|
||||
if ($search_string != '') {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$whereSubquery .= ' AND value LIKE "%' . $search_string . '%"';
|
||||
break;
|
||||
case "postgresql":
|
||||
$whereSubquery .= ' AND value LIKE \'%' . $search_string . '%\'';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filter_severity != -1) {
|
||||
//Test if install the enterprise to search oid in text or oid field in ttrap.
|
||||
if ($config['enterprise_installed'])
|
||||
$whereSubquery .= ' AND (
|
||||
(alerted = 0 AND severity = ' . $filter_severity . ') OR
|
||||
(alerted = 1 AND priority = ' . $filter_severity . '))';
|
||||
else
|
||||
$whereSubquery .= ' AND (
|
||||
(alerted = 0 AND 1 = ' . $filter_severity . ') OR
|
||||
(alerted = 1 AND priority = ' . $filter_severity . '))';
|
||||
}
|
||||
if ($filter_status != -1)
|
||||
$whereSubquery .= ' AND status = ' . $filter_status;
|
||||
|
||||
|
||||
$sql = sprintf($sql, $whereSubquery, $offset, $pagination);
|
||||
|
|
Loading…
Reference in New Issue