2009-04-20 Esteban Sanchez <estebans@artica.es>

* godmode/agentes/module_manager_editor.php,
	godmode/agentes/module_manager_editor_common.php,
	godmode/agentes/module_manager_editor_data.php,
	godmode/agentes/module_manager_editor_network.php,
	godmode/agentes/module_manager_editor_plugin.php,
	godmode/agentes/module_manager_editor_prediction.php,
	godmode/agentes/module_manager_editor_wmi.php,
	godmode/agentes/module_manager.php: Some fixes to allow form
	reutilization.
	
	* include/javascript/jquery.pandora.controls.js: Fixed a typo. Added 
	pandoraSelectGroup control.
	
	* include/javascript/jquery.pandora.js: Separate between auto executed code
	and document ready function.
	
	* include/javascript/pandora_modules.js: Added to repository. Functions to
	use on module editors.
	
	* include/functions_agents.php: Added get_agents().
	
	* include/functions_db.php: Added get_user_first_group(). Changed
	user_access_to_agent() parameters order.
	
	* include/functions_reporting.php: Style corrections.
	
	* include/functions_ui.php: Added doc to print_status_image(). Added 
	print_ui_agents_list() to print a list of agents with a search form and
	a lot of configuration options easily.
	
	* include/functions_ui_renders.php: Added to repository. New API for
	renders on UI components.
	
	* operation/agentes/estado_agente.php: Make table wider.
	
	* godmode/reporting/reporting_builder.php: Replaced exit with return. Use
	pandoraSelectGroup control.
	
	* godmode/servers/manage_recontask_form.php: Style corrections to fit
	Pandora styles.
	
	* godmode/servers/modificar_server.php: Removed a notice from a typo.
	
	* godmode/setup/setup.php: Fixed table data indexes. Removed javascript
	code from visual setup.
	
	* godmode/setup/setup_visuals.php: Some strings changed. Style correction.
	
	* godmode/menu.php: Added policies enterprise menu option.
	
	* images/policies.png: Added to repository.
	
	* godmode/agentes/modificar_agente.php: Style correction by using pandora
	functions.

	* godmode/agentes/massive_operations.php: Fixed tab styles that was showing
	wrong the .

	* godmode/agentes/manage_config_remote.php: Changes in
	user_access_to_agent()

	* general/ui/agents_list.php: Added to repository. Reusable render for an
	agent list.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1632 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2009-04-20 14:00:27 +00:00
parent 137ecd9885
commit 06815860a5
30 changed files with 876 additions and 408 deletions

View File

@ -1,3 +1,30 @@
2009-04-20 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/module_manager_editor.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/module_manager_editor_wmi.php,
godmode/agentes/module_manager.php: Some fixes to allow form
reutilization.
* godmode/reporting/reporting_builder.php: Replaced exit with return. Use
pandoraSelectGroup() control.
* godmode/agentes/modificar_agente.php: Style correction by using pandora
functions.
* godmode/agentes/massive_operations.php: Fixed tab styles that was showing
wrong the .
* godmode/agentes/manage_config_remote.php: Changes in
user_access_to_agent()
* general/ui/agents_list.php: Added to repository. Reusable render for an
agent list.
2009-04-20 Jorge Gonzalez <jorgegonz@artica.es>
* include/languages/es.po, include/languages/es.mo: Updated Spanish

View File

@ -0,0 +1,217 @@
<?php
// Pandora FMS - the Flexible Monitoring System
// ============================================
// Copyright (c) 2009 Artica Soluciones Tecnologicas, http://www.artica.es
// Please see http://pandora.sourceforge.net for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License (LGPL)
// as published by the Free Software Foundation for version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require_once ('include/config.php');
require_once ('include/functions_agents.php');
if (is_ajax ()) {
$search_agents = (bool) get_parameter ('search_agents');
if ($search_agents) {
require_once ('include/functions_ui_renders.php');
$filter = str_replace ("\\\"", "\"", $_POST['filter']);
$filter = json_decode ($filter, true);
$fields = '';
if (isset ($_POST['fields']))
$fields = json_decode (str_replace ("\\\"", "\"", $_POST['fields']));
$table_renders = str_replace ("\\\"", "\"", $_POST['table_renders']);
$table_renders = json_decode ($table_renders, true);
print_r ($fields);
$access = (string) get_parameter ('access', 'AR');
foreach ($_POST as $field => $value) {
$value = safe_input ($value);
switch ($field) {
case 'page':
case 'search_agents':
case 'search':
case 'table_renders':
case 'fields':
case 'filter':
case 'access':
continue;
case 'search':
array_push ($filter, '(nombre LIKE "%%'.$value.'%%" OR descripcion LIKE "%%'.$value.'%%")');
break;
case 'id_group':
if ($value == 1)
$filter['id_grupo'] = array_keys (get_user_groups (false, $value));
else
$filter['id_grupo'] = $value;
break;
default:
$filter[$field] = $value;
}
}
$agents = get_agents ($filter, $fields, $access);
$all_data = array ();
if ($agents !== false) {
foreach ($agents as $agent) {
$data = array ();
foreach ($table_renders as $name => $values) {
if (! is_numeric ($name)) {
array_push ($data, render_agent_field (&$agent, $name, $values, true));
} else {
array_push ($data, render_agent_field (&$agent, $values, false, true));
}
}
array_push ($all_data, $data);
}
}
echo json_encode ($all_data);
return;
}
return;
}
require_once ('include/functions_ui_renders.php');
check_login ();
if ($show_filter_form) {
$table->width = '90%';
$table->id = 'search_agent_table';
$table->data = array ();
$table->size = array ();
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->style[2] = 'font-weight: bold';
$odd = true;
if ($group_filter) {
if ($odd)
$data = array ();
$data = array ();
$data[] = __('Group');
$data[] = print_select (get_user_groups (false, $access),
'id_group', '', '', '', '', true);
if (! $odd)
array_push ($table->data, $data);
$odd = !$odd;
}
if ($text_filter) {
if ($odd)
$data = array ();
$data[] = __('Search');
$data[] = print_input_text ('search', '', '', 15, 255, true);
if (! $odd)
array_push ($table->data, $data);
$odd = !$odd;
}
echo '<form id="agent_search" method="post">';
print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
print_submit_button (__('Search'), 'search', false, 'class="sub search"');
print_input_hidden ('search_agents', 1);
echo '</div>';
echo '</form>';
require_jquery_file ('form');
}
$table->width = '90%';
$table->id = 'agents_table';
$table->head = $table_heads;
$table->align = $table_align;
$table->size = $table_size;
$table->data = array ();
$agents = get_agents ($filter, $fields, $access);
echo '<div id="agents_loading" class="loading invisible">';
echo '<img src="images/spinner.gif" />';
echo __('Loading').'&hellip;';
echo '</div>';
echo '<div id="agents_list"'.($agents === false ? ' class="invisible"' : '').'">';
echo '<div id="no_agents"'.($agents === false ? '' : ' class="invisible"').'>';
print_error_message (__('No agents found'));
echo '</div>';
if ($agents !== false) {
foreach ($agents as $agent) {
$data = array ();
foreach ($table_renders as $name => $values) {
if (! is_numeric ($name)) {
array_push ($data, render_agent_field (&$agent, $name, $values, true));
} else {
array_push ($data, render_agent_field (&$agent, $values, false, true));
}
}
array_push ($table->data, $data);
}
}
print_table ($table);
echo '</div>';
?>
<script type="text/javascript">
/* <![CDATA[ */
var table_renders = '<?php echo json_encode ($table_renders) ?>';
var fields = '<?php echo json_encode ($fields) ?>';
var filter = '<?php echo json_encode ($filter) ?>';
$(document).ready (function () {
<?php if ($show_filter_form): ?>
$("form#agent_search").submit (function () {
$("#agents_loading").show ();
$("#no_agents, #agents_list, table#agents_table").hide ();
$("table#agents_table tbody tr").remove ();
values = $(this).formToArray ();
values.push ({name: "page", value: "general/ui/agents_list"});
values.push ({name: "table_renders", value: table_renders});
values.push ({name: "filter", value: filter});
if (fields != "")
values.push ({name: "fields", value: fields});
jQuery.post ("ajax.php",
values,
function (data, status) {
if (! data || data.length == 0) {
$("#agents_loading").hide ();
$("#agents_list, #no_agents").show ();
return;
}
jQuery.each (data, function () {
tr = $("<tr></tr>");
len = this.length;
for (i = 0; i < len; i++) {
td = $("<td></td>").html (this[i]);
tr.append (td);
}
$("table#agents_table tbody").append (tr);
});
$("#agents_loading").hide ();
$("#agents_list, table#agents_table").show ();
},
"json"
);
return false;
});
<?php endif; ?>
});
/* ]]> */
</script>

View File

@ -182,6 +182,7 @@ if ($create_agent) {
$img_style = array ("class" => "top", "width" => 16);
if ($id_agente) {
echo '<div id="menu_tab_frame"><div id="menu_tab_left"><ul class="mn">';
echo '<li class="nomn"><a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente='.$id_agente.'">';
print_image ("images/setup.png", false, $img_style);

View File

@ -55,7 +55,7 @@ if ((isset($_GET["operacion"])) AND ($update_group == -1) ) {
$id_origen = get_parameter ("origen");
// Security check here
if (!user_access_to_agent ($config["id_user"], $id_origen,"AR")) {
if (!user_access_to_agent ($id_origen)) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to forge a source agent in remote config tool");
require ("general/noaccess.php");
exit;
@ -69,7 +69,7 @@ if ((isset($_GET["operacion"])) AND ($update_group == -1) ) {
$id_agente = $destino[$a];
// Security check here
if (!user_access_to_agent ($config["id_user"], $id_agente, "AR")){
if (!user_access_to_agent ($id_agente)){
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to forge a source agent in remote config tool");
require ("general/noaccess.php");
exit;

View File

@ -30,7 +30,7 @@ require_once ('include/functions_agents.php');
require_once ('include/functions_alerts.php');
require_once ('include/functions_modules.php');
$tab = (string) get_parameter ('tab');
$tab = (string) get_parameter ('tab', 'copy_modules');
$img_style = array ("class" => "top", "width" => 16);
@ -44,25 +44,25 @@ print_image ("images/copy.png", false, $img_style);
echo '&nbsp;'.__('Copy').'</a>';
echo '</li>';
echo '<li class="'.($tab == 'edit_modules' || $tab == '' ? 'nomn_high' : 'nomn').'">';
echo '<li class="'.($tab == 'edit_modules' ? 'nomn_high' : 'nomn').'">';
echo '<a href="index.php?sec=gagente&sec2=godmode/agentes/massive_operations&tab=edit_modules">';
print_image ("images/book_edit.png", false, $img_style);
echo '&nbsp; '.__('Edit modules').'</a>';
echo '</li>';
echo '<li class="'.($tab == 'delete_agents' || $tab == '' ? 'nomn_high' : 'nomn').'">';
echo '<li class="'.($tab == 'delete_agents' ? 'nomn_high' : 'nomn').'">';
echo '<a href="index.php?sec=gagente&sec2=godmode/agentes/massive_operations&tab=delete_agents">';
print_image ("images/delete_agents.png", false, $img_style);
echo '&nbsp; '.__('Delete agents').'</a>';
echo '</li>';
echo '<li class="'.($tab == 'delete_modules' || $tab == '' ? 'nomn_high' : 'nomn').'">';
echo '<li class="'.($tab == 'delete_modules' ? 'nomn_high' : 'nomn').'">';
echo '<a href="index.php?sec=gagente&sec2=godmode/agentes/massive_operations&tab=delete_modules">';
print_image ("images/delete_modules.png", false, $img_style);
echo '&nbsp; '.__('Delete modules').'</a>';
echo '</li>';
echo '<li class="'.($tab == 'delete_alerts' || $tab == '' ? 'nomn_high' : 'nomn').'">';
echo '<li class="'.($tab == 'delete_alerts' ? 'nomn_high' : 'nomn').'">';
echo '<a href="index.php?sec=gagente&sec2=godmode/agentes/massive_operations&tab=delete_alerts">';
print_image ("images/delete_alerts.png", false, $img_style);
echo '&nbsp; '.__('Delete alerts').'</a>';

View File

@ -237,11 +237,9 @@ if ($agents !== false) {
}
// Create agent button
echo "<form method='post' action='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente'>";
echo '<form method="post" action="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente">';
print_input_hidden ('new_agent', 1);
echo "<input type='submit' class='sub next' name='crt'
value='".__('Create agent')."'>";
print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"');
echo "</form></td></tr></table>";
?>

View File

@ -16,19 +16,17 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Load global vars
if (!isset ($id_agente)) {
die ("Not Authorized");
/* You can redefine $url and unset $id_agente to reuse the form. Dirty (hope temporal) hack */
if (isset ($id_agente)) {
$url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente;
echo "<h2>".__('Agent configuration')." &raquo; ".__('Modules')."</h2>";
}
enterprise_include ('godmode/agentes/module_manager.php');
echo "<h2>".__('Agent configuration')." &raquo; ".__('Modules')."</h2>";
// Create module/type combo
echo '<table width="300" cellpadding="4" cellspacing="4" class="databox">';
echo '<form name="modulo" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente.'">';
echo '<form id="create_module_type" method="post" action="'.$url.'">';
echo "<tr><td class='datos'>";
// Check if there is at least one server of each type available to assign that
@ -65,6 +63,8 @@ echo '<input align="right" name="updbutton" type="submit" class="sub wand" value
echo "</form>";
echo "</table>";
if (! isset ($id_agente))
return;
// ==========================
// MODULE VISUALIZATION TABLE
// ==========================

View File

@ -69,10 +69,6 @@ if (is_ajax ()) {
return;
}
if (!isset ($id_agente)) {
die ("Not Authorized");
}
require_once ("include/functions_exportserver.php");
// Using network component to fill some fields
@ -214,7 +210,9 @@ echo '<h3 id="message" class="error invisible"></h3>';
echo '<form method="post" id="module_form">';
print_table ($table_simple);
echo '<a href="#" id="show_advanced">'.__('Advanced options').' &raquo; </a>';
echo '<a href="#" id="show_advanced" onclick="$(\'div#advanced\').show ();$(this).remove (); return false">';
echo __('Advanced options').' &raquo;';
echo '</a>';
echo '<div id="advanced" style="display: none">';
print_table ($table_advanced);
@ -236,189 +234,18 @@ echo '</form>';
require_jquery_file ('ui');
require_jquery_file ('form');
?>
require_jquery_file ('pandora');
require_javascript_file ('pandora_modules');
?>
<script language="javascript">
/* Modules ids to check types */
var icmp = Array (6, 7);
var tcp = Array (8, 9, 10, 11);
var snmp = Array (15, 16, 17, 18);
/* <![CDATA[ */
var no_name_lang = "<?php echo __('No module name provided') ?>";
var no_target_lang = "<?php echo __('No target IP provided') ?>";
var no_oid_lang = "<?php echo __('No SNMP OID provided') ?>";
$(document).ready (function () {
$("#id_module_type").change (function () {
if (icmp.in_array (this.value)) {
$("tr#simple-snmp_1, tr#simple-snmp_2, tr#advanced-tcp_send, tr#advanced-tcp_receive").hide ();
$("#text-tcp_port").attr ("disabled", "1");
} else if (snmp.in_array (this.value)) {
$("tr#simple-snmp_1, tr#simple-snmp_2").show ();
$("tr#advanced-tcp_send, tr#advanced-tcp_receive").hide ();
$("#text-tcp_port").removeAttr ("disabled");
} else if (tcp.in_array (this.value)) {
$("tr#simple-snmp_1, tr#simple-snmp_2").hide ();
$("tr#advanced-tcp_send, tr#advanced-tcp_receive").show ();
$("#text-tcp_port").removeAttr ("disabled");
}
});
$("#network_component_group").change (function () {
var $select = $("#network_component").hide ();
$("#component").hide ();
if (this.value == 0)
return;
$("#component_loading").show ();
$(".error, #no_component").hide ();
$("option[value!=0]", $select).remove ();
jQuery.post ("ajax.php",
{"page" : "godmode/agentes/module_manager_editor",
"get_module_components" : 1,
"id_module_component_group" : this.value,
"id_module_component_type" : $("#hidden-id_module_component_type").attr ("value")
},
function (data, status) {
if (data == false) {
$("#component_loading").hide ();
$("span#no_component").show ();
return;
}
jQuery.each (data, function (i, val) {
option = $("<option></option>")
.attr ("value", val['id_nc'])
.append (val['name']);
$select.append (option);
});
$("#component_loading").hide ();
$select.show ();
$("#component").show ();
},
"json"
);
});
$("#network_component").change (function () {
if (this.value == 0)
return;
$("#component_loading").show ();
$(".error").hide ();
jQuery.post ("ajax.php",
{"page" : "godmode/agentes/module_manager_editor",
"get_module_component" : 1,
"id_module_component" : this.value
},
function (data, status) {
$("#text-name").attr ("value", html_entity_decode (data["name"]));
$("#textarea_description").attr ("value", html_entity_decode (data["description"]));
$("#id_module_type option[value="+data["type"]+"]").select (1);
$("#text-max").attr ("value", data["max"]);
$("#text-min").attr ("value", data["min"]);
$("#text-module_interval").attr ("value", data["module_interval"]);
$("#text-tcp_port").attr ("value", data["tcp_port"]);
$("#textarea_tcp_send").attr ("value", html_entity_decode (data["tcp_send"]));
$("#textarea_tcp_rcv").attr ("value", html_entity_decode (data["tcp_rcv"]));
$("#text-snmp_community").attr ("value", html_entity_decode (data["snmp_community"]));
$("#text-snmp_oid").attr ("value", html_entity_decode (data["snmp_oid"])).show ();
$("#oid, img#edit_oid").hide ();
$("#id_module_group option["+data["id_group"]+"]").select (1);
$("#max_timeout").attr ("value", data["max_timeout"]);
if (data["history_data"])
$("#checkbox-history_data").check ();
else
$("#checkbox-history_data").uncheck ();
$("#text-min_warning").attr ("value", (data["min_warning"] == 0) ? 0 : data["min_warning"]);
$("#text-max_warning").attr ("value", (data["max_warning"] == 0) ? 0 : data["min_warning"]);
$("#text-min_critical").attr ("value", (data["min_critical"] == 0) ? 0 : data["min_critical"]);
$("#text-max_critical").attr ("value", (data["max_critical"] == 0) ? 0 : data["max_critical"]);
$("#text-ff_threshold").attr ("value", (data["min_ff_event"] == 0) ? 0 : data["min_ff_event"]);
$("#component_loading").hide ();
$("#id_module_type").change ();
},
"json"
);
});
$("#text-ip_target").keyup (function () {
if (this.value != '') {
$("#button-snmp_walk").enable ();
} else {
$("#button-snmp_walk").disable ();
}
});
$("#button-snmp_walk").click (function () {
$(this).disable ();
$("#oid_loading").show ();
$("span.error").hide ();
$("#select_snmp_oid").empty ().hide ();
$("#text-snmp_oid").hide ().attr ("value", "");
$("span#oid").show ();
jQuery.post ("ajax.php",
{"page" : "godmode/agentes/module_manager_editor",
"snmp_walk" : 1,
"ip_target" : $("#text-ip_target").fieldValue (),
"snmp_community" : $("#text-snmp_community").fieldValue ()
},
function (data, status) {
if (data == false) {
$("span#no_snmp").show ();
$("#oid_loading").hide ();
$("#edit_oid").hide ();
return false;
}
jQuery.each (data, function (id, value) {
opt = $("<option></option>").attr ("value", id).html (value);
$("#select_snmp_oid").append (opt);
});
$("#select_snmp_oid").show ();
$("#oid_loading").hide ();
$("#button-snmp_walk").enable ();
$("#edit_oid").show ();
$("#button-snmp_walk").enable ();
},
"json"
);
});
$("img#edit_oid").click (function () {
$("#oid").hide ();
$("#text-snmp_oid").show ()
.attr ("value", $("#select_snmp_oid").fieldValue ());
$(this).hide ();
});
$("form#module_form").submit (function () {
if ($("#text-name").attr ("value") == "") {
$("#text-name").pulsate ().focus ();
$("#message").showMessage ("<?php echo __('No module name provided') ?>");
return false;
}
module = $("#id_module_type").attr ("value");
if (icmp.in_array (module) || tcp.in_array (module) || snmp.in_array (module)) {
/* Network module */
if ($("#text-ip_target").attr ("value") == "") {
$("#text-ip_target").pulsate ().focus ();
$("#message").showMessage ("<?php echo __('No target IP provided') ?>");
return false;
}
}
if (snmp.in_array (module)) {
if ($("#text-snmp_oid").attr ("value") == "") {
if ($("#select_snmp_oid").attr ("value") == "") {
$("#message").showMessage ("<?php echo __('No SNMP OID provided') ?>");
return false;
}
}
}
$("#message").hide ();
return true;
});
$("a#show_advanced").click (function () {
$("div#advanced").show ();
$(this).remove ();
return false;
});
configure_modules_form ();
});
/* ]]> */
</script>

View File

@ -16,10 +16,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
if (! isset ($id_agente)) {
die ("Not Authorized");
}
function prepend_table_simple ($row, $id = false) {
global $table_simple;

View File

@ -16,11 +16,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// General startup for established session
if (!isset ($id_agente)) {
die ("Not Authorized");
}
$extra_title = __('Data server module');
/* No extra fields at this moment */

View File

@ -17,12 +17,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// General startup for established session
if (!isset ($id_agente)) {
die ("Not Authorized");
}
$extra_title = __('Network server module');
define ('ID_NETWORK_COMPONENT_TYPE', 2);

View File

@ -17,12 +17,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// General startup for established session
if (!isset ($id_agente)) {
die ("Not Authorized");
}
$extra_title = __('Plugin server module');
define ('ID_NETWORK_COMPONENT_TYPE', 4);

View File

@ -16,11 +16,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// General startup for established session
if (!isset ($id_agente)) {
die ("Not Authorized");
}
$extra_title = __('Prediction server module');
$data = array ();

View File

@ -16,11 +16,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// General startup for established session
if (!isset ($id_agente)) {
die ("Not Authorized");
}
$extra_title = __('WMI server module');
define ('ID_NETWORK_COMPONENT_TYPE', 6);

View File

@ -52,6 +52,7 @@ if (give_acl ($config['id_user'], 0, "AW")) {
$menu["gagente"]["sub"] = $sub;
}
if (give_acl ($config['id_user'], 0, "PM")) {
$menu["gmodules"]["text"] = __('Manage modules');
$menu["gmodules"]["sec2"] = "godmode/modules/module_list";
@ -88,6 +89,8 @@ if (give_acl ($config['id_user'], 0, "LM")) {
$menu["galertas"]["sub"] = $sub;
}
enterprise_hook ('policies_menu');
if (give_acl ($config['id_user'], 0, "UM")) {
$menu["gusuarios"]["text"] = __('Manage users');
$menu["gusuarios"]["sec2"] = "godmode/users/user_list";

View File

@ -37,9 +37,9 @@ if (is_ajax ()) {
$id_report_type = (string) get_parameter ('id_report_type');
echo get_report_type_data_source ($id_report_type);
exit ();
return;
}
exit ();
return;
}
$edit_report = (bool) get_parameter ('edit_report');
@ -51,7 +51,7 @@ $report_name = (string) get_parameter ('report_name');
$report_description = (string) get_parameter ('report_description');
$report_private = (bool) get_parameter ('report_private', 0);
$id_report = (int) get_parameter ('id_report');
$report_id_group = (int) get_parameter ('report_id_group');
$report_id_group = (int) get_parameter ('report_id_group', get_user_first_group ());
$id_agent = (int) get_parameter ('id_agent');
$id_group = (int) get_parameter ('id_group');
$add_content = (bool) get_parameter ('add_content');
@ -117,7 +117,7 @@ if ($add_content) {
echo '<h3 class="suc">'.__('Reporting successfully created').'</h3>';
$id_agent = 0;
$id_agent_module = 0;
$report_id_group = 0;
$report_id_group = 1;
$period = 0;
$type = 0;
$id_custom_graph = 0;
@ -289,7 +289,7 @@ if ($edit_sla_report_content) {
} elseif ($edit_report || $id_report) {
/* Edit and creation report form */
$id_agent = get_parameter_post ("id_agent",0);
$id_agent = (int) get_parameter ("id_agent");
echo "<h2>".__('Reporting')." &raquo; ";
echo __('Custom reporting builder');
@ -308,15 +308,12 @@ if ($edit_sla_report_content) {
$table->data[1][0] = __('Group');
$group_select = get_user_groups ($config['id_user']);
$table->data[1][1] = print_select ($group_select, 'report_id_group', $report_id_group, '', '', '', true);
$table->data[1][1] .= ' <span id="icon_preview">';
if ($report_id_group) {
$table->data[1][1] .= '<img src="images/groups_small/'.get_group_icon ($report_id_group).'.png" />';
}
$table->data[1][1] .= ' <span id="group_preview">';
$table->data[1][1] .= print_group_icon ($report_id_group, true);
$table->data[1][1] .= '</span>';
$table->data[2][0] = __('Private');
$table->data[2][1] = print_checkbox ('report_private', 1, $report_private, true);
$table->data[3][0] = __('Description');
@ -545,9 +542,11 @@ if ($edit_sla_report_content) {
echo "</div>";
echo "</form>";
}
require_jquery_file ('pandora.controls');
?>
<script language="javascript" type="text/javascript">
/* <![CDATA[ */
function refresh_table () {
$('#table-add-item > tbody > tr:odd td').removeClass('datos2').addClass('datos');
$('#table-add-item > tbody > tr:even td').removeClass('datos').addClass('datos2');
@ -625,34 +624,10 @@ function report_type_changed () {
});
}
function group_changed () {
var inputs = [];
inputs.push ("get_group_json=1");
inputs.push ("id_group=" + this.value);
inputs.push ("page=godmode/groups/group_list");
jQuery.ajax ({
data: inputs.join ("&"),
type: 'GET',
url: action="ajax.php",
timeout: 10000,
dataType: 'json',
success: function (data) {
var data_ = data;
$('#icon_preview').fadeOut ('normal', function () {
$('#icon_preview').empty ();
if (data_ != null) {
$('#icon_preview').append ($('<img />').attr ('src', 'images/groups_small/'+data['icon']+'.png'));
}
$('#icon_preview').fadeIn ();
});
}
});
}
$(document).ready (function () {
$('#id_agent').change (agent_changed);
$('#type').change (report_type_changed);
$('#report_id_group').change (group_changed);
});
$('#report_id_group').pandoraSelectGroup ();
});
/* ]]> */
</script>

View File

@ -62,89 +62,72 @@ $table->cellspacing=4;
$table->cellpadding=4;
$table->class="databox_color";
// Different Form url if it's a create or if it's a update form
echo '<form name="modulo" method="POST" action="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&'.(($id_rt != -1) ? 'update='.$id_rt : 'create=1').'">';
// Name
$table->data[] = array (__('Task name'),print_input_text ('name',$name,'',25,0,true));
$table->data[0][0] = __('Task name');
$table->data[0][1] = print_input_text ('name', $name, '', 25, 0, true);
// Recon server
$sql = "SELECT id_server, name FROM tserver WHERE server_type = 3 ORDER BY name";
$result = get_db_all_rows_sql ($sql);
foreach ($result as $row) {
$selectbox[$row["id_server"]] = $row["name"];
}
$table->data[] = array (__('Recon Server').'<a href="#" class="tip">&nbsp;<span>'.__('You must select a Recon Server for the Task, otherwise the Recon Task will never run').'</span></a>',
print_select ($selectbox, "id_recon_server", $id_recon_server,'','','',true));
unset ($selectbox);
$table->data[1][0] = __('Recon Server').'<a href="#" class="tip">&nbsp;<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);
// Network
$table->data[] = array (__('Network'),print_input_text ('network',$network,'',25,0,true));
$table->data[2][0] = __('Network');
$table->data[2][1] = print_input_text ('network', $network, '', 25, 0, true);
// Interval
$selectbox = array (
3600 => '1 '.__('hour'),
7200 => '2 '.__('hours'),
21600 => '6 '.__('hours'),
43200 => '12 '.__('hours'),
86400 => '1 '.__('day'),
432000 => '5 '.__('days'),
604800 => '1 '.__('week'),
1209600 => '2 '.__('weeks'),
2592000 => '1 '.__('month')
);
$values = array ();
$values[3600] = __('%d hour', 1);
$values[7200] = __('%d hours', 2);
$values[21600] = __('%d hours', 12);
$values[43200] = __('%d day', 1);
$values[86400] = __('%d day', 1);
$values[432000] = __('%d days', 5);
$values[604800] = __('%d week', 1);
$values[1209600] = __('%d weeks', 2);
$values[2592000] = __('%d month', 1);
$table->data[] = array (__('Interval'),print_select ($selectbox, "interval", $interval,'','','',true));
unset ($selectbox);
$table->data[3][0] = __('Interval');
$table->data[3][1] = print_select ($values, "interval", $interval, '', '', '', true);
// Network profile
$sql = sprintf("SELECT id_np, name FROM tnetwork_profile");
$result = get_db_all_rows_sql ($sql);
foreach($result as $row) {
$selectbox[$row["id_np"]] = $row["name"];
}
$table->data[] = array (__('Network profile'),print_select ($selectbox, "id_network_profile", $id_network_profile,'','','',true));
unset ($selectbox);
$table->data[4][0] = __('Network profile');
$table->data[4][1] = print_select_from_sql ('SELECT id_np, name FROM tnetwork_profile',
"id_network_profile", $id_network_profile, '', '', '', true);
// OS
$sql = "SELECT id_os, name FROM tconfig_os ORDER BY name";
$result = get_db_all_rows_sql ($sql);
$selectbox[-1] = __('Any');
foreach ($result as $row) {
$selectbox[$row["id_os"]] = $row["name"];
}
$table->data[] = array (__('OS'),print_select ($selectbox, "id_os", $id_os,'','','',true));
unset ($selectbox);
$table->data[5][0] = __('OS');
$table->data[5][1] = print_select_from_sql ('SELECT id_os, name FROM tconfig_os ORDER BY name',
"id_os", $id_os, '', '', '', true);
// Group
$sql = "SELECT id_grupo, nombre FROM tgrupo WHERE id_grupo > 1";
$result = get_db_all_rows_sql ($sql);
foreach ($result as $row) {
$selectbox[$row["id_grupo"]] = $row["nombre"];
}
$table->data[] = array (__('Group'),print_select ($selectbox, "id_group", $id_group,'','','',true));
unset ($selectbox);
$table->data[6][0] = __('Group');
$table->data[6][1] = print_select (get_user_groups (), "id_group",
$id_group, '', '', '', true);
// Incident
$selectbox = array ( 0 => __('No'), 1 => __('Yes') );
$table->data[] = array (__('Incident'),print_select ($selectbox, "create_incident", $create_incident,'','','',true));
$values = array (0 => __('No'), 1 => __('Yes'));
$table->data[7][0] = __('Incident');
$table->data[7][1] = print_select ($values, "create_incident", $create_incident,
'','','',true);
// Comments
$table->data[] = array (__('Comments'),print_textarea ("description", 2, 70, $description,'',true));
print_table ($table);
unset ($table);
$table->data[8][0] = __('Comments');
$table->data[8][1] = print_textarea ("description", 2, 70, $description, '', true);
echo '<div class="action-buttons" style="width: 700px">';
if ($id_rt != "-1")
echo print_submit_button (__('Update'),"crt",false,'class="sub upd"',true);
print_table ($table);
// Different Form url if it's a create or if it's a update form
echo '<form name="modulo" method="post" action="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&'.(($id_rt != -1) ? 'update='.$id_rt : 'create=1').'">';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id_rt != -1)
print_submit_button (__('Update'), "crt", false, 'class="sub upd"');
else
echo print_submit_button (__('Add'),"crt",false,'class="sub wand"',true);
print_submit_button (__('Add'), "crt", false, 'class="sub wand"');
echo '</form>';
echo "</div>";
echo "</form>";
?>

View File

@ -78,7 +78,7 @@ if (isset($_GET["server"])) {
$servers = get_server_info ();
echo "<h2>".__('Pandora servers')." &raquo; ".__('Manage servers')."</h2>";
if ($result !== false) {
if ($servers !== false) {
$table->width = "90%";
$table->class = "databox";
$table->data = array ();

View File

@ -60,79 +60,64 @@ $table->data[0][0] = __('Language code for Pandora');
$table->data[0][1] = print_select_from_sql ('SELECT id_language, name FROM tlanguage',
'language', $config["language"], '', '', '', true);
$table->data[1][0] = __('Date format string') . print_help_icon("date_format", true);
$table->data[1][1] = '<em>'.__('Example').'</em> '.date ($config["date_format"]);
$table->data[1][1] .= print_input_text ('date_format', $config["date_format"], '', 30, 100, true);
$table->data[1][0] = __('Remote config directory');
$table->data[1][1] = print_input_text ('remote_config', $config["remote_config"], '', 30, 100, true);
$table->data[2][0] = __('Remote config directory');
$table->data[2][1] = print_input_text ('remote_config', $config["remote_config"], '', 30, 100, true);
$table->data[2][0] = __('SLA period (seconds)');
$table->data[2][1] = print_input_text ('sla_period', $config["sla_period"], '', 8, 8, true);
$table->data[6][0] = __('SLA period (seconds)');
$table->data[6][1] = print_input_text ('sla_period', $config["sla_period"], '', 8, 8, true);
$table->data[3][0] = __('Max. days before compact data');
$table->data[3][1] = print_input_text ('days_compact', $config["days_compact"], '', 5, 5, true);
$table->data[7][0] = __('Max. days before compact data');
$table->data[7][1] = print_input_text ('days_compact', $config["days_compact"], '', 5, 5, true);
$table->data[4][0] = __('Max. days before purge');
$table->data[4][1] = print_input_text ('days_purge', $config["days_purge"], '', 5, 5, true);
$table->data[8][0] = __('Max. days before purge');
$table->data[8][1] = print_input_text ('days_purge', $config["days_purge"], '', 5, 5, true);
$table->data[5][0] = __('Compact interpolation in hours (1 Fine-20 bad)');
$table->data[5][1] = print_input_text ('step_compact', $config["step_compact"], '', 5, 5, true);
$table->data[10][0] = __('Compact interpolation in hours (1 Fine-20 bad)');
$table->data[10][1] = print_input_text ('step_compact', $config["step_compact"], '', 5, 5, true);
$table->data[6][0] = __('Auto login (Hash) password');
$table->data[6][1] = print_input_text ('loginhash_pwd', $config["loginhash_pwd"], '', 15, 15, true);
$table->data[11][0] = __('Auto login (Hash) password');
$table->data[11][1] = print_input_text ('loginhash_pwd', $config["loginhash_pwd"], '', 15, 15, true);
$table->data[7][0] = __('Default hours for event view');
$table->data[7][1] = print_input_text ('event_view_hr', $config["event_view_hr"], '', 5, 5, true);
$table->data[15][0] = __('Default hours for event view');
$table->data[15][1] = print_input_text ('event_view_hr', $config["event_view_hr"], '', 5, 5, true);
$table->data[8][0] = __('Timestamp or time comparation') . print_help_icon ("time_stamp-comparation", true);
$table->data[8][1] = __('Comparation in rollover').' ';
$table->data[8][1] .= print_radio_button ('prominent_time', "timestamp", '', $config["prominent_time"], true);
$table->data[8][1] .= '<br />'.__('Timestamp in rollover').' ';
$table->data[8][1] .= print_radio_button ('prominent_time', "comparation", '', $config["prominent_time"], true);
$table->data[16][0] = __('Timestamp or time comparation') . print_help_icon ("time_stamp-comparation", true);
$table->data[16][1] = __('Comparation in rollover').' ';
$table->data[16][1] .= print_radio_button ('prominent_time', "timestamp", '', $config["prominent_time"], true);
$table->data[16][1] .= '<br />'.__('Timestamp in rollover').' ';
$table->data[16][1] .= print_radio_button ('prominent_time', "comparation", '', $config["prominent_time"], true);
$table->data[17][0] = __('Time source') . print_help_icon ("timesource", true);
$table->data[9][0] = __('Time source') . print_help_icon ("timesource", true);
$sources["system"] = __('System');
$sources["sql"] = __('Database');
$table->data[17][1] = print_select ($sources, 'timesource', $config["timesource"], '', '', '', true);
$table->data[9][1] = print_select ($sources, 'timesource', $config["timesource"], '', '', '', true);
$table->data[18][0] = __('Automatic update check');
$table->data[18][1] = __('Yes').'&nbsp;'.print_radio_button ('autoupdate', 1, '', $config["autoupdate"], true).'&nbsp;&nbsp;';
$table->data[18][1] .= __('No').'&nbsp;'.print_radio_button ('autoupdate', 0, '', $config["autoupdate"], true);
$table->data[10][0] = __('Automatic update check');
$table->data[10][1] = __('Yes').'&nbsp;'.print_radio_button ('autoupdate', 1, '', $config["autoupdate"], true).'&nbsp;&nbsp;';
$table->data[10][1] .= __('No').'&nbsp;'.print_radio_button ('autoupdate', 0, '', $config["autoupdate"], true);
$table->data[19][0] = __('Enforce https');
$table->data[19][1] = __('Yes').'&nbsp;'.print_radio_button ('https', 1, '', $config["https"], true).'&nbsp;&nbsp;';
$table->data[19][1] .= __('No').'&nbsp;'.print_radio_button ('https', 0, '', $config["https"], true);
$table->data[11][0] = __('Enforce https');
$table->data[11][1] = __('Yes').'&nbsp;'.print_radio_button ('https', 1, '', $config["https"], true).'&nbsp;&nbsp;';
$table->data[11][1] .= __('No').'&nbsp;'.print_radio_button ('https', 0, '', $config["https"], true);
$table->data[20][0] = __('Compact CSS and JS into header');
$table->data[20][1] = __('Yes').'&nbsp;'.print_radio_button ('compact_header', 1, '', $config["compact_header"], true).'&nbsp;&nbsp;';
$table->data[20][1] .= __('No').'&nbsp;'.print_radio_button ('compact_header', 0, '', $config["compact_header"], true);
$table->data[12][0] = __('Compact CSS and JS into header');
$table->data[12][1] = __('Yes').'&nbsp;'.print_radio_button ('compact_header', 1, '', $config["compact_header"], true).'&nbsp;&nbsp;';
$table->data[12][1] .= __('No').'&nbsp;'.print_radio_button ('compact_header', 0, '', $config["compact_header"], true);
$table->data[25][0] = __('Font path');
$table->data[25][1] = print_input_text ('fontpath', $config["fontpath"], '', 50, 255, true);
$table->data[13][0] = __('Font path');
$table->data[13][1] = print_input_text ('fontpath', $config["fontpath"], '', 50, 255, true);
$table->data[26][0] = __('Attachment store');
$table->data[26][1] = print_input_text ('attachment_store', $config["attachment_store"], '', 50, 255, true);
$table->data[14][0] = __('Attachment store');
$table->data[14][1] = print_input_text ('attachment_store', $config["attachment_store"], '', 50, 255, true);
enterprise_hook ('setup');
enterprise_hook ('load_snmpforward_enterprise');
echo '<form id="form_setup" method="POST" action="index.php?sec=gsetup&amp;sec2=godmode/setup/setup">';
echo '<form id="form_setup" method="post">';
print_input_hidden ('update_config', 1);
print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
print_submit_button (__('Update'), 'update_button', false, 'class="sub upd"');
echo '</div>';
echo '</form>';
require_css_file ("color-picker");
require_jquery_file ("colorpicker");
?>
<script language="javascript" type="text/javascript">
$(document).ready (function () {
$("#form_setup #text-graph_color1").attachColorPicker();
$("#form_setup #text-graph_color2").attachColorPicker();
$("#form_setup #text-graph_color3").attachColorPicker();
});
</script>

View File

@ -73,15 +73,13 @@ $table->data[8][0] = __('Use round corners');
$table->data[8][1] = __('Yes').'&nbsp;'.print_radio_button ('round_corner', 1, '', $config["round_corner"], true).'&nbsp;&nbsp;';
$table->data[8][1] .= __('No').'&nbsp;'.print_radio_button ('round_corner', 0, '', $config["round_corner"], true);
$table->data[9][0] = __('Status Icon set');
$iconsets["default"] = __('Colors (Default)');
$table->data[9][0] = __('Status icon set');
$iconsets["default"] = __('Colors');
$iconsets["faces"] = __('Faces');
$iconsets["color_text"] = __('Color and text');
$iconsets["color_text"] = __('Colors and text');
$table->data[9][1] = print_select ($iconsets, 'status_images_set', $config["status_images_set"], '', '', '', true);
echo '<form id="form_setup" method="POST" action="index.php?sec=gsetup&amp;sec2=godmode/setup/setup_visuals">';
echo '<form id="form_setup" method="post">';
print_input_hidden ('update_config', 1);
print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

View File

@ -107,6 +107,40 @@ function get_agent_alerts_compound ($id_agent, $filter = '', $options = false) {
return $alerts;
}
/**
* Get a list of agents.
*
* By default, it will return all the agents where the user has reading access.
*
* @param array ilter options in an indexed array. See
* format_array_to_where_clause_sql()
* @param array Fields to get.
* @param string Access needed in the agents groups.
*
* @return array An array with all alerts defined for an agent.
*/
function get_agents ($filter = false, $fields = false, $access = 'AR') {
if (! is_array ($filter))
$filter = array ();
if (! isset ($filter['id_grupo']))
$filter['id_grupo'] = array_keys (get_user_groups (false, $access));
else
if (! is_array ($filter['id_grupo'])) {
if (! in_array ($filter['id_grupo'], array_keys (get_user_groups (false, $access))))
return false;
} else {
$user_groups = get_user_groups (false, $access);
foreach ($filter['id_grupo'] as $i => $id_group)
if (! isset ($user_groups[$id_group]))
unset ($filter['id_grupo'][$id]);
if (count ($filter['id_grupo']) == 0)
$filter['id_grupo'] = $user_groups;
}
return @get_db_all_rows_filter ('tagente', $filter, $fields);
}
/**
* Get all the alerts of an agent, simple and combined.
*

View File

@ -1235,6 +1235,20 @@ function get_user_groups ($id_user = false, $privilege = "AR") {
return $user_groups;
}
/**
* Get the first group of an user.
*
* Useful function when you need a default group for a user.
*
* @param string User id
* @param string The privilege to evaluate
*
* @return array The first group where the user has certain privileges.
*/
function get_user_first_group ($id_user = false, $privilege = "AR") {
return array_shift (array_keys (get_user_groups ($id_user, $privilege)));
}
/**
* Get module type icon.
*
@ -2356,7 +2370,7 @@ echo __('Hello, %s!', $user);
*
* @return string The translated string. If not defined, the same string will be returned
*/
function __ ($string) {
function __ ($string /*, variable arguments */) {
global $l10n;
if (func_num_args () == 1) {
@ -3142,14 +3156,22 @@ function print_database_debug () {
/**
* Return access to a specific agent by a specific user
*
* @param string $id_user User id.
* @param int $id_agent Agent id.
* @param int Agent id.
* @param string Access mode to be checked. Default AR (Agent reading)
* @param string User id. Current user by default
*
* @return int Access to that agent (0 not, 1 yes)
* @return bool Access to that agent (false not, true yes)
*/
function user_access_to_agent ($id_user, $id_agent, $mode = "AR"){
function user_access_to_agent ($id_agent, $mode = "AR", $id_user = false) {
if (empty ($id_agent))
return false;
if ($id_user == false) {
global $config;
$id_user = $config['id_user'];
}
$id_group = (int) get_db_value ('id_grupo', 'tagente', 'id_agente', (int) $id_agent);
return give_acl ($id_user, $id_group, $mode);
return (bool) give_acl ($id_user, $id_group, $mode);
}
?>

View File

@ -756,9 +756,9 @@ function get_agent_module_info ($id_agent) {
$return["monitor_down"] = 0; //Number of 'down' monitors
$return["last_contact"] = 0; //Last agent contact
$return["interval"] = get_agent_interval ($id_agent); //How often the agent gets contacted
$return["status_img"] = print_status_image(STATUS_AGENT_NO_DATA, __('Agent without data'), true);
$return["status_img"] = print_status_image (STATUS_AGENT_NO_DATA, __('Agent without data'), true);
$return["alert_status"] = "notfired";
$return["alert_img"] = print_status_image(STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true);
$return["alert_img"] = print_status_image (STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true);
$return["agent_group"] = get_agent_group ($id_agent);
if (!give_acl ($config["id_user"], $return["agent_group"], "AR")) {
@ -766,8 +766,8 @@ function get_agent_module_info ($id_agent) {
}
$sql = sprintf ("SELECT * FROM tagente_estado, tagente_modulo
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND
tagente_modulo.disabled = 0 AND tagente_modulo.id_agente = %d", $id_agent);
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND
tagente_modulo.disabled = 0 AND tagente_modulo.id_agente = %d", $id_agent);
$modules = get_db_all_rows_sql ($sql);

View File

@ -1064,12 +1064,103 @@ define ('STATUS_ALERT_DISABLED', 'alert_disabled.png');
define ('STATUS_SERVER_OK', 'server_ok.png');
define ('STATUS_SERVER_DOWN', 'server_down.png');
/**
* Prints an image representing a status.
*
* @param string
* @param string
* @param bool Whether to return an output string or echo now (optional, echo by default).
*
* @return string HTML code if return parameter is true.
*/
function print_status_image ($type, $title = "", $return = false) {
list ($imagepath) = get_status_images_path ();
$imagepath .= "/" . $type;
$imagepath .= "/".$type;
return print_image ($imagepath, $return, array ("title" => $title));
}
/**
* Prints a form to search agents.
*
* @param array Extra options for the function. To be documented.
* @param array Extra and hidden filter for the agent search.
*/
function print_ui_agents_list ($options = false, $filter = false, $return = false) {
global $config;
$output = '';
$group_filter = true;
$text_filter = true;
$access = 'AR';
$table_heads = array (__('Name'), __('Group'), __('Status'));
$table_renders = array ('view_link', 'group', 'status');
$table_align = array ('', '', 'center');
$table_size = array ('50%', '45%', '5%');
$fields = false;
$show_filter_form = true;
if (is_array ($options)) {
if (isset ($options['group_filter']))
$group_filter = (bool) $options['group_filter'];
if (isset ($options['text_filter']))
$text_filter = (bool) $options['text_filter'];
if (isset ($options['access']))
$access = (string) $options['access'];
if (isset ($options['table_heads']))
$table_heads = (array) $options['table_heads'];
if (isset ($options['table_renders']))
$table_renders = (array) $options['table_renders'];
if (isset ($options['table_align']))
$table_align = (array) $options['table_align'];
if (isset ($options['table_size']))
$table_size = (array) $options['table_size'];
if (isset ($options['fields']))
$fields = (array) $options['fields'];
if (isset ($options['show_filter_form']))
$show_filter_form = (bool) $options['show_filter_form'];
if (count ($table_renders) != count ($table_heads))
trigger_error ('Different count for table_renders and table_heads options');
unset ($options);
}
if ($return)
return get_include_contents ($config['homedir'].'/general/ui/agents_list.php',
get_defined_vars ());
include ($config['homedir'].'/general/ui/agents_list.php');
}
/**
* Get the content of a PHP file instead of dumping to the output.
*
* Picked from PHP official doc.
*
* @param string File name to include and get content.
* @param array Extra parameters in an indexed array to be passed to the file.
*
* @return string Content of the file after being processed. False if the file
* could not be included.
*/
function get_include_contents ($filename, $params = false) {
ob_start ();
if (is_array ($params)) {
extract ($params);
}
$result = include ($filename);
if ($result === false) {
ob_end_clean ();
return false;
}
$contents = ob_get_contents ();
ob_end_clean ();
return $contents;
}
?>

View File

@ -0,0 +1,117 @@
<?php
// Pandora FMS - the Flexible Monitoring System
// ============================================
// Copyright (c) 2009 Artica Soluciones Tecnologicas, http://www.artica.es
// Please see http://pandora.sourceforge.net for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License (LGPL)
// as published by the Free Software Foundation for version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
/**
*/
function render_agent_field ($agent, $field, $field_value = false, $return = false) {
global $config;
if (empty ($agent))
return '';
$output = '';
switch ($field) {
case 'group_name':
if (! isset ($agent['id_grupo']))
return '';
$output = get_group_name ($agent['id_grupo'], true);
break;
case 'group_icon':
if (! isset ($agent['id_grupo']))
return '';
$output = print_group_icon ($agent['id_grupo'], true);
break;
case 'group':
if (! isset ($agent['id_grupo']))
return '';
$output = print_group_icon ($agent['id_grupo'], true);
$output .= ' ';
$output .= get_group_name ($agent['id_grupo']);
break;
case 'view_link':
if (! isset ($agent['nombre']))
return '';
if (! isset ($agent['id_agente']))
return '';
$output = '<a class="agent_link" id="agent-'.$agent['id_agente'].'" href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'">';
$output .= $agent['nombre'];
$output .= '</a>';
break;
case 'name':
if (! isset ($agent['nombre']))
return '';
$output = $agent['nombre'];
break;
case 'status':
if (! isset ($agent['id_agente']))
return print_status_image (STATUS_AGENT_NO_DATA, '', $return);
require_once ('include/functions_reporting.php');
$info = get_agent_module_info ($agent['id_agente']);
$output = $info['status_img'];
break;
case 'ajax_link':
if (! $field_value || ! is_array ($field_value))
return '';
if (! isset ($field_value['callback']))
return '';
if (! isset ($agent['id_agente']))
return '';
$parameters = $agent['id_agente'];
if (isset ($field_value['parameters']))
$parameters = implode (',', $field_value['parameters']);
$text = __('Action');
if (isset ($field_value['name']))
$text = $field_value['name'];
if (isset ($field_value['image']))
$text = print_image ($field_value['image'], true, array ('title' => $text));
$output = '<a href="#" onclick="'.$field_value['callback'].'(this, '.$parameters.'); return false"">';
$output .= $text;
$output .= '</a>';
break;
default:
if (! isset ($agent[$field]))
return '';
$ouput = $agent[$field];
}
if ($return)
return $output;
echo $output;
}
?>

View File

@ -168,7 +168,7 @@
$.extend ({
pandoraSelectOS: new function() {
this.defaults = {
alertSelect: "select#id_od",
alertSelect: "select#id_os",
spanPreview: "#os_preview",
debug: false
};
@ -206,10 +206,53 @@
}
});
$.extend ({
pandoraSelectGroup: new function() {
this.defaults = {
alertSelect: "select#id_group",
spanPreview: "#group_preview",
debug: false
};
/* public methods */
this.construct = function (settings) {
return this.each (function() {
this.config = {};
this.config = $.extend (this.config, $.pandoraSelectGroup.defaults, settings);
var config = this.config;
$(this).change (function () {
var id_group = this.value;
$(config.spanPreview).fadeOut ('fast', function () {
$("img", config.spanPreview).remove ();
jQuery.post ('ajax.php',
{"page": "godmode/groups/group_list",
"get_group_json": 1,
"id_group": id_group
},
function (data) {
img = $("<img />").attr ("src", "images/groups_small/"+data["icon"]+".png")
$(config.spanPreview)
.append (img)
.fadeIn ('fast');
},
"json"
);
});
});
});
};
}
});
$.fn.extend({
pandoraSelectGroup: $.pandoraSelectGroup.construct,
pandoraSelectAgentModule: $.pandoraSelectAgentModule.construct,
pandoraSelectAgentAlert: $.pandoraSelectAgentAlert.construct,
pandoraSelectOS: $.pandoraSelectOS.construct
pandoraSelectOS: $.pandoraSelectOS.construct,
pandoraSelectGroup: $.pandoraSelectGroup.construct
});
}) (jQuery);

View File

@ -1,4 +1,4 @@
$(document).ready (function () {
(function($) {
$.fn.check = function () {
return this.each (function () {
this.checked = true;
@ -29,7 +29,9 @@ $(document).ready (function () {
.text (msg)
.slideDown ();
};
}) (jQuery);
$(document).ready (function () {
$("a#show_messages_dialog").click (function () {
jQuery.get ("ajax.php",
{"page": "operation/messages/message"},

View File

@ -0,0 +1,176 @@
/* Modules ids to check types */
var id_modules_icmp = Array (6, 7);
var id_modules_tcp = Array (8, 9, 10, 11);
var id_modules_snmp = Array (15, 16, 17, 18);
function configure_modules_form () {
$("#id_module_type").change (function () {
if (id_modules_icmp.in_array (this.value)) {
$("tr#simple-snmp_1, tr#simple-snmp_2, tr#advanced-tcp_send, tr#advanced-tcp_receive").hide ();
$("#text-tcp_port").attr ("disabled", "1");
} else if (id_modules_snmp.in_array (this.value)) {
$("tr#simple-snmp_1, tr#simple-snmp_2").show ();
$("tr#advanced-tcp_send, tr#advanced-tcp_receive").hide ();
$("#text-tcp_port").removeAttr ("disabled");
} else if (id_modules_tcp.in_array (this.value)) {
$("tr#simple-snmp_1, tr#simple-snmp_2").hide ();
$("tr#advanced-tcp_send, tr#advanced-tcp_receive").show ();
$("#text-tcp_port").removeAttr ("disabled");
}
});
$("#network_component_group").change (function () {
var $select = $("#network_component").hide ();
$("#component").hide ();
if (this.value == 0)
return;
$("#component_loading").show ();
$(".error, #no_component").hide ();
$("option[value!=0]", $select).remove ();
jQuery.post ("ajax.php",
{"page" : "godmode/agentes/module_manager_editor",
"get_module_components" : 1,
"id_module_component_group" : this.value,
"id_module_component_type" : $("#hidden-id_module_component_type").attr ("value")
},
function (data, status) {
if (data == false) {
$("#component_loading").hide ();
$("span#no_component").show ();
return;
}
jQuery.each (data, function (i, val) {
option = $("<option></option>")
.attr ("value", val['id_nc'])
.append (val['name']);
$select.append (option);
});
$("#component_loading").hide ();
$select.show ();
$("#component").show ();
},
"json"
);
});
$("#network_component").change (function () {
if (this.value == 0)
return;
$("#component_loading").show ();
$(".error").hide ();
jQuery.post ("ajax.php",
{"page" : "godmode/agentes/module_manager_editor",
"get_module_component" : 1,
"id_module_component" : this.value
},
function (data, status) {
$("#text-name").attr ("value", html_entity_decode (data["name"]));
$("#textarea_description").attr ("value", html_entity_decode (data["description"]));
$("#id_module_type option[value="+data["type"]+"]").select (1);
$("#text-max").attr ("value", data["max"]);
$("#text-min").attr ("value", data["min"]);
$("#text-module_interval").attr ("value", data["module_interval"]);
$("#text-tcp_port").attr ("value", data["tcp_port"]);
$("#textarea_tcp_send").attr ("value", html_entity_decode (data["tcp_send"]));
$("#textarea_tcp_rcv").attr ("value", html_entity_decode (data["tcp_rcv"]));
$("#text-snmp_community").attr ("value", html_entity_decode (data["snmp_community"]));
$("#text-snmp_oid").attr ("value", html_entity_decode (data["snmp_oid"])).show ();
$("#oid, img#edit_oid").hide ();
$("#id_module_group option["+data["id_group"]+"]").select (1);
$("#max_timeout").attr ("value", data["max_timeout"]);
if (data["history_data"])
$("#checkbox-history_data").check ();
else
$("#checkbox-history_data").uncheck ();
$("#text-min_warning").attr ("value", (data["min_warning"] == 0) ? 0 : data["min_warning"]);
$("#text-max_warning").attr ("value", (data["max_warning"] == 0) ? 0 : data["min_warning"]);
$("#text-min_critical").attr ("value", (data["min_critical"] == 0) ? 0 : data["min_critical"]);
$("#text-max_critical").attr ("value", (data["max_critical"] == 0) ? 0 : data["max_critical"]);
$("#text-ff_threshold").attr ("value", (data["min_ff_event"] == 0) ? 0 : data["min_ff_event"]);
$("#component_loading").hide ();
$("#id_module_type").change ();
},
"json"
);
});
$("#text-ip_target").keyup (function () {
if (this.value != '') {
$("#button-snmp_walk").enable ();
} else {
$("#button-snmp_walk").disable ();
}
});
$("#button-snmp_walk").click (function () {
$(this).disable ();
$("#oid_loading").show ();
$("span.error").hide ();
$("#select_snmp_oid").empty ().hide ();
$("#text-snmp_oid").hide ().attr ("value", "");
$("span#oid").show ();
jQuery.post ("ajax.php",
{"page" : "godmode/agentes/module_manager_editor",
"snmp_walk" : 1,
"ip_target" : $("#text-ip_target").fieldValue (),
"snmp_community" : $("#text-snmp_community").fieldValue ()
},
function (data, status) {
if (data == false) {
$("span#no_snmp").show ();
$("#oid_loading").hide ();
$("#edit_oid").hide ();
return false;
}
jQuery.each (data, function (id, value) {
opt = $("<option></option>").attr ("value", id).html (value);
$("#select_snmp_oid").append (opt);
});
$("#select_snmp_oid").show ();
$("#oid_loading").hide ();
$("#button-snmp_walk").enable ();
$("#edit_oid").show ();
$("#button-snmp_walk").enable ();
},
"json"
);
});
$("img#edit_oid").click (function () {
$("#oid").hide ();
$("#text-snmp_oid").show ()
.attr ("value", $("#select_snmp_oid").fieldValue ());
$(this).hide ();
});
$("form#module_form").submit (function () {
if ($("#text-name").attr ("value") == "") {
$("#text-name").focus ();
$("#message").showMessage (no_name_lang);
return false;
}
module = $("#id_module_type").attr ("value");
if (id_modules_icmp.in_array (module) || id_modules_tcp.in_array (module) || id_modules_snmp.in_array (module)) {
/* Network module */
if ($("#text-ip_target").attr ("value") == "") {
$("#text-ip_target").focus ();
$("#message").showMessage (no_target_lang);
return false;
}
}
if (id_modules_snmp.in_array (module)) {
if ($("#text-snmp_oid").attr ("value") == "") {
if ($("#select_snmp_oid").attr ("value") == "") {
$("#message").showMessage (no_oid_lang);
return false;
}
}
}
$("#message").hide ();
return true;
});
}

View File

@ -110,7 +110,7 @@ pagination (count ($agents), "index.php?sec=estado&sec2=operation/agentes/estado
// Show data.
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "90%";
$table->width = "98%";
$table->class = "databox";
$table->head = array ();