2008-10-24 Esteban Sanchez <estebans@artica.es>

* operation/snmpconsole/snmp_alert.php: Fixed an error that doesn't
        allow to show some fields when editing an alert. It's done using
        javascript, but a PHP version might be better. Style correction.

        * include/functions_db.php: Added get_agent_with_ip().

        * operation/snmpconsole/snmp_view.php: Use get_agent_with_ip() since
        using get_db_row() is not enough for agents with many addresses.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1193 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2008-10-24 09:52:46 +00:00
parent f66deed9d2
commit 695c23b493
4 changed files with 42 additions and 8 deletions

View File

@ -1,3 +1,14 @@
2008-10-24 Esteban Sanchez <estebans@artica.es>
* operation/snmpconsole/snmp_alert.php: Fixed an error that doesn't
allow to show some fields when editing an alert. It's done using
javascript, but a PHP version might be better. Style correction.
* include/functions_db.php: Added get_agent_with_ip().
* operation/snmpconsole/snmp_view.php: Use get_agent_with_ip() since
using get_db_row() is not enough for agents with many addresses.
2008-10-23 Esteban Sanchez <estebans@artica.es>
* operation/agentes/estado_agente.php: Use print_select() to show the

View File

@ -1273,6 +1273,22 @@ function give_agent_address ($id_agent) {
return (string) get_db_value ('direccion', 'tagente', 'id_agente', $id_agent);
}
/**
* Get the agent that matches an IP address
*
* @param $ip_address IP address to get the agents.
*
* @return The agent that has the IP address given. False if none were found.
*/
function get_agent_with_ip ($ip_address) {
$sql = sprintf ('SELECT tagente.*
FROM tagente, taddress, taddress_agent
WHERE tagente.id_agente = taddress_agent.id_agent
AND taddress_agent.id_a = taddress.id_a
AND ip = "%s"', $ip_address);
return get_db_row_sql ($sql);
}
/**
* Get IP address of an agent from address list
*

View File

@ -133,8 +133,9 @@ if ((isset ($_GET["update_alert"])) && ($_GET["update_alert"] != -1)) {
}
// Alert form
if (isset ($_GET["update_alert"])) { //the update_alert means the form should be displayed. If update_alert > 1 then an existing alert is updated
if ($id_as > 1) {
if (isset ($_GET["update_alert"])) {
//the update_alert means the form should be displayed. If update_alert > 1 then an existing alert is updated
if ($id_as) {
echo "<h2>Pandora SNMP &gt; ".__('Update alert')."</h2>";
} else {
echo "<h2>Pandora SNMP &gt; ".__('Create alert')."</h2>";
@ -376,8 +377,7 @@ function time_changed () {
}
}
function trigger_changed () {
var trigger = this.value;
function trigger_changed (trigger) {
if (trigger == 0) {
$('#tr-custom_value').fadeOut ('fast');
$('#tr-source_ip').fadeOut ('fast');
@ -400,6 +400,13 @@ function trigger_changed () {
$(document).ready (function () {
$('#time_threshold').change (time_changed);
$('#alert_trigger').change (trigger_changed);
$('#alert_trigger').change (function () {
trigger_changed (this.value)
});
<?php
if ($id_as) {
echo 'trigger_changed ('.$alert_trigger.');';
}
?>
});
</script>

View File

@ -174,8 +174,8 @@ foreach ($traps as $trap) {
$data[0] = '<img src="images/pixel_green.png" title="'.__('Validated').'" width="20" height="20" />';
}
// Agent matching
$agent = get_db_row ('tagente', 'direccion', $trap['source']);
// Agent matching source address
$agent = get_agent_with_ip ($trap['source']);
if ($agent !== false && ! give_acl ($config["id_user"], $agent["id_grupo"], "AR")) {
//Agent found, no rights
continue;
@ -189,7 +189,7 @@ foreach ($traps as $trap) {
} else {
//Agent found
$data[1] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent["id_agente"].'" title="'.__('View agent details').'">';
$data[1] .= '<b>'.$agent["nombre"].'</b></a>';
$data[1] .= '<strong>'.$agent["nombre"].'</strong></a>';
}
//OID