mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-03 12:04:57 +02:00
2008-11-20 Evi Vanoost <vanooste@rcbi.rochester.edu>
* reporting/fgraph.php: Updated for some faster processing and new functions. * operation/events/events.php, operation/agentes/estado_alertas, include/functions_reporting.php, godmode/reporting/reporting_bulder.php, godmode/reporting/map_builder.php, godmode/db/db_info.php: Function name updates * include/functions_html.php: Small style update * include/functions_db.php: get_agents_in_group is now get_group_agents. Accepts array and specified case. get_modules_in_agent is now get_agentmodules and accepts arrays of agents as well as which details to select. Deprecated dame_nombre_agente in favor of get_agent_name which accepts case. Fixed get_agent_addresses for use in select boxes. Added filter to get_agentmodule_count * godmode/db/db_purge.php: Fixed queries and style updates * godmode/agentes/configurar_agente.php: Fixed IP select box * godmode/agentes/agent_manager.php: Style update and fixed a bug git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1250 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
4ea1e37444
commit
b184efd4d5
@ -1,3 +1,31 @@
|
|||||||
|
2008-11-20 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||||
|
|
||||||
|
* reporting/fgraph.php: Updated for some faster processing
|
||||||
|
and new functions.
|
||||||
|
|
||||||
|
* operation/events/events.php,
|
||||||
|
operation/agentes/estado_alertas,
|
||||||
|
include/functions_reporting.php,
|
||||||
|
godmode/reporting/reporting_bulder.php,
|
||||||
|
godmode/reporting/map_builder.php, godmode/db/db_info.php:
|
||||||
|
Function name updates
|
||||||
|
|
||||||
|
* include/functions_html.php: Small style update
|
||||||
|
|
||||||
|
* include/functions_db.php: get_agents_in_group is now
|
||||||
|
get_group_agents. Accepts array and specified case.
|
||||||
|
get_modules_in_agent is now get_agentmodules and accepts arrays
|
||||||
|
of agents as well as which details to select. Deprecated
|
||||||
|
dame_nombre_agente in favor of get_agent_name which accepts case.
|
||||||
|
Fixed get_agent_addresses for use in select boxes. Added filter
|
||||||
|
to get_agentmodule_count
|
||||||
|
|
||||||
|
* godmode/db/db_purge.php: Fixed queries and style updates
|
||||||
|
|
||||||
|
* godmode/agentes/configurar_agente.php: Fixed IP select box
|
||||||
|
|
||||||
|
* godmode/agentes/agent_manager.php: Style update and fixed a bug
|
||||||
|
|
||||||
2008-11-19 Jorge Gonzalez <jorgegonz@svn.gnome.org>
|
2008-11-19 Jorge Gonzalez <jorgegonz@svn.gnome.org>
|
||||||
|
|
||||||
* pandoradb_data.sql: Added Arab and Turkish translations to the
|
* pandoradb_data.sql: Added Arab and Turkish translations to the
|
||||||
|
@ -19,8 +19,9 @@
|
|||||||
// ========================
|
// ========================
|
||||||
// AGENT GENERAL DATA FORM
|
// AGENT GENERAL DATA FORM
|
||||||
// ========================
|
// ========================
|
||||||
|
|
||||||
// Load global vars
|
// Load global vars
|
||||||
require ('include/config.php');
|
require_once ('include/config.php');
|
||||||
|
|
||||||
enterprise_include ('godmode/agentes/agent_manager.php');
|
enterprise_include ('godmode/agentes/agent_manager.php');
|
||||||
|
|
||||||
@ -30,190 +31,136 @@ if (! give_acl ($config['id_user'], 0, "AW")) {
|
|||||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||||
"Trying to access agent manager");
|
"Trying to access agent manager");
|
||||||
require ("general/noaccess.php");
|
require ("general/noaccess.php");
|
||||||
return;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<h2>".__('Agent configuration');
|
echo "<h2>".__('Agent configuration');
|
||||||
if (isset($_GET["create_agent"])){
|
if (isset($_GET["create_agent"])) {
|
||||||
$create_agent = 1;
|
$create_agent = 1;
|
||||||
echo " > ".__('Create agent');
|
echo " > ".__('Create agent');
|
||||||
} else {
|
} else {
|
||||||
echo " > ".__('Update agent');
|
echo " > ".__('Update agent');
|
||||||
}
|
}
|
||||||
echo "</h2>";
|
echo "</h2>";
|
||||||
echo "<div style='height: 5px'> </div>";
|
echo '<div style="height: 5px"> </div>';
|
||||||
|
|
||||||
// Agent remote configuration editor
|
// Agent remote configuration editor
|
||||||
$agent_md5 = md5($nombre_agente, FALSE);
|
$agent_md5 = md5 ($nombre_agente, FALSE);
|
||||||
if (isset($_GET["disk_conf"])){
|
$filename['md5'] = $config["remote_config"] . "/" . $agent_md5 . ".md5";
|
||||||
|
$filename['conf'] = $config["remote_config"] . "/" . $agent_md5 . ".conf";
|
||||||
|
|
||||||
|
if (isset ($_GET["disk_conf"])) {
|
||||||
require ("agent_disk_conf_editor.php");
|
require ("agent_disk_conf_editor.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Agent remote configuration DELETE
|
// Agent remote configuration DELETE
|
||||||
if (isset($_GET["disk_conf_delete"])){
|
if (isset($_GET["disk_conf_delete"])) {
|
||||||
$agent_md5 = md5($nombre_agente, FALSE);
|
//TODO: Get this working on computers where the Pandora server(s) are not on the webserver
|
||||||
$file_name = $config["remote_config"] . "/" . $agent_md5 . ".conf";
|
//TODO: Get a remote_config editor working in the open version
|
||||||
unlink ($file_name);
|
unlink ($filename['md5']);
|
||||||
$file_name = $config["remote_config"] . "/" . $agent_md5 . ".md5";
|
unlink ($filename['conf']);
|
||||||
unlink ($file_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<form name="conf_agent" method="post" action="index.php?sec=gagente&
|
echo '<form name="conf_agent" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">';
|
||||||
sec2=godmode/agentes/configurar_agente">';
|
|
||||||
echo '<table width="650" id="table-agent-configuration" cellpadding="4" cellspacing="4" class="databox_color">';
|
$table->width = 650;
|
||||||
echo "<tr>";
|
$table->cellpadding = 4;
|
||||||
echo '<td class="datos"><b>'.__('Agent name').'</b><a href="#" class="tip"> <span>'.__('The Agent\'s name must be the same as the one defined at the Console').'</span></a></td><td class="datos">';
|
$table->cellspacing = 4;
|
||||||
print_input_text ('agente', $nombre_agente, '', 30, 100);
|
$table->class = "databox_color";
|
||||||
|
|
||||||
|
$table->head = array ();
|
||||||
|
$table->data = array ();
|
||||||
|
|
||||||
|
$table->data[0][0] = '<b>'.__('Agent name').'</b>'.print_help_tip (__("The agent's name must be the same as the one defined at the console"), true);
|
||||||
|
$table->data[0][1] = print_input_text ('agente', $nombre_agente, '', 30, 100,true);
|
||||||
|
|
||||||
if (isset ($id_agente) && $id_agente != "") {
|
if (isset ($id_agente) && $id_agente != "") {
|
||||||
echo "
|
$table->data[0][1] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'">
|
||||||
<a href='index.php?sec=estado&
|
<img src="images/lupa.png" border="0" title="'.__('Agent detail').'"></a>';
|
||||||
sec2=operation/agentes/ver_agente&id_agente=".$id_agente."'>
|
|
||||||
<img src='images/lupa.png' border='0' align='middle' title='".__('Agent detail')."'></a>";
|
|
||||||
}
|
|
||||||
// Remote configuration available
|
|
||||||
if (file_exists ($config["remote_config"] . "/" . $agent_md5 . ".md5")) {
|
|
||||||
echo "
|
|
||||||
<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente=".$id_agente."&disk_conf=" . $agent_md5 . "'>
|
|
||||||
<img src='images/application_edit.png' border='0' align='middle' title='".__('This agent can be remotely configured')."'></a>";
|
|
||||||
echo '<a href="#" class="tip"> <span>'.__('You can remotely edit this agent configuration').'</span></a>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<tr><td class="datos2">';
|
// Remote configuration available
|
||||||
echo '<b>'.__('IP Address').'</b>';
|
if (file_exists ($filename['md5'])) {
|
||||||
echo '<td class="datos2">';
|
$table->data[0][1] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$id_agente.'&disk_conf='.$agent_md5.'">
|
||||||
print_input_text ('direccion', $direccion_agente, '', 16, 100);
|
<img src="images/application_edit.png" border="0" title="'.__('This agent can be remotely configured').'"></a>'.print_help_tip (__('You can remotely edit this agent configuration'), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$table->data[1][0] = '<b>'.__('IP Address').'</b>';
|
||||||
|
$table->data[1][1] = print_input_text ('direccion', $direccion_agente, '', 16, 100, true);
|
||||||
|
|
||||||
if ($create_agent != 1) {
|
if ($create_agent != 1) {
|
||||||
echo " ";
|
$table->data[1][1] .= ' ';
|
||||||
|
|
||||||
echo '<select name="address_list">';
|
$ip_all = get_agent_addresses ($id_agente);
|
||||||
$sql1 = "SELECT * FROM taddress, taddress_agent
|
|
||||||
WHERE taddress.id_a = taddress_agent.id_a
|
$table->data[1][1] .= print_select ($ip_all, "address_list", $direccion_agente, '', '', 0, true);
|
||||||
AND taddress_agent.id_agent = $id_agente";
|
$table->data[1][1] .= print_checkbox ("delete_ip", 1, false, true).__('Delete selected');
|
||||||
if ($result=mysql_query($sql1))
|
|
||||||
while ($row=mysql_fetch_array($result)){
|
|
||||||
echo "<option value='".salida_limpia($row["ip"])."'>".salida_limpia($row["ip"])." ";
|
|
||||||
}
|
|
||||||
echo "</select>";
|
|
||||||
|
|
||||||
echo "<input name='delete_ip' type=checkbox value='1'> ".__('Delete selected');
|
|
||||||
echo "</td>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<tr><td class="datos"><b>'.__('Parent').'</b>';
|
$groups = get_user_groups ($config["id_user"]);
|
||||||
echo '<td class="datos">';
|
$agents = get_group_agents (array_keys ($groups));
|
||||||
print_select_from_sql ('SELECT id_agente, nombre FROM tagente ORDER BY nombre',
|
|
||||||
'id_parent', $id_parent, '', 'None', '0');
|
|
||||||
|
|
||||||
echo '<tr><td class="datos"><b>'.__('Group').'</b>';
|
$table->data[2][0] = '<b>'.__('Parent').'</b>';
|
||||||
echo '<td class="datos">';
|
$table->data[2][1] = print_select ($agents, 'id_parent', $id_parent, '', get_agent_name ($id_parent, "lower"), $id_parent, true, false, false); //I use get_agent_name because the user might not have rights to the current parent
|
||||||
print_select_from_sql ('SELECT id_grupo, nombre FROM tgrupo ORDER BY nombre',
|
|
||||||
'grupo', $grupo, '', '', '');
|
|
||||||
|
|
||||||
echo "<tr><td class='datos2'>";
|
$table->data[3][0] = '<b>'.__('Group').'</b>';
|
||||||
echo "<b>".__('Interval')."</b></td>";
|
$table->data[3][1] = print_select ($groups, 'grupo', $grupo, '', '', 0, true, false, false);
|
||||||
echo '<td class="datos2">';
|
|
||||||
|
|
||||||
echo '<input type="text" name="intervalo" size="15" value="'.$intervalo.'"></td>';
|
$table->data[4][0] = '<b>'.__('Interval').'</b>';
|
||||||
echo '<tr><td class="datos"><b>'.__('OS').'</b></td>';
|
$table->data[4][1] = print_input_text ('intervalo', $intervalo, '', 16, 100, true);
|
||||||
echo '<td class="datos">';
|
|
||||||
print_select_from_sql ('SELECT id_os, name FROM tconfig_os ORDER BY name',
|
$table->data[5][0] = '<b>'.__('OS').'</b>';
|
||||||
'id_os', $id_os, '', '', '');
|
$table->data[5][1] = print_select_from_sql ('SELECT id_os, name FROM tconfig_os ORDER BY name', 'id_os', $id_os, '', '', '0', true);
|
||||||
|
|
||||||
// Network server
|
// Network server
|
||||||
echo '<tr><td class="datos2"><b>'.__('Network Server').'</b>';
|
$table->data[6][0] = '<b>'.__('Network Server').'</b>'.print_help_tip (__('You must select a Network Server for the Agent, so it can work properly with this kind of modules'), true);
|
||||||
echo '<a href="#" class="tip"> <span>'.__('You must select a Network Server for the Agent, so it can work properly with this kind of modules').'</span></a>';
|
$table->data[6][1] = print_select_from_sql ('SELECT id_server, name FROM tserver WHERE network_server = 1 ORDER BY name', 'network_server', $id_network_server, '', '', 0, true);
|
||||||
echo '</td><td class="datos2">';
|
|
||||||
$none = '';
|
|
||||||
$none_value = '';
|
|
||||||
if ($id_network_server == 0) {
|
|
||||||
$none = __('None');
|
|
||||||
$none_value = 0;
|
|
||||||
}
|
|
||||||
print_select_from_sql ('SELECT id_server, name FROM tserver WHERE network_server = 1 ORDER BY name',
|
|
||||||
'network_server', $id_network_server, '', $none, $none_value);
|
|
||||||
|
|
||||||
// Plugin Server
|
// Plugin server
|
||||||
echo '<tr><td class="datos"><b>'.__('Plugin Server').'</b>';
|
$table->data[7][0] = '<b>'.__('Plugin Server').'</b>'.print_help_tip (__('You must select a Plugin Server for the Agent, so it can work properly with this kind of modules'), true);
|
||||||
echo '<a href="#" class="tip"> <span>'.__('You must select a Plugin Server for the Agent, so it can work properly with this kind of modules').'</span></a>';
|
$table->data[7][1] = print_select_from_sql ('SELECT id_server, name FROM tserver WHERE plugin_server = 1 ORDER BY name', 'plugin_server', $id_plugin_server, '', '', 0, true);
|
||||||
echo '</td><td class="datos">';
|
|
||||||
$none_str = __('None');
|
|
||||||
$none = '';
|
|
||||||
$none_value = '';
|
|
||||||
if ($id_plugin_server == 0) {
|
|
||||||
$none = $none_str;
|
|
||||||
$none_value = 0;
|
|
||||||
}
|
|
||||||
print_select_from_sql ('SELECT id_server, name FROM tserver WHERE plugin_server = 1 ORDER BY name',
|
|
||||||
'plugin_server', $id_plugin_server, '', $none, $none_value);
|
|
||||||
|
|
||||||
// WMI Server
|
// WMI Server
|
||||||
echo '<tr><td class="datos2"><b>'.__('WMI Server').'</b>';
|
$table->data[8][0] = '<b>'.__('WMI Server').'</b>'.print_help_tip (__('You must select a WMI Server for the Agent, so it can work properly with this kind of modules'), true);
|
||||||
echo '<a href="#" class="tip"> <span>'.__('You must select a WMI Server for the Agent, so it can work properly with this kind of modules').'</span></a>';
|
$table->data[8][1] = print_select_from_sql ('SELECT id_server, name FROM tserver WHERE wmi_server = 1 ORDER BY name', 'wmi_server', $id_wmi_server, '', '', 0, true);
|
||||||
echo '</td><td class="datos2">';
|
|
||||||
$none = '';
|
|
||||||
$none_value = '';
|
|
||||||
if ($id_wmi_server == 0) {
|
|
||||||
$none = $none_str;
|
|
||||||
$none_value = 0;
|
|
||||||
}
|
|
||||||
print_select_from_sql ('SELECT id_server, name FROM tserver WHERE wmi_server = 1 ORDER BY name',
|
|
||||||
'wmi_server', $id_wmi_server, '', $none, $none_value);
|
|
||||||
|
|
||||||
// Prediction Server
|
// Prediction Server
|
||||||
echo '<tr><td class="datos"><b>'.__('Prediction Server').'</b>';
|
$table->data[9][0] = '<b>'.__('Prediction Server').'</b>'.print_help_tip (__('You must select a Prediction Server for the Agent, so it can work properly with this kind of modules'), true);
|
||||||
echo '<a href="#" class="tip"> <span>'.__('You must select a Prediction Server for the Agent, so it can work properly with this kind of modules').'</span></a>';
|
$table->data[9][1] = print_select_from_sql ('SELECT id_server, name FROM tserver WHERE prediction_server = 1 ORDER BY name', 'prediction_server', $id_prediction_server, '', '', 0, true);
|
||||||
echo '</td><td class="datos">';
|
|
||||||
$none = '';
|
|
||||||
$none_value = '';
|
|
||||||
if ($id_prediction_server == 0) {
|
|
||||||
$none = $none_str;
|
|
||||||
$none_value = 0;
|
|
||||||
}
|
|
||||||
print_select_from_sql ('SELECT id_server, name FROM tserver WHERE prediction_server = 1 ORDER BY name',
|
|
||||||
'prediction_server', $id_prediction_server, '', $none, $none_value);
|
|
||||||
|
|
||||||
enterprise_hook ('inventory_server');
|
enterprise_hook ('inventory_server');
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
echo '<tr><td class="datos2"><b>';
|
$table->data[10][0] = '<b>'.__('Description').'</b>';
|
||||||
echo __('Description');
|
$table->data[10][1] = print_input_text ('comentarios', $comentarios, '', 45, 255, true);
|
||||||
echo '</b><td class="datos2">';
|
|
||||||
print_input_text ('comentarios', $comentarios, '', 45, 255);
|
|
||||||
|
|
||||||
// Learn mode / Normal mode
|
// Learn mode / Normal mode
|
||||||
echo '<tr><td class="datos"><b>';
|
$table->data[11][0] = '<b>'.__('Module definition').'</b>'.pandora_help("module_definition", true);
|
||||||
echo __('Module definition');
|
$table->data[11][1] = __('Learning mode').' '.print_radio_button_extended ("modo", 1, '', $modo, false, '', 'style="margin-right: 40px;"', true);
|
||||||
pandora_help("module_definition");
|
$table->data[11][1] .= __('Normal mode').' '.print_radio_button_extended ("modo", 0, '', $modo, false, '', 'style="margin-right: 40px;"', true);
|
||||||
echo '</b><td class="datos">';
|
|
||||||
echo __('Learning mode');
|
|
||||||
print_radio_button_extended ("modo", 1, '', $modo, false, '', 'style="margin-right: 40px;"');
|
|
||||||
echo __('Normal mode');
|
|
||||||
print_radio_button_extended ("modo", 0, '', $modo, false, '', 'style="margin-right: 40px;"');
|
|
||||||
|
|
||||||
// Status (Disabled / Enabled)
|
// Status (Disabled / Enabled)
|
||||||
echo '<tr><td class="datos2"><b>'.__('Status').'</b>';
|
$table->data[12][0] = '<b>'.__('Status').'</b>';
|
||||||
echo '<td class="datos2">';
|
$table->data[12][1] = __('Disabled').' '.print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
|
||||||
echo __('Disabled');
|
$table->data[12][1] .= __('Active').' '.print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
|
||||||
print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"');
|
|
||||||
echo __('Active');
|
|
||||||
print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"');
|
|
||||||
|
|
||||||
// Remote configuration
|
// Remote configuration
|
||||||
echo '<tr><td class="datos"><b>'.__('Remote configuration').'</b>';
|
$table->data[13][0] = '<b>'.__('Remote configuration').'</b>';
|
||||||
echo '<td class="datos">';
|
|
||||||
$filename = $config["remote_config"] . "/" . $agent_md5 . ".md5";
|
|
||||||
if (file_exists($filename)){
|
if (file_exists ($filename['md5'])) {
|
||||||
echo date("F d Y H:i:s.", fileatime($filename));
|
$table->data[13][1] = date ("F d Y H:i:s.", fileatime ($filename['md5']));
|
||||||
// Delete remote configuration
|
// Delete remote configuration
|
||||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&disk_conf_delete=1&id_agente=$id_agente'><img src='images/cross.png'></A>";
|
$table->data[13][1] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&disk_conf_delete=1&id_agente=$id_agente"><img src="images/cross.png" /></a>';
|
||||||
} else {
|
} else {
|
||||||
echo '<i>'.__('Not available').'</i>';
|
$table->data[13][1] = '<i>'.__('Not available').'</i>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</table><table width="650"><tr><td align="right">';
|
print_table ($table);
|
||||||
|
unset ($table);
|
||||||
|
|
||||||
|
echo '<div style="width: 650px; text-align: right;">';
|
||||||
if ($create_agent == 1) {
|
if ($create_agent == 1) {
|
||||||
print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"');
|
print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"');
|
||||||
print_input_hidden ('create_agent', 1);
|
print_input_hidden ('create_agent', 1);
|
||||||
@ -222,7 +169,5 @@ if ($create_agent == 1) {
|
|||||||
print_input_hidden ('update_agent', 1);
|
print_input_hidden ('update_agent', 1);
|
||||||
print_input_hidden ('id_agente', $id_agente);
|
print_input_hidden ('id_agente', $id_agente);
|
||||||
}
|
}
|
||||||
|
echo '</div>';
|
||||||
echo "</td></form></table>";
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -37,7 +37,7 @@ if (! give_acl($config["id_user"], $group, "AW")) {
|
|||||||
|
|
||||||
|
|
||||||
// Get passed variables
|
// Get passed variables
|
||||||
$tab = get_parameter_get ("tab","main");
|
$tab = get_parameter_get ("tab", "main");
|
||||||
$form_moduletype = get_parameter_post ("form_moduletype");
|
$form_moduletype = get_parameter_post ("form_moduletype");
|
||||||
$form_alerttype = get_parameter ("form_alerttype");
|
$form_alerttype = get_parameter ("form_alerttype");
|
||||||
$moduletype = get_parameter_get ("moduletype");
|
$moduletype = get_parameter_get ("moduletype");
|
||||||
@ -490,6 +490,14 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter
|
|||||||
$id_agente = (int) get_parameter_post ("id_agente", 0);
|
$id_agente = (int) get_parameter_post ("id_agente", 0);
|
||||||
$nombre_agente = (string) get_parameter_post ("agente");
|
$nombre_agente = (string) get_parameter_post ("agente");
|
||||||
$direccion_agente = (string) get_parameter_post ("direccion");
|
$direccion_agente = (string) get_parameter_post ("direccion");
|
||||||
|
$address_list = (string) get_parameter_post ("address_list");
|
||||||
|
if ($address_list != $direccion_agente && $direccion_agente == get_agent_address ($id_agente) && $address_list != get_agent_address ($id_agente)) {
|
||||||
|
//If we selected another IP in the drop down list to be 'primary':
|
||||||
|
// a) field is not the same as selectbox
|
||||||
|
// b) field has not changed from current IP
|
||||||
|
// c) selectbox is not the current IP
|
||||||
|
$direccion_agente = $address_list;
|
||||||
|
}
|
||||||
$grupo = (int) get_parameter_post ("grupo", 0);
|
$grupo = (int) get_parameter_post ("grupo", 0);
|
||||||
$intervalo = (int) get_parameter_post ("intervalo", 300);
|
$intervalo = (int) get_parameter_post ("intervalo", 300);
|
||||||
$comentarios = (string) get_parameter_post ("comentarios");
|
$comentarios = (string) get_parameter_post ("comentarios");
|
||||||
|
@ -82,7 +82,7 @@ foreach ($result as $row) {
|
|||||||
$data[0] = '<strong><a href="index.php?sec=gagente&sec2=operation/agentes/ver_agente&id_agente='.
|
$data[0] = '<strong><a href="index.php?sec=gagente&sec2=operation/agentes/ver_agente&id_agente='.
|
||||||
$row["id_agente"].'">'.dame_nombre_agente ($row["id_agente"]).'</a></strong>';
|
$row["id_agente"].'">'.dame_nombre_agente ($row["id_agente"]).'</a></strong>';
|
||||||
//Second row is a number of modules for the agent
|
//Second row is a number of modules for the agent
|
||||||
$data[1] = count (get_modules_in_agent ($row["id_agente"]));
|
$data[1] = get_agentmodule_count ($row["id_agente"]);
|
||||||
//Then the number of data packets for the agent
|
//Then the number of data packets for the agent
|
||||||
$data[2] = $row["count"];
|
$data[2] = $row["count"];
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ if (! give_acl ($config['id_user'], 0, "DM")) {
|
|||||||
|
|
||||||
//id_agent = -1: None selected; id_agent = 0: All
|
//id_agent = -1: None selected; id_agent = 0: All
|
||||||
if (isset ($_POST["agent"])){
|
if (isset ($_POST["agent"])){
|
||||||
$id_agent = (int) get_parameter_post ("agent",-1); //Default to none selected
|
$id_agent = (int) get_parameter_post ("agent", -1); //Default to none selected
|
||||||
} else {
|
} else {
|
||||||
$id_agent = -1;
|
$id_agent = -1;
|
||||||
}
|
}
|
||||||
@ -78,13 +78,13 @@ $data["total"] = 0;
|
|||||||
|
|
||||||
# Purge data using dates
|
# Purge data using dates
|
||||||
if (isset($_POST["purgedb"])) {
|
if (isset($_POST["purgedb"])) {
|
||||||
$from_date = get_parameter_post ("date_purge",0); //0: No time selected
|
$from_date = get_parameter_post ("date_purge", 0); //0: No time selected
|
||||||
if ($id_agent > 0) {
|
if ($id_agent > 0) {
|
||||||
echo __('Purge task launched for agent')." ".dame_nombre_agente ($id_agent)." :: ".__('Data older than')." ".human_time_description ($from_date);
|
echo __('Purge task launched for agent')." ".dame_nombre_agente ($id_agent)." :: ".__('Data older than')." ".human_time_description ($from_date);
|
||||||
echo "<h3>".__('Please be patient. This operation can take a long time depending on the amount of modules.')."</h3>";
|
echo "<h3>".__('Please be patient. This operation can take a long time depending on the amount of modules.')."</h3>";
|
||||||
|
|
||||||
$sql = sprintf ("SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = %d",$id_agent);
|
$sql = sprintf ("SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = %d", $id_agent);
|
||||||
$result=get_db_all_rows_sql($sql);
|
$result=get_db_all_rows_sql ($sql);
|
||||||
if (empty ($result)) {
|
if (empty ($result)) {
|
||||||
$result = array ();
|
$result = array ();
|
||||||
}
|
}
|
||||||
@ -98,13 +98,13 @@ if (isset($_POST["purgedb"])) {
|
|||||||
echo "<br />";
|
echo "<br />";
|
||||||
flush (); //Flush here in case there are errors and the script dies, at least we know where we ended
|
flush (); //Flush here in case there are errors and the script dies, at least we know where we ended
|
||||||
set_time_limit (); //Reset the time limit just in case
|
set_time_limit (); //Reset the time limit just in case
|
||||||
$sql = sprintf("DELETE FROM `tagente_datos` WHERE `id_agente_modulo` = '%d' AND `utimestamp` < '%d'",$row["id_agente_modulo"],$from_date);
|
$sql = sprintf ("DELETE FROM `tagente_datos` WHERE `id_agente_modulo` = %d AND `utimestamp` < %d",$row["id_agente_modulo"],$from_date);
|
||||||
if (process_sql ($sql) === false)
|
if (process_sql ($sql) === false)
|
||||||
$errors++;
|
$errors++;
|
||||||
$sql = sprintf("DELETE FROM `tagente_datos_inc` WHERE `id_agente_modulo` = '%d' AND `utimestamp` < '%d'",$row["id_agente_modulo"],$from_date);
|
$sql = sprintf ("DELETE FROM `tagente_datos_inc` WHERE `id_agente_modulo` = %d AND `utimestamp` < %d",$row["id_agente_modulo"],$from_date);
|
||||||
if (process_sql ($sql) === false)
|
if (process_sql ($sql) === false)
|
||||||
$errors++;
|
$errors++;
|
||||||
$sql = sprintf("DELETE FROM `tagente_datos_string` WHERE `id_agente_modulo` = '%d' AND `utimestamp` < '%d'",$row["id_agente_modulo"],$from_date);
|
$sql = sprintf ("DELETE FROM `tagente_datos_string` WHERE `id_agente_modulo` = %d AND `utimestamp` < %d",$row["id_agente_modulo"],$from_date);
|
||||||
if (process_sql ($sql) === false)
|
if (process_sql ($sql) === false)
|
||||||
$errors++;
|
$errors++;
|
||||||
}
|
}
|
||||||
@ -120,39 +120,29 @@ if (isset($_POST["purgedb"])) {
|
|||||||
//All agents
|
//All agents
|
||||||
echo __('Deleting records for all agents');
|
echo __('Deleting records for all agents');
|
||||||
flush ();
|
flush ();
|
||||||
//ob_flush();
|
$query = sprintf ("DELETE FROM `tagente_datos` WHERE `utimestamp` < %d",$from_date);
|
||||||
$query = sprintf("DELETE FROM `tagente_datos` WHERE `utimestamp` < '%d'",$from_date);
|
|
||||||
process_sql ($query);
|
process_sql ($query);
|
||||||
$query = sprintf("DELETE FROM `tagente_datos_inc` WHERE `utimestamp` < '%d'",$from_date);
|
$query = sprintf ("DELETE FROM `tagente_datos_inc` WHERE `utimestamp` < %d",$from_date);
|
||||||
process_sql ($query);
|
process_sql ($query);
|
||||||
$query = sprintf("DELETE FROM `tagente_datos_string` WHERE `utimestamp` < '%d'",$from_date);
|
$query = sprintf ("DELETE FROM `tagente_datos_string` WHERE `utimestamp` < %d",$from_date);
|
||||||
process_sql ($query);
|
process_sql ($query);
|
||||||
}
|
}
|
||||||
echo "<br /><br />";
|
echo "<br /><br />";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Select Agent for further operations.
|
# Select Agent for further operations.
|
||||||
echo '<form action="index.php?sec=gdbman&sec2=godmode/db/db_purge" method="post">
|
$agents = get_group_agents (1, true);
|
||||||
<table class="databox">
|
|
||||||
<tr><td class="datos">';
|
|
||||||
|
|
||||||
$agents[-1] = __('Choose agent');
|
$agents[-1] = __('Choose agent');
|
||||||
$agents[0] = __('All agents');
|
$agents[0] = __('All agents');
|
||||||
|
|
||||||
$result = get_agents_in_group (1);
|
echo '<form action="index.php?sec=gdbman&sec2=godmode/db/db_purge" method="post">';
|
||||||
if ($result === false)
|
echo '<div style="width:100%;">';
|
||||||
$result = array();
|
print_select ($agents, "agent", $id_agent, "this.form.submit();", "", "", false, false, false);
|
||||||
|
|
||||||
foreach ($result as $row) {
|
|
||||||
$agents[$row["id_agente"]] = $row["nombre"];
|
|
||||||
}
|
|
||||||
|
|
||||||
print_select ($agents, "agent", $id_agent, "", "", "", false, false, false);
|
|
||||||
print_help_tip (__("Select the agent you want information about"));
|
print_help_tip (__("Select the agent you want information about"));
|
||||||
|
echo '<noscript>';
|
||||||
echo '</td><td><input class="sub upd" type="submit" name="purgedb_ag" value="'.__('Get data').'">';
|
print_submit_button (__('Get data'), 'purgedb_ag', false, 'class="sub upd"');
|
||||||
print_help_tip (__("Click here to get the data from the agent specified in the select box"));
|
print_help_tip (__("Click here to get the data from the agent specified in the select box"));
|
||||||
echo '</td></tr></table><br />';
|
echo '</noscript><br />';
|
||||||
|
|
||||||
if ($id_agent > 0) {
|
if ($id_agent > 0) {
|
||||||
$title = __('Information on agent').' '.dame_nombre_agente ($id_agent).' '.__('in the database');
|
$title = __('Information on agent').' '.dame_nombre_agente ($id_agent).' '.__('in the database');
|
||||||
@ -161,10 +151,12 @@ if ($id_agent > 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo "<h3>".$title."</h3>";
|
echo "<h3>".$title."</h3>";
|
||||||
flush ();
|
flush (); //Flush before we do some SQL stuff
|
||||||
$query = "";
|
|
||||||
if ($id_agent > 0) { //If the agent is not All or Not selected
|
if ($id_agent > 0) { //If the agent is not All or Not selected
|
||||||
$query = sprintf (" AND id_agente_modulo = ANY(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = '%d' ",$id_agent);
|
$modules = get_agentmodules ($id_agent);
|
||||||
|
sprintf ("AND id_agente_modulo IN(%s)", implode (",", array_keys ($modules)));
|
||||||
|
} else {
|
||||||
|
$query = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$data["1day"] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp > %d %s", $time["1day"], $query));
|
$data["1day"] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||||
|
@ -369,15 +369,8 @@ if (! $edit_layout && ! $id_layout) {
|
|||||||
$intervals[1440] = __('Two Months');
|
$intervals[1440] = __('Two Months');
|
||||||
$intervals[4320] = __('Six Months');
|
$intervals[4320] = __('Six Months');
|
||||||
|
|
||||||
$all_agents = get_agents_in_group ($id_group);
|
$agents = get_group_agents ($id_group);
|
||||||
$agents = array ();
|
|
||||||
if ($all_agents !== false) {
|
|
||||||
foreach ($all_agents as $agent) {
|
|
||||||
$agents[$agent['id_agente']] = strtolower($agent['nombre']);
|
|
||||||
}
|
|
||||||
asort($agents);
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<div id="layout_editor_drop">';
|
echo '<div id="layout_editor_drop">';
|
||||||
echo '<h1>'.__('Map element editor').'</h1>';
|
echo '<h1>'.__('Map element editor').'</h1>';
|
||||||
echo __('Drag an element here to edit the properties');
|
echo __('Drag an element here to edit the properties');
|
||||||
|
@ -202,14 +202,7 @@ if ($id_report) {
|
|||||||
$report_id_group = $report['id_group'];
|
$report_id_group = $report['id_group'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$all_agents = get_agents_in_group ($report_id_group);
|
$agents = get_group_agents ($report_id_group);
|
||||||
$agents = array ();
|
|
||||||
if ($all_agents !== false) {
|
|
||||||
foreach ($all_agents as $agent) {
|
|
||||||
$agents[$agent['id_agente']] = strtolower($agent['nombre']);
|
|
||||||
}
|
|
||||||
asort ($agents);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($edit_sla_report_content) {
|
if ($edit_sla_report_content) {
|
||||||
/* Edit SLA report form */
|
/* Edit SLA report form */
|
||||||
|
@ -190,44 +190,100 @@ function give_disabled_group ($id_group) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the agents in a group.
|
* Get all the agents within a group(s).
|
||||||
*
|
*
|
||||||
* @param id_group Group id or a comma delimited list of id_groups or an array
|
* @param id_group Group id or a comma delimited list of id_groups or an array
|
||||||
* of ID's
|
* of ID's
|
||||||
*
|
*
|
||||||
* @param disabled Add disabled agents to agents. Default: False.
|
* @param disabled Add disabled agents to agents. Default: False.
|
||||||
|
*
|
||||||
|
* @param case Which case to return the agentname as (lower, upper, none)
|
||||||
*
|
*
|
||||||
* @return An array with all agents in the group.
|
* @return An array with all agents in the group or an empty array
|
||||||
*/
|
*/
|
||||||
function get_agents_in_group ($id_group, $disabled = false) {
|
function get_group_agents ($id_group, $disabled = false, $case = "lower") {
|
||||||
if (is_array ($id_group)) //If id_group is an array, then
|
$id_group = safe_int ($id_group, 1);
|
||||||
$id_group = implode (",", $id_group);
|
|
||||||
|
if (is_array ($id_group)) {
|
||||||
|
//If id_group is an array, then
|
||||||
|
if (in_array (1, $id_group)) {
|
||||||
|
//If All is included in the group list, just select All
|
||||||
|
$id_group = 1;
|
||||||
|
} else {
|
||||||
|
//If All is not included, select what we need
|
||||||
|
$id_group = implode (",", $id_group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* 'All' group must return all agents */
|
/* 'All' group must return all agents */
|
||||||
if ($id_group == 1) {
|
$search = '';
|
||||||
if ($disabled) {
|
if (!empty ($id_group) && $id_group > 1) {
|
||||||
return get_db_all_rows_in_table ('tagente', 'nombre');
|
$search .= sprintf (' WHERE id_grupo IN (%s)', $id_group);
|
||||||
} else {
|
|
||||||
return get_db_all_rows_field_filter ('tagente', 'disabled', 0, 'nombre');
|
|
||||||
}
|
|
||||||
} elseif ($disabled && $id_group != 1) {
|
|
||||||
$sql = sprintf ("SELECT * FROM tagente WHERE id_grupo IN (%s) ORDER BY nombre",$id_group);
|
|
||||||
return get_db_all_rows_sql ($sql);
|
|
||||||
} else {
|
|
||||||
$sql = sprintf ("SELECT * FROM tagente WHERE id_grupo IN (%s) AND disabled = 0 ORDER BY nombre",$id_group);
|
|
||||||
return get_db_all_rows_sql ($sql);
|
|
||||||
}
|
}
|
||||||
|
if ($disabled !== false) {
|
||||||
|
$search .= (($search == '') ? ' WHERE' : ' AND' ).' disabled = 0';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = sprintf ("SELECT id_agente, nombre FROM tagente%s ORDER BY nombre", $search);
|
||||||
|
$result = get_db_all_rows_sql ($sql);
|
||||||
|
|
||||||
|
if ($result === false)
|
||||||
|
return array (); //Return an empty array
|
||||||
|
|
||||||
|
$agents = array ();
|
||||||
|
foreach ($result as $row) {
|
||||||
|
switch ($case) {
|
||||||
|
case "lower":
|
||||||
|
$agents[$row["id_agente"]] = mb_strtolower ($row["nombre"],"UTF-8");
|
||||||
|
break;
|
||||||
|
case "upper":
|
||||||
|
$agents[$row["id_agente"]] = mb_strtoupper ($row["nombre"],"UTF-8");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$agents[$row["id_agente"]] = $row["nombre"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ($agents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the modules in an agent.
|
* Get all the modules in an agent.
|
||||||
*
|
*
|
||||||
* @param $id_agent Agent id
|
* @param $id_agent Agent id
|
||||||
|
* @param $details Array, comma delimited list or singular value of rows to select. If nothing is specified, nombre will be selected
|
||||||
*
|
*
|
||||||
* @return An array with all modules in the agent.
|
* @return An array with all modules in the agent. If multiple rows are selected, they will be in an array
|
||||||
*/
|
*/
|
||||||
function get_modules_in_agent ($id_agent) {
|
function get_agentmodules ($id_agent, $details = false) {
|
||||||
return get_db_all_rows_field_filter ('tagente_modulo', 'id_agente', (int) $id_agent);
|
$id_agent = safe_int ($id_agent, 1);
|
||||||
|
|
||||||
|
if (empty ($id_agent)) {
|
||||||
|
$filter = '';
|
||||||
|
} elseif (is_array ($id_agent)) {
|
||||||
|
$filter = sprintf (' WHERE id_agente IN (%s)', implode (",",$id_agent));
|
||||||
|
} else {
|
||||||
|
$filter = sprintf (' WHERE id_agente = %d', $id_agent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty ($details)) {
|
||||||
|
$details = "nombre";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT id_agente_modulo,".implode (",", (array) $details)." FROM tagente_modulo".$filter." ORDER BY nombre";
|
||||||
|
$result = get_db_all_rows_sql ($sql); //cast as array, that way a false will be converted into an array
|
||||||
|
if (empty ($result)) {
|
||||||
|
$result = array ();
|
||||||
|
}
|
||||||
|
$modules = array ();
|
||||||
|
|
||||||
|
foreach ($result as $row) {
|
||||||
|
if (is_array ($details)) {
|
||||||
|
$modules[$row["id_agente_modulo"]] = $row; //Just stack the information in array by ID
|
||||||
|
} else {
|
||||||
|
$modules[$row["id_agente_modulo"]] = $row[$details];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -361,14 +417,36 @@ function return_event_description ($id_event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get name of an agent.
|
* DEPRECATED: Use get_agent_name instead
|
||||||
*
|
*
|
||||||
* @param id_agent Agent id.
|
* @param id_agent Agent id.
|
||||||
*
|
*
|
||||||
* @return Name of the given agent.
|
* @return Name of the given agent.
|
||||||
*/
|
*/
|
||||||
function dame_nombre_agente ($id_agent) {
|
function dame_nombre_agente ($id_agent) {
|
||||||
return (string) get_db_value ('nombre', 'tagente', 'id_agente', (int) $id_agent);
|
return get_agent_name ($id_agent, "none");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name of an agent.
|
||||||
|
*
|
||||||
|
* @param id_agent Agent id.
|
||||||
|
* @param case Case (upper, lower, none)
|
||||||
|
*
|
||||||
|
* @return Name of the given agent.
|
||||||
|
*/
|
||||||
|
function get_agent_name ($id_agent, $case = "upper") {
|
||||||
|
$agent = (string) get_db_value ('nombre', 'tagente', 'id_agente', (int) $id_agent);
|
||||||
|
switch ($case) {
|
||||||
|
case "upper":
|
||||||
|
return mb_strtoupper ($agent,"UTF-8");
|
||||||
|
break;
|
||||||
|
case "lower":
|
||||||
|
return mb_strtolower ($agent,"UTF-8");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return ($agent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -662,12 +740,10 @@ function get_alert_fires_in_period ($id_agent_module, $period, $date = 0) {
|
|||||||
*/
|
*/
|
||||||
function get_alerts_in_group ($id_group) {
|
function get_alerts_in_group ($id_group) {
|
||||||
$alerts = array ();
|
$alerts = array ();
|
||||||
$agents = get_agents_in_group ($id_group);
|
$agents = get_group_agents ($id_group, false, "none");
|
||||||
if (empty ($agents))
|
|
||||||
return $alerts;
|
|
||||||
|
|
||||||
foreach ($agents as $agent) {
|
foreach ($agents as $agent_id => $agent_name) {
|
||||||
$agent_alerts = get_alerts_in_agent ($agent["id_agente"]);
|
$agent_alerts = get_alerts_in_agent ($agent_id);
|
||||||
$alerts = array_merge ($alerts, $agent_alerts);
|
$alerts = array_merge ($alerts, $agent_alerts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1287,7 +1363,7 @@ function agent_delete_address ($id_agent, $ip_address) {
|
|||||||
if (get_agent_address ($id_agent) == $ip_address) {
|
if (get_agent_address ($id_agent) == $ip_address) {
|
||||||
$new_ips = get_agent_addresses ($id_agent);
|
$new_ips = get_agent_addresses ($id_agent);
|
||||||
// Change main address in agent to first one in the list
|
// Change main address in agent to first one in the list
|
||||||
$query = sprintf ("UPDATE tagente SET `direccion` = '%s' WHERE id_agente = %d", $new_ips[0], $id_agent);
|
$query = sprintf ("UPDATE tagente SET `direccion` = '%s' WHERE id_agente = %d", current ($new_ips), $id_agent);
|
||||||
process_sql ($query);
|
process_sql ($query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1324,7 +1400,7 @@ function get_agent_with_ip ($ip_address) {
|
|||||||
*
|
*
|
||||||
* @param id_agent Agent id
|
* @param id_agent Agent id
|
||||||
*
|
*
|
||||||
* @return Array with the IP address of the given agent.
|
* @return Array with the IP address of the given agent or an empty array.
|
||||||
*/
|
*/
|
||||||
function get_agent_addresses ($id_agent) {
|
function get_agent_addresses ($id_agent) {
|
||||||
$sql = sprintf ("SELECT ip FROM taddress_agent, taddress
|
$sql = sprintf ("SELECT ip FROM taddress_agent, taddress
|
||||||
@ -1339,7 +1415,7 @@ function get_agent_addresses ($id_agent) {
|
|||||||
|
|
||||||
$ret_arr = array ();
|
$ret_arr = array ();
|
||||||
foreach ($ips as $row) {
|
foreach ($ips as $row) {
|
||||||
$ret_arr[] = $row["ip"];
|
$ret_arr[$row["ip"]] = $row["ip"];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret_arr;
|
return $ret_arr;
|
||||||
@ -2365,11 +2441,23 @@ function get_server_info ($id_server = -1) {
|
|||||||
/**
|
/**
|
||||||
* This function will return the number of all agent modules in the database
|
* This function will return the number of all agent modules in the database
|
||||||
*
|
*
|
||||||
|
* @param integer or array of integers with agent(s). Leave empty to select everything
|
||||||
|
*
|
||||||
* @return integer with the number of agent modules
|
* @return integer with the number of agent modules
|
||||||
*
|
*
|
||||||
* TODO: Filter? Implement when necessary
|
|
||||||
**/
|
**/
|
||||||
function get_agentmodule_count () {
|
function get_agentmodule_count ($id_agent = 0) {
|
||||||
return (int) get_db_sql ("SELECT COUNT(*) FROM tagente_modulo");
|
$id_agent = safe_int ($id_agent); //Make sure we're all int's and filter out bad stuff
|
||||||
|
if (empty ($id_agent) || $id_agent < 1) {
|
||||||
|
//If the array proved empty or the agent is less than 1 (eg. -1)
|
||||||
|
$filter = '';
|
||||||
|
} elseif (is_array ($id_agent)) {
|
||||||
|
//If it's an array of agents, flatten the aray
|
||||||
|
$filter = sprintf (" WHERE id_agente IN (%s)", implode (",",$id_agent));
|
||||||
|
} else {
|
||||||
|
$filter = sprintf (" WHERE id_agente = %d", $id_agent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) get_db_sql ("SELECT COUNT(*) FROM tagente_modulo".$filter);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -113,12 +113,7 @@ function print_select_from_sql ($sql, $name, $selected = '', $script = '', $noth
|
|||||||
$fields[$row[0]] = $row[1];
|
$fields[$row[0]] = $row[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, true, $multiple, $sort);
|
return print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, $return, $multiple, $sort);
|
||||||
|
|
||||||
if ($return)
|
|
||||||
return $output;
|
|
||||||
|
|
||||||
echo $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,7 +221,7 @@ function get_group_stats ($id_group) {
|
|||||||
} //End module check
|
} //End module check
|
||||||
} //End foreach module
|
} //End foreach module
|
||||||
|
|
||||||
$data["total_agents"] = count (get_agents_in_group ($groups));
|
$data["total_agents"] = count (get_group_agents ($groups, false, "none"));
|
||||||
$data["total_checks"] = $data["data_checks"] + $data["monitor_checks"];
|
$data["total_checks"] = $data["data_checks"] + $data["monitor_checks"];
|
||||||
$data["total_ok"] = $data["data_ok"] + $data["monitor_ok"];
|
$data["total_ok"] = $data["data_ok"] + $data["monitor_ok"];
|
||||||
$data["total_alerts"] = $data["data_alerts"] + $data["monitor_alerts"];
|
$data["total_alerts"] = $data["data_alerts"] + $data["monitor_alerts"];
|
||||||
@ -496,7 +496,7 @@ function get_monitors_down_reporting_table ($monitors_down) {
|
|||||||
$data = array ();
|
$data = array ();
|
||||||
foreach ($monitors as $monitor) {
|
foreach ($monitors as $monitor) {
|
||||||
if (! isset ($data[0]))
|
if (! isset ($data[0]))
|
||||||
$data[0] = dame_nombre_agente ($id_agent);
|
$data[0] = get_agent_name ($id_agent);
|
||||||
else
|
else
|
||||||
$data[0] = '';
|
$data[0] = '';
|
||||||
if ($monitor['descripcion'] != '') {
|
if ($monitor['descripcion'] != '') {
|
||||||
@ -520,12 +520,12 @@ function get_monitors_down_reporting_table ($monitors_down) {
|
|||||||
* @param $return Flag to return or echo the report (by default).
|
* @param $return Flag to return or echo the report (by default).
|
||||||
*/
|
*/
|
||||||
function general_group_reporting ($id_group, $return = false) {
|
function general_group_reporting ($id_group, $return = false) {
|
||||||
$output = '';
|
$agents = get_group_agents ($id_group, false, "none");
|
||||||
$agents = get_agents_in_group ($id_group);
|
$output = '<strong>'.__('Agents in group').': '.count ($agents).'</strong><br />';
|
||||||
$output .= '<strong>'.__('Agents in group').': '.sizeof ($agents).'</strong><br />';
|
|
||||||
|
|
||||||
if (!$return)
|
if ($return === false)
|
||||||
echo $output;
|
echo $output;
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,7 +619,7 @@ function get_agent_monitors_reporting_table ($id_agent, $period = 0, $date = 0)
|
|||||||
function get_agent_modules_reporting_table ($id_agent, $period = 0, $date = 0) {
|
function get_agent_modules_reporting_table ($id_agent, $period = 0, $date = 0) {
|
||||||
$table->data = array ();
|
$table->data = array ();
|
||||||
$n_a_string = __('N/A').'(*)';
|
$n_a_string = __('N/A').'(*)';
|
||||||
$modules = get_modules_in_agent ($id_agent);
|
$modules = get_agentmodules ($id_agent, array ("nombre", "descripcion"));
|
||||||
if ($modules === false)
|
if ($modules === false)
|
||||||
$modules = array();
|
$modules = array();
|
||||||
$data = array ();
|
$data = array ();
|
||||||
@ -693,20 +693,16 @@ function get_agent_detailed_reporting ($id_agent, $period = 0, $date = 0, $retur
|
|||||||
* @param $return Flag to return or echo the report (by default).
|
* @param $return Flag to return or echo the report (by default).
|
||||||
*/
|
*/
|
||||||
function get_agents_detailed_reporting ($id_group, $period = 0, $date = 0, $return = false) {
|
function get_agents_detailed_reporting ($id_group, $period = 0, $date = 0, $return = false) {
|
||||||
$output = '';
|
$agents = get_group_agents ($id_group, false, "none");
|
||||||
$agents = get_agents_in_group ($id_group);
|
|
||||||
|
|
||||||
foreach ($agents as $agent) {
|
$output = '';
|
||||||
$output .= get_agent_detailed_reporting ($agent['id_agente'], $period, $date, true);
|
foreach ($agents as $agent_id => $agent_name) {
|
||||||
if (!$return) {
|
$output .= get_agent_detailed_reporting ($agent_id, $period, $date, true);
|
||||||
echo $output;
|
|
||||||
$output = '';
|
|
||||||
flush ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$return)
|
if ($return === false)
|
||||||
echo $output;
|
echo $output;
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,10 +144,10 @@ if (isset($_GET["id_agente"])){
|
|||||||
|
|
||||||
// Agent group selector
|
// Agent group selector
|
||||||
if ($ag_group > 1) {
|
if ($ag_group > 1) {
|
||||||
$result = get_agents_in_group ($ag_group);
|
$result = get_group_agents ($ag_group, false, "upper");
|
||||||
} else {
|
} else {
|
||||||
//Fields is an array with all the groups the user has access to
|
//Fields is an array with all the groups the user has access to
|
||||||
$result = get_agents_in_group (array_keys ($fields));
|
$result = get_group_agents (array_keys ($fields), false, "upper");
|
||||||
}
|
}
|
||||||
|
|
||||||
$color = 1;
|
$color = 1;
|
||||||
@ -174,9 +174,7 @@ if (isset($_GET["id_agente"])){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//This result is the array with agents
|
//This result is the array with agents
|
||||||
foreach ($result as $row) {
|
foreach ($result as $id_agente => $nombre_agente) {
|
||||||
$id_agente = $row["id_agente"];
|
|
||||||
$nombre_agente = strtoupper ($row["nombre"]);
|
|
||||||
$result_alerts = get_alerts_in_agent ($id_agente);
|
$result_alerts = get_alerts_in_agent ($id_agente);
|
||||||
|
|
||||||
if ($result_alerts === false)
|
if ($result_alerts === false)
|
||||||
|
@ -161,7 +161,7 @@ if (dame_admin ($config["id_user"])) {
|
|||||||
foreach ($result as $id_row) {
|
foreach ($result as $id_row) {
|
||||||
$name_for_combo = "";
|
$name_for_combo = "";
|
||||||
if ($id_row[0] > 0)
|
if ($id_row[0] > 0)
|
||||||
$name_for_combo = substr (strtolower (dame_nombre_agente ($id_row[0])),0,20);
|
$name_for_combo = substr (get_agent_name ($id_row[0], "lower"),0,20);
|
||||||
if ($name_for_combo != "")
|
if ($name_for_combo != "")
|
||||||
$agents[$id_row[0]] = $name_for_combo;
|
$agents[$id_row[0]] = $name_for_combo;
|
||||||
}
|
}
|
||||||
|
@ -1207,8 +1207,8 @@ function grafico_db_agentes_modulos($width, $height) {
|
|||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$data[] = count (get_modules_in_agent ($row["id_agente"]));
|
$data[] = get_agentmodule_count ($row["id_agente"]);
|
||||||
$legend[] = dame_nombre_agente ($row["id_agente"]);
|
$legend[] = get_agent_name ($row["id_agente"], "lower");
|
||||||
}
|
}
|
||||||
|
|
||||||
generic_bar_graph ($width, $height, $data, $legend);
|
generic_bar_graph ($width, $height, $data, $legend);
|
||||||
@ -1370,7 +1370,7 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "") {
|
|||||||
$legend[] = "SYSTEM (".$row["count"].")";
|
$legend[] = "SYSTEM (".$row["count"].")";
|
||||||
} else {
|
} else {
|
||||||
//Other events
|
//Other events
|
||||||
$legend[] = substr (dame_nombre_agente ($row["id_agente"]), 0, 15)." (".$row["count"].")";
|
$legend[] = substr (get_agent_name ($row["id_agente"], "lower"), 0, 15)." (".$row["count"].")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1434,7 +1434,7 @@ function grafico_db_agentes_paquetes ($width = 380, $height = 300) {
|
|||||||
|
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$data[] = $row["count"];
|
$data[] = $row["count"];
|
||||||
$legend[] = dame_nombre_agente ($row["id_agente"]);
|
$legend[] = get_agent_name ($row["id_agente"], "lower");
|
||||||
}
|
}
|
||||||
|
|
||||||
generic_bar_graph ($width, $height, $data, $legend);
|
generic_bar_graph ($width, $height, $data, $legend);
|
||||||
@ -1447,7 +1447,8 @@ function grafico_db_agentes_purge ($id_agent, $width, $height) {
|
|||||||
$id_agent = -1;
|
$id_agent = -1;
|
||||||
$query = "";
|
$query = "";
|
||||||
} else {
|
} else {
|
||||||
$query = sprintf (" AND id_agente_modulo = ANY(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = '%d' ",$id_agent);
|
$modules = get_agentmodules ($id_agent);
|
||||||
|
$query = sprintf (" AND id_agente_modulo IN (%s)", implode (",", array_keys ($modules)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// All data (now)
|
// All data (now)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user