2011-06-29 Sergio Martin <sergio.martin@artica.es>

* include/help/en/help_snmp_trap_types.php
	include/help/es/help_snmp_trap_types.php
	include/functions_snmp.php
	operation/snmpconsole/snmp_view.php: Added snmp trap generator
	in the snmpview



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4499 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2011-06-29 10:38:07 +00:00
parent e73584d223
commit 0ad0450849
5 changed files with 135 additions and 17 deletions

View File

@ -1,3 +1,11 @@
2011-06-29 Sergio Martin <sergio.martin@artica.es>
* include/help/en/help_snmp_trap_types.php
include/help/es/help_snmp_trap_types.php
include/functions_snmp.php
operation/snmpconsole/snmp_view.php: Added snmp trap generator
in the snmpview
2011-06-29 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/styles/pandora.css

View File

@ -0,0 +1,31 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org 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
// 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.
/**
* Generates a trap
*
* @param string Destiny host address.
* @param string Snmp community.
* @param string Snmp OID.
* @param string Snmp agent.
* @param string Data of the trap.
* @param string Snmp especific OID.
*/
function snmp_generate_trap($snmp_host_address, $snmp_community, $snmp_oid, $snmp_agent, $snmp_data, $snmp_type) {
system("snmptrap -v 1 -c $snmp_community $snmp_host_address $snmp_oid $snmp_agent $snmp_type $snmp_data 0");
}
?>

View File

@ -0,0 +1,15 @@
<?php
/**
* @package Include/help/es
*/
?>
<h1>Trap types</h1>
<ul>
<li>Cold start (0): Indicates that the agent has been started/restarted;</li>
<li>Warm start (1): Indicates that the agent configuration has been changed;</li>
<li>Link down (2): Indicates that the communication interface is out of service (inactive);</li>
<li>Link up (3): Indicates that a communication interface is in service(active);</li>
<li>Authentication failure (4): Indicates that the agent has been received a request from a not authorized NMS (normally controlled by a community);</li>
<li>EGP neighbor loss (5): Indicates that in systems that routers are using EGP protocol, a near host is out of service;</li>
<li>Enterprise (6): In this category are all the new traps, including by the vendors.</li>
</ul>

View File

@ -0,0 +1,15 @@
<?php
/**
* @package Include/help/es
*/
?>
<h1>Tipos de trap</h1>
<ul>
<li>Cold start (0): Indica que el agente ha sido inicializado o reinicializado;</li>
<li>Warm start (1): Indica que la configuración del agente ha cambiado;</li>
<li>Link down (2): Indica que una interfaz de comunicación se encuentra fuera de servicio (inactiva);</li>
<li>Link up (3): Indica que una interfaz de comunicación se encuentra en servicio (activa);</li>
<li>Authentication failure (4): Indica que el agente ha recibido un requerimiento de un NMS no autorizado (normalmente controlado por una comunidad);</li>
<li>EGP neighbor loss (5): Indica que en sistemas en que los routers están utilizando el protocolo EGP, un equipo colindante se encuentra fuera de servicio;</li>
<li>Enterprise (6): En esta categoría se encuentran todos los nuevos traps incluidos por los vendedores.</li>
</ul>

View File

@ -19,6 +19,7 @@
global $config;
enterprise_include ("operation/snmpconsole/snmp_view.php");
require_once("include/functions_agents.php");
require_once("include/functions_snmp.php");
check_login ();
@ -38,8 +39,17 @@ $filter_status = (int) get_parameter ("filter_status", 0);
$search_string = (string) get_parameter ("search_string", '');
$pagination = (int) get_parameter ("pagination", $config["block_size"]);
$offset = (int) get_parameter ('offset',0);
$snmp_host_address = (string) get_parameter ("snmp_host_address", 'localhost');
$snmp_community = (string) get_parameter ("snmp_community", 'public');
$snmp_oid = (string) get_parameter ("snmp_oid", '');
$snmp_agent = (string) get_parameter ("snmp_agent", '');
$snmp_value = (string) get_parameter ("snmp_value", '');
$snmp_type = (int) get_parameter ("snmp_type", 0);
$generate_trap = (bool) get_parameter ("generate_trap", 0);
$url = "index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&filter_agent=".$filter_agent."&filter_oid=".$filter_oid."&filter_severity=".$filter_severity."&filter_fired=".$filter_fired."&search_string=".$search_string."&pagination=".$pagination."&offset=".$offset;
if ($config["pure"]) {
$link = '<a target="_top" href="'.$url.'&pure=0&refr=30">' . html_print_image("images/normalscreen.png", true, array("title" => __('Normal screen'))) . '</a>';
}
@ -117,6 +127,20 @@ if (isset ($_POST["updatebt"])) {
}
}
if($generate_trap) {
$result = true;
if($snmp_host_address != '' && $snmp_community != '' && $snmp_oid != '' && $snmp_agent != '' && $snmp_value != '' && $snmp_type != -1) {
snmp_generate_trap($snmp_host_address, $snmp_community, $snmp_oid, $snmp_agent, $snmp_value, $snmp_type);
}
else {
$result = false;
}
ui_print_result_message ($result,
__('Successfully generated'),
__('Could not be generated'));
}
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ("SELECT * FROM ttrap ORDER BY timestamp DESC LIMIT %d,%d",$offset,$pagination);
@ -146,10 +170,42 @@ if (empty ($traps)) {
return;
}
// Toggle filters
echo '<a href="#" onmousedown="toggleDiv(\'filters\');"><b>'.__('Toggle filter(s)').'</b>&nbsp;' . html_print_image("images/down.png", true) . '</a>';
$traps_generator = '<form method="POST" action="index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&refr='.$config["refr"].'&pure='.$config["pure"].'">';
$table->width = '90%';
$table->size = array ();
$table->data = array ();
$table->data[0][0] = __('Host address');
$table->data[0][1] = html_print_input_text('snmp_host_address', $snmp_host_address, '', 50, 255, true);
$table->data[1][0] = __('Community');
$table->data[1][1] = html_print_input_text('snmp_community', $snmp_community, '', 50, 255, true);
$table->data[2][0] = __('OID');
$table->data[2][1] = html_print_input_text('snmp_oid', $snmp_oid, '', 50, 255, true);
$table->data[3][0] = __('SNMP Agent');
$table->data[3][1] = html_print_input_text('snmp_agent', $snmp_agent, '', 50, 255, true);
$table->data[4][0] = __('SNMP Type').' '.ui_print_help_icon ("snmp_trap_types", true);
$table->data[4][1] = html_print_input_text('snmp_type', $snmp_type, '', 50, 255, true);
$types = array(0 => 'Cold start (0)', 1 => 'Warm start (1)', 2 => 'Link down (2)', 3 => 'Link up (3)', 4 => 'Authentication failure (4)', 5 => 'EGP neighbor loss (5)', 6 => 'Enterprise (6)');
$table->data[4][1] = html_print_select($types, 'snmp_type', $snmp_type, '', __('Select'), -1, true, false, false);
$table->data[5][0] = __('Value');
$table->data[5][1] = html_print_input_text('snmp_value', $snmp_value, '', 50, 255, true);
$traps_generator .= html_print_table($table, true);
$traps_generator .= '<div style="width:'.$table->width.'; text-align: right;">'.html_print_submit_button(__('Generate trap'), 'btn_generate_trap', false, 'class="sub cog"', true).'</div>';
$traps_generator .= html_print_input_hidden('generate_trap', 1, true);
unset($table);
$traps_generator .= '</form>';
ui_toggle($traps_generator, __('Trap generator'));
echo '<form method="POST" action="index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&refr='.$config["refr"].'&pure='.$config["pure"].'">';
$table->width = '90%';
$table->size = array ();
$table->size[0] = '120px';
@ -272,13 +328,6 @@ if (($config['dbtype'] == 'oracle') && ($traps !== false)) {
}
}
if ($config["pure"] == 1) {
echo '<div id="filters" style="display:none;">';
}
else {
echo '<div id="filters" style="display: none;">';
}
// Agent select
$table->data[0][0] = '<strong>'.__('Agent').'</strong>';
$table->data[0][1] = html_print_select ($agents, 'filter_agent', $filter_agent, 'javascript:this.form.submit();', __('All'), '', true);
@ -315,14 +364,14 @@ $status[0] = __('Not validated');
$status[1] = __('Validated');
$table->data[3][1] = html_print_select ($status, 'filter_status', $filter_status, 'this.form.submit();', '', '', true);
html_print_table ($table);
$filter = '<form method="POST" action="index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&refr='.$config["refr"].'&pure='.$config["pure"].'">';
$filter .= html_print_table($table, true);
$filter .= '</form>';
ui_toggle($filter, __('Toggle filter(s)'));
unset ($table);
echo '</form>';
echo '</div>';
echo '<br />';
// Prepare index for pagination
$trapcount = db_get_sql ("SELECT COUNT(*) FROM ttrap " . $whereSubquery);
@ -330,7 +379,7 @@ $urlPagination = "index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view
. "&filter_oid=" . $filter_oid . "&filter_severity=" . $filter_severity
. "&filter_fired=" . $filter_fired . "&filter_status=" . $filter_status
. "&search_string=" . $search_string . "&pagination=".$pagination."&offset=".$offset."&refr=".$config["refr"]."&pure=".$config["pure"];
pagination ($trapcount, $urlPagination, $offset, $pagination);
ui_pagination ($trapcount, $urlPagination, $offset, $pagination);
echo '<form name="eventtable" method="POST" action="index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&pagination='.$pagination.'&offset='.$offset.'">';