pandorafms/pandora_console/godmode/agentes/agent_template.php

171 lines
5.6 KiB
PHP
Raw Normal View History

2007-04-18 Sancho Lerena <slerena@artica.es> * include/styles/pandora.css: Added frame and changed basic form input styles (fixed the old problem with radio and checkboxes). * include/functions_db.php: Finished function agent_add_address(). Added functions: agent_delete_address(), give_agent_address() and give_agent_address_from_list(). * include/languages/language_en.php: More strings ! * include/functions.php: Added numeric render for graph Y scale and for numeric data output in screen: format_for_graph(). * pandoradb.sql: Several small fixes and cleanup (deleted drop check). * operation/agentes/estado_alertas.php: Fixed old bug with visualization of alerts (min/max) vs (max/min). Now alert is a real value, not integer. * operation/agentes/datos_agente.php: Better render for numeric (float) data. * operation/agentes/estado_ultimopaquete.php: Better render for numeric (float) data and fixed a small costemic bug. * operation/agentes/estado_generalagente.php: Fixed a small costemic bug, list of ip's have some white space before and this have better visualization for user due to combo style stripping some space. * reporting/fgraph.php: Graph improvement: graphs now could show alerts associated to an agent and draw alert limits. Preprocessor function is now used to render axis label with (M,K) symbols and decimal commas. Title and subtitle has been improved. * reporting/stat_win.php: Graph menu improvement. Fully completed work. This should work for final version without more changes. * godmode/agentes/agent_template.php: Template/Wizard module assigment form for agent. * godmode/agentes/alert_manager.php: Several fixes (links) and alert max/min render. * godmode/agentes/configurar_agente.php: Fixed several navitation bugs. Added agent ip addition/deletion code. * godmode/agentes/agent_manager.php: Address list management code. * godmode/modules/module_list.php: Deleted link to "module type editor" and create button: This has no sense since there is no moduletype editor yet :-) git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@425 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2007-04-18 11:58:26 +02:00
<?PHP
// Pandora FMS - the Free monitoring system
// ========================================
// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com
// Main PHP/SQL code development and project architecture and management
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; 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.
// Load global vars
require("include/config.php");
// Access control
if (give_acl($id_user, 0, "AW")!=1) {
audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access agent manager");
require ("general/noaccess.php");
exit;
};
// ==========================
// TEMPLATE ASSIGMENT LOGIC
// ==========================
if (isset($_POST["template_id"])){
// Take agent data
$sql1='SELECT * FROM tagente WHERE id_agente = '.$id_agente;
$result=mysql_query($sql1);
if ($row=mysql_fetch_array($result)){
$intervalo = $row["intervalo"];
$nombre_agente = $row["nombre"];
$direccion_agente =$row["direccion"];
$ultima_act = $row["ultimo_contacto"];
$ultima_act_remota =$row["ultimo_contacto_remoto"];
$comentarios = $row["comentarios"];
$id_grupo = $row["id_grupo"];
$id_os= $row["id_os"];
$os_version = $row["os_version"];
$agent_version = $row["agent_version"];
$disabled= $row["disabled"];
$agent_type= $row["agent_type"];
$server = $row["id_server"];
}
$id_np = $_POST["template_id"];
$sql1 = "SELECT * FROM tnetwork_profile_component
WHERE id_np = $id_np";
$result=mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
$sql2 = "SELECT * FROM tnetwork_component
WHERE id_nc = ".$row["id_nc"];
$result2=mysql_query($sql2);
while ($row2=mysql_fetch_array($result2)){
// Insert each module from tnetwork_component into agent
$module_sql = "INSERT INTO tagente_modulo
(id_agente, id_tipo_modulo, descripcion, nombre, max, min, module_interval, tcp_port, tcp_send, tcp_rcv, snmp_community, snmp_oid, ip_target, id_module_group)
VALUES ( $id_agente,
'".$row2["type"]."',
'".$row2["description"]."',
'".$row2["name"]."',
'".$row2["max"]."',
'".$row2["min"]."',
'".$row2["module_interval"]."',
'".$row2["tcp_port"]."',
'".$row2["tcp_send"]."',
'".$row2["tcp_rcv"]."',
'".$row2["snmp_community"]."',
'".$row2["snmp_oid"]."',
'$direccion_agente',
'".$row2["id_module_group"]."'
)";
mysql_query ($module_sql);
}
}
echo "<div class='suc'>";
echo "Modules added successfully";
echo "</div>";
}
// Main header
echo "<h2>".$lang_label["agent_conf"]." &gt; ".$lang_label["network_templates"];
echo "</h2>";
// ==========================
// TEMPLATE ASSIGMENT FORM
// ==========================
echo "<h3>".$lang_label["available_templates"]."</h3>";
echo "<table width=300 border=0>";
echo "<tr><td><br>";
echo "<form method=post action='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=template&id_agente=$id_agente'>";
echo "<select name='template_id'>";
$sql1='SELECT * FROM tnetwork_profile ORDER BY name';
$result=mysql_query($sql1);
if (mysql_num_rows($result))
while ($row=mysql_fetch_array($result))
echo "<option value='".$row["id_np"]."'>".$row["name"];
echo "</select>";
echo "<td>";
echo "<input type='submit' class='sub next' name='crt' value='".$lang_label["assign"]."'>";
echo "</table>";
echo "</form>";
// ==========================
// MODULE VISUALIZATION TABLE
// ==========================
echo "<h3>".$lang_label["assigned_modules"]."</h3>";
$sql1='SELECT * FROM tagente_modulo WHERE id_agente = "'.$id_agente.'"
ORDER BY id_module_group, nombre ';
$result=mysql_query($sql1);
if ($row=mysql_num_rows($result)){
echo '<table width="700" cellpadding="3" cellspacing="3" class="fon">';
echo '<tr>';
echo "<th>".$lang_label["module_name"];
echo "<th>".$lang_label["type"];
echo "<th>".$lang_label["description"];
echo "<th width=50>".$lang_label["action"];
$color=1;$last_modulegroup = "0";
while ($row=mysql_fetch_array($result)){
if ($color == 1){
$tdcolor="datos";
$color =0;
} else {
$tdcolor="datos2";
$color =1;
}
$id_tipo = $row["id_tipo_modulo"];
$nombre_modulo =$row["nombre"];
$descripcion = $row["descripcion"];
echo "<tr><td class='".$tdcolor."_id'>".$nombre_modulo;
echo "<td class='".$tdcolor."f9'>";
if ($id_tipo > 0) {
echo "<img src='images/".show_icon_type($id_tipo)."' border=0>";
}
echo "<td class='$tdcolor' title='$descripcion'>".substr($descripcion,0,30)."</td>";
echo "<td class='$tdcolor'>";
if ($id_tipo != -1)
echo "<a href='index.php?sec=gagente&
tab=module&
sec2=godmode/agentes/configurar_agente&tab=template&
id_agente=".$id_agente."&
delete_module=".$row["id_agente_modulo"]."'>
<img src='images/cross.png' border=0 alt='".$lang_label["delete"]."'>
</b></a> &nbsp; ";
echo "<a href='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&
id_agente=".$id_agente."&
tab=module&
update_module=".$row["id_agente_modulo"]."#modules'>
<img src='images/config.gif' border=0 alt='".$lang_label["update"]."' onLoad='type_change()'></b></a>";
}
echo "<tr><td colspan='7'><div class='raya'></div></td></tr>";
echo "</table>";
} else
echo "<div class='nf'>No modules</div>";
?>