2006-03-27 05:37:27 +02:00
< ? php
2008-01-10 17:40:00 +01:00
// Pandora FMS - the Free Monitoring System
2007-03-12 18:58:52 +01:00
// ========================================
2008-04-01 15:53:11 +02:00
// Copyright (c) 2008 Artica Soluciones Tecnológicas, http://www.artica.es
2008-04-03 Jorge Gonzalez <jo[Brge.gonzalez@artica.es>
* include/functions_db.php: New functions added to handle plugins and
export servers.
* include/languages/language_en.php: Updated English translation file.
* general/header.php: Updated header.
* godmode/agentes/manage_config.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/module_manager_editor_wmi.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/agent_manager.php, godmode/modules/module_list.php:
Added infrastructure to add/edit modules.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@792 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-04-03 18:52:11 +02:00
// Copyright (c) 2008 Jorge Gonzalez <jorge.gonzalez@artica.es>
2008-01-10 17:40:00 +01:00
// Please see http://pandora.sourceforge.net for full contribution list
2006-03-27 05:37:27 +02:00
2008-04-01 15:53:11 +02:00
// 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 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.
2007-03-12 18:58:52 +01:00
// Load global vars
require ( " include/config.php " );
if ( give_acl ( $id_user , 0 , " AW " ) != 1 ) {
audit_db ( $id_user , $REMOTE_ADDR , " ACL Violation " ,
" Trying to access Agent Management " );
require ( " general/noaccess.php " );
exit ;
}
2008-01-10 17:40:00 +01:00
// Take some parameters (GET)
$offset = get_parameter ( " offset " , 0 );
$group_id = get_parameter ( " group_id " , 0 );
$ag_group = get_parameter ( " ag_group " , - 1 );
if (( $ag_group == - 1 ) && ( $group_id != 0 ))
$ag_group = $group_id ;
if ( isset ( $_GET [ " ag_group_refresh " ])){
$ag_group = $_GET [ " ag_group_refresh " ];
}
$search = get_parameter ( " search " , " " );
2007-09-27 17:12:49 +02:00
2007-03-12 18:58:52 +01:00
if ( isset ( $_GET [ " borrar_agente " ])){ // if delete agent
$id_agente = entrada_limpia ( $_GET [ " borrar_agente " ]);
$agent_name = dame_nombre_agente ( $id_agente );
$id_grupo = dame_id_grupo ( $id_agente );
if ( give_acl ( $id_user , $id_grupo , " AW " ) == 1 ){
// Firts delete from agents table
$sql_delete = " DELETE FROM tagente
WHERE id_agente = " . $id_agente ;
$result = mysql_query ( $sql_delete );
if ( ! $result )
echo " <h3 class='error'> " . $lang_label [ " delete_agent_no " ] . " </h3> " ;
else
echo " <h3 class='suc'> " . $lang_label [ " delete_agent_ok " ] . " </h3> " ;
// Delete agent access table
$sql_delete = " DELETE FROM tagent_access
WHERE id_agent = " . $id_agente ;
// Delete tagente_datos data
$result = mysql_query ( $sql_delete );
$sql_delete4 = " DELETE FROM tagente_datos
WHERE id_agente = " . $id_agente ;
$result = mysql_query ( $sql_delete4 );
// Delete tagente_datos_string data
$result = mysql_query ( $sql_delete );
$sql_delete4 = " DELETE FROM tagente_datos_string
WHERE id_agente = " . $id_agente ;
$result = mysql_query ( $sql_delete4 );
// Delete from tagente_datos
$sql1 = ' SELECT * FROM tagente_modulo
WHERE id_agente = ' . $id_agente ;
$result1 = mysql_query ( $sql1 );
while ( $row = mysql_fetch_array ( $result1 )){
$sql_delete4 = " DELETE FROM tagente_datos_inc
WHERE id_agente_modulo = " . $row["id_agente_modulo"] ;
$result = mysql_query ( $sql_delete4 );
}
$sql_delete2 = " DELETE FROM tagente_modulo
WHERE id_agente = " . $id_agente ;
$sql_delete3 = " DELETE FROM tagente_estado
WHERE id_agente = " . $id_agente ;
$result = mysql_query ( $sql_delete2 );
$result = mysql_query ( $sql_delete3 );
2007-03-19 20:39:40 +01:00
// Delete IPs from tadress table and taddress_agent
$sql = " SELECT * FROM taddress_agent where id_agent = $id_agente " ;
$result = mysql_query ( $sql );
while ( $row = mysql_fetch_array ( $result )){
$sql2 = " DELETE FROM taddress where id_a = " . $row [ " id_a " ];
$result2 = mysql_query ( $sql2 );
}
$sql = " DELETE FROM taddress_agent where id_agent = $id_agente " ;
$result = mysql_query ( $sql );
audit_db ( $id_user , $REMOTE_ADDR , " Agent ' $agent_name ' deleted " , " Agent Management " );
2008-06-19 02:24:05 +02:00
// Delete remote configuration
$agent_md5 = md5 ( $agent_name , FALSE );
if ( file_exists ( $config [ " remote_config " ] . " / " . $agent_md5 . " .md5 " )){
// Agent remote configuration editor
$file_name = $config [ " remote_config " ] . " / " . $agent_md5 . " .conf " ;
unlink ( $file_name );
$file_name = $config [ " remote_config " ] . " / " . $agent_md5 . " .md5 " ;
unlink ( $file_name );
}
2007-03-12 18:58:52 +01:00
} else { // NO permissions.
2007-03-02 18:56:07 +01:00
audit_db ( $id_user , $REMOTE_ADDR , " ACL Violation " ,
2007-03-12 18:58:52 +01:00
" Trying to delete agent ' $agent_name ' " );
2007-03-02 18:56:07 +01:00
require ( " general/noaccess.php " );
exit ;
}
2007-03-12 18:58:52 +01:00
}
2007-10-12 18:27:50 +02:00
echo " <h2> " . $lang_label [ " agent_conf " ] . " > " . $lang_label [ " agent_defined2 " ] . " </h2> " ;
2007-03-12 18:58:52 +01:00
// Show group selector
if ( isset ( $_POST [ " ag_group " ])){
$ag_group = $_POST [ " ag_group " ];
echo " <form method='post'
action = 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&ag_group_refresh=".$ag_group."' > " ;
} else {
echo " <form method='post'
action = 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente' > " ;
}
2007-03-02 18:56:07 +01:00
2008-01-10 17:40:00 +01:00
echo " <table cellpadding='4' cellspacing='4' class='databox' width=700><tr> " ;
echo " <td valign='top'> " . $lang_label [ " group " ] . " </td> " ;
echo " <td valign='top'> " ;
2007-03-12 18:58:52 +01:00
echo " <select name='ag_group' onChange='javascript:this.form.submit();'
class = 'w130' > " ;
if ( $ag_group > 1 ){
echo " <option value=' " . $ag_group . " '> " . dame_nombre_grupo ( $ag_group ) .
" </option> " ;
}
echo " <option value=1> " . dame_nombre_grupo ( 1 ) . " </option> " ; // Group all is always active
$mis_grupos = list_group ( $id_user ); //Print combo for groups and set an array with all groups
echo " </select> " ;
2008-01-10 17:40:00 +01:00
echo " <td valign='top'>
2007-03-12 18:58:52 +01:00
< noscript >
2007-05-08 13:24:57 +02:00
< input name = 'uptbutton' type = 'submit' class = 'sub upd'
2007-03-12 18:58:52 +01:00
value = '".$lang_label["show"]."' >
</ noscript >
</ td >
</ form >
2008-01-10 17:40:00 +01:00
< td valign = 'top' > " ;
echo $lang_label [ " free_text_search " ];
echo " </td><td> " ;
// Show group selector
if ( isset ( $_POST [ " ag_group " ])){
$group_mod = " &ag_group_refresh= " . $_POST [ " ag_group " ];
2007-03-12 18:58:52 +01:00
} else {
2008-01-10 17:40:00 +01:00
$group_mod = " " ;
2007-03-12 18:58:52 +01:00
}
2008-01-10 17:40:00 +01:00
echo " <form method='post' action='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&refr=60 $group_mod '> " ;
echo " <input type=text name='search' size='15' > " ;
echo " </td><td valign='top'> " ;
echo " <input name='srcbutton' type='submit' class='sub'
value = '".$lang_label["search"]."' > " ;
echo " </form> " ;
echo " </td></table> " ;
if ( $search != " " ){
2008-07-08 22:30:15 +02:00
$search_sql = " nombre LIKE '% $search %' " ;
2008-01-10 17:40:00 +01:00
} else {
2008-07-08 22:06:44 +02:00
$search_sql = " 1 = 1 " ;
2008-01-10 17:40:00 +01:00
}
// Show only selected groups
if ( $ag_group > 1 ){
2008-07-08 22:06:44 +02:00
$sql1 = " SELECT * FROM tagente WHERE id_grupo = $ag_group
AND $search_sql ORDER BY nombre LIMIT $offset , " . $config["block_size"] ;
2008-03-06 Sancho Lerena <slerena@gmail.com>
Pandora FMS 2.0 development first commit. 1.4 version is now 2.0
* pandoradb_data.sql: Added correct tnetwork_components, fixed
ttipo_modulo (categoria values).
* include/styles/pandora.css: Added some server icons, tab style
for module editor has been improved.
* include/functions_db.php: added new functions, lang_string and
check_login, and a first review of several functions that currently
need change for new config session parameters in array $config[]
* include/javascript/pandora.js: Added a new global include for
spare javascript functions before included into a few pages.
* include/languages/language_en.php: New tokens.
* include/help*: New contextual help system.
* include/config_process.php: New way to manage config.
* include/functions.php: Added new functions to manage global
* operation/agentes/estado_ultimopaquete.php: removed old javascript
code from there.
* operation/agentes/estado_agente.php: Removed references to deprecated
field "agent_type".
* operation/agentes/tactical.php: Some code cleanup and progressbar
issues merged from 1.3.1 branch. Need to add support to new server
types and new module types.
* operation/servers/view_server.php: Added support to new servers, code
cleanup.
* reporting/fgraph.php: Code cleanup, changes to use new config method,
and a lot of style change.
* general/pandora_help.php: New source for contextual help in the way
of moodle.
* general/footer.php, general/noaccess.php: Code cleanup and uses of
new config.
* module_manager_editor: New editors for each module family. Need
finish and implement EDITION of data, now only inserts data.
* godmode/agentes/agent_manager.php: Implemented new server assigment
and edition.
* godmode/agentes/configurar_agente.php: Small changes that affects
module management, visualization and agent management.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@739 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-03-07 17:22:16 +01:00
$sql2 = " SELECT COUNT(id_agente) FROM tagente WHERE id_grupo = $ag_group
2008-07-08 22:06:44 +02:00
AND $search_sql ORDER BY nombre " ;
2008-01-10 17:40:00 +01:00
} else {
// Is admin user ??
if ( get_db_sql ( " SELECT * FROM tusuario WHERE id_usuario =' $id_user ' " , " nivel " ) == 1 ){
2008-07-08 22:06:44 +02:00
$sql1 = " SELECT * FROM tagente WHERE $search_sql ORDER BY nombre, id_grupo LIMIT $offset , " . $config [ " block_size " ];
$sql2 = " SELECT COUNT(id_agente) FROM tagente WHERE $search_sql ORDER BY nombre, id_grupo " ;
2008-01-10 17:40:00 +01:00
} else {
2008-07-08 22:06:44 +02:00
$sql1 = " SELECT * FROM tagente WHERE $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario=' $id_user ')
2008-03-06 Sancho Lerena <slerena@gmail.com>
Pandora FMS 2.0 development first commit. 1.4 version is now 2.0
* pandoradb_data.sql: Added correct tnetwork_components, fixed
ttipo_modulo (categoria values).
* include/styles/pandora.css: Added some server icons, tab style
for module editor has been improved.
* include/functions_db.php: added new functions, lang_string and
check_login, and a first review of several functions that currently
need change for new config session parameters in array $config[]
* include/javascript/pandora.js: Added a new global include for
spare javascript functions before included into a few pages.
* include/languages/language_en.php: New tokens.
* include/help*: New contextual help system.
* include/config_process.php: New way to manage config.
* include/functions.php: Added new functions to manage global
* operation/agentes/estado_ultimopaquete.php: removed old javascript
code from there.
* operation/agentes/estado_agente.php: Removed references to deprecated
field "agent_type".
* operation/agentes/tactical.php: Some code cleanup and progressbar
issues merged from 1.3.1 branch. Need to add support to new server
types and new module types.
* operation/servers/view_server.php: Added support to new servers, code
cleanup.
* reporting/fgraph.php: Code cleanup, changes to use new config method,
and a lot of style change.
* general/pandora_help.php: New source for contextual help in the way
of moodle.
* general/footer.php, general/noaccess.php: Code cleanup and uses of
new config.
* module_manager_editor: New editors for each module family. Need
finish and implement EDITION of data, now only inserts data.
* godmode/agentes/agent_manager.php: Implemented new server assigment
and edition.
* godmode/agentes/configurar_agente.php: Small changes that affects
module management, visualization and agent management.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@739 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-03-07 17:22:16 +01:00
ORDER BY nombre , id_grupo LIMIT $offset , " . $config["block_size"] ;
2008-07-08 22:06:44 +02:00
$sql2 = " SELECT COUNT(id_agente) FROM tagente WHERE $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario=' $id_user ') ORDER BY nombre, id_grupo " ;
2008-01-10 17:40:00 +01:00
}
}
2007-03-12 18:58:52 +01:00
$result = mysql_query ( $sql1 );
$result2 = mysql_query ( $sql2 );
$row2 = mysql_fetch_array ( $result2 );
$total_events = $row2 [ 0 ];
2007-03-02 18:56:07 +01:00
2007-03-12 18:58:52 +01:00
// Prepare pagination
2007-09-27 17:12:49 +02:00
pagination ( $total_events , " index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id= $ag_group " , $offset );
2007-03-12 18:58:52 +01:00
echo " <div style='height: 20px'> </div> " ;
if ( mysql_num_rows ( $result )){
2008-01-10 17:40:00 +01:00
echo " <table cellpadding='4' cellspacing='4' width='750' class='databox'> " ;
2007-06-06 18:23:24 +02:00
echo " <th> " . $lang_label [ " agent_name " ] . " </th> " ;
2008-06-19 02:24:05 +02:00
echo " <th title=' " . lang_string ( " Remote agent configuration " ) . " '> " . lang_string ( " R " ) . " </th> " ;
2007-06-06 18:23:24 +02:00
echo " <th> " . $lang_label [ " os " ] . " </th> " ;
echo " <th> " . $lang_label [ " group " ] . " </th> " ;
echo " <th> " . $lang_label [ " description " ] . " </th> " ;
echo " <th> " . $lang_label [ " delete " ] . " </th> " ;
2007-03-12 18:58:52 +01:00
$color = 1 ;
while ( $row = mysql_fetch_array ( $result )){
$id_grupo = $row [ " id_grupo " ];
if ( $color == 1 ){
$tdcolor = " datos " ;
$color = 0 ;
2006-07-03 12:49:42 +02:00
}
2007-03-12 18:58:52 +01:00
else {
$tdcolor = " datos2 " ;
$color = 1 ;
}
if ( give_acl ( $id_user , $id_grupo , " AW " ) == 1 ){
// Agent name
2008-07-08 22:06:44 +02:00
echo " <tr><td class=' $tdcolor '> " ;
if ( $row [ " disabled " ] == 1 ){
echo " <i> " ;
}
echo " <b><a href='index.php?sec=gagente&
2007-03-12 18:58:52 +01:00
sec2 = godmode / agentes / configurar_agente & tab = main &
2008-07-08 22:06:44 +02:00
id_agente = " . $row["id_agente"] . " ' > " .substr(strtoupper( $row["nombre"] ),0,20). " </ a ></ b > " ;
if ( $row [ " disabled " ] == 1 ){
echo " <i> " ;
}
echo " </td> " ;
2008-06-19 02:24:05 +02:00
echo " <td align='center' class=' $tdcolor '> " ;
// Has remote configuration ?
$agent_md5 = md5 ( $row [ " nombre " ], FALSE );
if ( file_exists ( $config [ " remote_config " ] . " / " . $agent_md5 . " .md5 " )){
2008-07-01 Jorge Gonzalez <jorge.gonzalez@artica.es>
* include/help/en/help_plugin_parameters.php,
include/help/en/help_alert_recovery.php,
include/help/en/help_prediction_source_module.php,
include/help/en/help_snmpwalk.php,
include/help/en/help_alert_type.php,
include/help/en/help_network_component.php: Added new help pages.
* include/help/en/help_map_builder.php,
include/help/en/help_postprocess.php,
include/help/en/help_recontask.php, include/help/en/help_alerts.php,
include/help/en/help_manage_alerts.php: modified HTML tag.
* godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/alert_manager_editor.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/agent_manager.php, godmode/alerts/configure_alert.php:
Added/modified help support.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@912 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-07-01 13:26:17 +02:00
echo " <img src='images/application_edit.png' border='0' align='middle' title=' " . lang_string ( " Edit remote config " ) . " '> " ;
2008-06-19 02:24:05 +02:00
}
echo " </td> " ;
2007-03-12 18:58:52 +01:00
// Operating System icon
echo " <td class=' $tdcolor ' align='center'>
< img src = 'images/".dame_so_icon($row["id_os"])."' ></ td > " ;
// Group icon and name
echo " <td class=' $tdcolor '>
< img src = 'images/groups_small/".show_icon_group($id_grupo).".png' class = 'bot' border = '0' >
& nbsp ; " .dame_grupo( $id_grupo ). " </ td > " ;
// Description
2008-01-10 17:40:00 +01:00
echo " <td class=' " . $tdcolor . " f9'> " . $row [ " comentarios " ] . " </td> " ;
2007-03-12 18:58:52 +01:00
// Action
2007-04-21 18:14:11 +02:00
echo " <td class=' $tdcolor ' align='center'><a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
borrar_agente = " . $row["id_agente"] . " ' " ;
echo ' onClick="if (!confirm(\' ' . $lang_label [ " are_you_sure " ] . '\')) return false;">' ;
echo " <img border='0' src='images/cross.png'></a></td> " ;
2006-07-03 12:49:42 +02:00
}
2006-03-27 05:37:27 +02:00
}
2007-06-06 18:23:24 +02:00
echo " </table> " ;
2008-01-10 17:40:00 +01:00
echo " <table width='750'><tr><td align='right'> " ;
2007-03-12 18:58:52 +01:00
} else {
echo " <div class='nf'> " . $lang_label [ " no_agent_def " ] . " </div> " ;
2007-04-24 15:38:44 +02:00
echo " </td></tr><tr><td> " ;
2007-04-21 18:14:11 +02:00
}
2007-04-11 05:12:48 +02:00
2007-04-21 18:14:11 +02:00
// Create agent button
2007-03-12 18:58:52 +01:00
echo " <form method='post' action='index.php?sec=gagente&
2007-04-11 05:12:48 +02:00
sec2 = godmode / agentes / configurar_agente & create_agent = 1 ' > " ;
2007-05-08 13:24:57 +02:00
echo " <input type='submit' class='sub next' name='crt'
2007-03-12 18:58:52 +01:00
value = '".$lang_label["create_agent"]."' > " ;
2007-04-24 15:38:44 +02:00
echo " </form></td></tr></table> " ;
2006-10-07 13:52:52 +02:00
?>