2010-02-12 Miguel de Dios <miguel.dedios@artica.es>

* pandoradb.sql: add new fields to tnetwork_component for support the
	snmp ver 3.
	
	* godmode/modules/manage_network_components_form.php,
	godmode/modules/manage_network_components_form_network.php
	godmode/modules/manage_network_components.php: add support to snmp ver 3,
	add the fields for this use, and now can create and edit network
	component with snmp ver 3.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2356 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2010-02-12 11:13:24 +00:00
parent 52f9ad01c1
commit 176a3d1963
5 changed files with 204 additions and 11 deletions

View File

@ -1,3 +1,14 @@
2010-02-12 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb.sql: add new fields to tnetwork_component for support the
snmp ver 3.
* godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_components_form_network.php
godmode/modules/manage_network_components.php: add support to snmp ver 3,
add the fields for this use, and now can create and edit network
component with snmp ver 3.
2010-02-12 Miguel de Dios <miguel.dedios@artica.es>
* godmode/modules/manage_network_components_form.php: clean source code and

View File

@ -54,6 +54,14 @@ $ff_event = (int) get_parameter ('ff_event');
$history_data = (bool) get_parameter ('history_data');
$id = (int) get_parameter ('id');
$snmp_version = (string) get_parameter('snmp_version');
$snmp3_auth_user = (string) get_parameter('snmp3_auth_user');
$snmp3_auth_pass = (string) get_parameter('snmp3_auth_pass');
$snmp3_auth_method = (string) get_parameter('snmp3_auth_method');
$snmp3_privacy_method = (string) get_parameter('snmp3_privacy_method');
$snmp3_privacy_pass = (string) get_parameter('snmp3_privacy_pass');
$snmp3_security_level = (string) get_parameter('snmp3_security_level');
$create_component = (bool) get_parameter ('create_component');
$update_component = (bool) get_parameter ('update_component');
$delete_component = (bool) get_parameter ('delete_component');
@ -78,6 +86,20 @@ if ($duplicate_network_component) {
}
if ($create_component) {
$custom_string_1 = '';
$custom_string_2 = '';
$custom_string_3 = '';
if ($type >= 15 && $type <= 18) {
// New support for snmp v3
$tcp_send = $snmp_version;
$plugin_user = $snmp3_auth_user;
$plugin_pass = $snmp3_auth_pass;
$plugin_parameter = $snmp3_auth_method;
$custom_string_1 = $snmp3_privacy_method;
$custom_string_2 = $snmp3_privacy_pass;
$custom_string_3 = $snmp3_security_level;
}
$id = create_network_component ($name, $type, $id_group,
array ('description' => $description,
'module_interval' => $module_interval,
@ -100,7 +122,10 @@ if ($create_component) {
'max_warning' => $max_warning,
'min_critical' => $min_critical,
'max_critical' => $max_critical,
'min_ff_event' => $ff_event));
'min_ff_event' => $ff_event,
'custom_string_1' => $custom_string_1,
'custom_string_2' => $custom_string_2,
'custom_string_3' => $custom_string_3));
if ($id === false) {
print_error_message (__('Could not be created'));
include_once ('godmode/modules/manage_network_components_form.php');
@ -113,6 +138,20 @@ if ($create_component) {
if ($update_component) {
$id = (int) get_parameter ('id');
$custom_string_1 = '';
$custom_string_2 = '';
$custom_string_3 = '';
if ($type >= 15 && $type <= 18) {
// New support for snmp v3
$tcp_send = $snmp_version;
$plugin_user = $snmp3_auth_user;
$plugin_pass = $snmp3_auth_pass;
$plugin_parameter = $snmp3_auth_method;
$custom_string_1 = $snmp3_privacy_method;
$custom_string_2 = $snmp3_privacy_pass;
$custom_string_3 = $snmp3_security_level;
}
$result = update_network_component ($id,
array ('type' => $type,
'name' => $name,
@ -138,7 +177,10 @@ if ($update_component) {
'max_warning' => $max_warning,
'min_critical' => $min_critical,
'max_critical' => $max_critical,
'min_ff_event' => $ff_event));
'min_ff_event' => $ff_event,
'custom_string_1' => $custom_string_1,
'custom_string_2' => $custom_string_2,
'custom_string_3' => $custom_string_3));
if ($result === false) {
print_error_message (__('Could not be updated'));
include_once ('godmode/modules/manage_network_components_form.php');

View File

@ -54,7 +54,20 @@ if (isset ($id)) {
$min_critical = $component["min_critical"];
$ff_event = $component["min_ff_event"];
$history_data = $component["history_data"];
} elseif (isset ($new_component) && $new_component) {
if ($type >= 15 && $type <= 18) {
// New support for snmp v3
$snmp_version = $component["tcp_send"];
$snmp3_auth_user = $component["plugin_user"];
$snmp3_auth_pass = $component["plugin_pass"];
$snmp3_auth_method = $component["plugin_parameter"];
$snmp3_privacy_method = $component["custom_string_1"];
$snmp3_privacy_pass = $component["custom_string_2"];
$snmp3_security_level = $component["custom_string_3"];
}
}
elseif (isset ($new_component) && $new_component) {
$name = "";
$snmp_oid = "";
$description = "";
@ -77,6 +90,15 @@ if (isset ($id)) {
$min_critical = 0;
$ff_event = 0;
$history_data = true;
$snmp_version = 1;
$snmp3_auth_user = '';
$snmp3_auth_pass = '';
$snmp3_privacy_method = '';
$snmp3_privacy_pass = '';
$snmp3_auth_method = '';
$snmp3_security_level = '';
}
}
@ -137,7 +159,7 @@ echo '</form>';
<!--
function type_change () {
// type 1-4 - Generic_xxxxxx
if ((document.component.type.value > 0) && (document.component.type.value < 5)){
if ((document.component.type.value > 0) && (document.component.type.value < 5)) {
document.component.snmp_oid.style.background="#ddd";
document.component.snmp_oid.disabled=true;
document.component.snmp_community.style.background="#ddd";
@ -148,9 +170,24 @@ function type_change () {
document.component.tcp_rcv.disabled=true;
document.component.tcp_port.style.background="#ddd";
document.component.tcp_port.disabled=true;
document.component.snmp_version.style.background="#ddd";
document.component.snmp_version.disabled=true;
document.component.snmp3_auth_user.style.background="#ddd";
document.component.snmp3_auth_user.disabled=true;
document.component.snmp3_auth_pass.background="#ddd";
document.component.snmp3_auth_pass.disabled=true;
document.component.snmp3_privacy_method.style.background="#ddd";
document.component.snmp3_privacy_method.disabled=true;
document.component.snmp3_privacy_pass.style.background="#ddd";
document.component.snmp3_privacy_pass.disabled=true;
document.component.snmp3_auth_method.style.background="#ddd";
document.component.snmp3_auth_method.disabled=true;
document.component.snmp3_security_level.style.background="#ddd";
document.component.snmp3_security_level.disabled=true;
}
// type 15-18- SNMP
if ((document.component.type.value > 14) && (document.component.type.value < 19 )){
if ((document.component.type.value > 14) && (document.component.type.value < 19 )) {
document.component.snmp_oid.style.background="#fff";
document.component.snmp_oid.style.disabled=false;
document.component.snmp_community.style.background="#fff";
@ -163,9 +200,24 @@ function type_change () {
document.component.tcp_rcv.disabled=true;
document.component.tcp_port.style.background="#ddd";
document.component.tcp_port.disabled=true;
document.component.snmp_version.style.background="#fff";
document.component.snmp_version.disabled=false;
document.component.snmp3_auth_user.style.background="#fff";
document.component.snmp3_auth_user.disabled=false;
document.component.snmp3_auth_pass.background="#fff";
document.component.snmp3_auth_pass.disabled=false;
document.component.snmp3_privacy_method.style.background="#fff";
document.component.snmp3_privacy_method.disabled=false;
document.component.snmp3_privacy_pass.style.background="#fff";
document.component.snmp3_privacy_pass.disabled=false;
document.component.snmp3_auth_method.style.background="#fff";
document.component.snmp3_auth_method.disabled=false;
document.component.snmp3_security_level.style.background="#fff";
document.component.snmp3_security_level.disabled=false;
}
// type 6-7 - ICMP
if ((document.component.type.value == 6) || (document.component.type.value == 7)){
if ((document.component.type.value == 6) || (document.component.type.value == 7)) {
document.component.snmp_oid.style.background="#ddd";
document.component.snmp_oid.disabled=true;
document.component.snmp_community.style.background="#ddd";
@ -178,9 +230,24 @@ function type_change () {
document.component.tcp_rcv.disabled=true;
document.component.tcp_port.style.background="#ddd";
document.component.tcp_port.disabled=true;
document.component.snmp_version.style.background="#ddd";
document.component.snmp_version.disabled=true;
document.component.snmp3_auth_user.style.background="#ddd";
document.component.snmp3_auth_user.disabled=true;
document.component.snmp3_auth_pass.background="#ddd";
document.component.snmp3_auth_pass.disabled=true;
document.component.snmp3_privacy_method.style.background="#ddd";
document.component.snmp3_privacy_method.disabled=true;
document.component.snmp3_privacy_pass.style.background="#ddd";
document.component.snmp3_privacy_pass.disabled=true;
document.component.snmp3_auth_method.style.background="#ddd";
document.component.snmp3_auth_method.disabled=true;
document.component.snmp3_security_level.style.background="#ddd";
document.component.snmp3_security_level.disabled=true;
}
// type 8-11 - TCP
if ((document.component.type.value > 7) && (document.component.type.value < 12)){
if ((document.component.type.value > 7) && (document.component.type.value < 12)) {
document.component.snmp_oid.style.background="#ddd";
document.component.snmp_oid.disabled=true;
document.component.snmp_community.style.background="#ddd";
@ -191,9 +258,24 @@ function type_change () {
document.component.tcp_rcv.disabled=false;
document.component.tcp_port.style.background="#fff";
document.component.tcp_port.disabled=false;
document.component.snmp_version.style.background="#ddd";
document.component.snmp_version.disabled=true;
document.component.snmp3_auth_user.style.background="#ddd";
document.component.snmp3_auth_user.disabled=true;
document.component.snmp3_auth_pass.background="#ddd";
document.component.snmp3_auth_pass.disabled=true;
document.component.snmp3_privacy_method.style.background="#ddd";
document.component.snmp3_privacy_method.disabled=true;
document.component.snmp3_privacy_pass.style.background="#ddd";
document.component.snmp3_privacy_pass.disabled=true;
document.component.snmp3_auth_method.style.background="#ddd";
document.component.snmp3_auth_method.disabled=true;
document.component.snmp3_security_level.style.background="#ddd";
document.component.snmp3_security_level.disabled=true;
}
// type 12 - UDP
if (document.component.type.value == 12){
if (document.component.type.value == 12) {
document.component.snmp_oid.style.background="#ddd";
document.component.snmp_oid.disabled=true;
document.component.snmp_community.style.background="#ddd";
@ -204,6 +286,21 @@ function type_change () {
document.component.tcp_rcv.disabled=false;
document.component.tcp_port.style.background="#fff";
document.component.tcp_port.disabled=false;
document.component.snmp_version.style.background="#ddd";
document.component.snmp_version.disabled=true;
document.component.snmp3_auth_user.style.background="#ddd";
document.component.snmp3_auth_user.disabled=true;
document.component.snmp3_auth_pass.background="#ddd";
document.component.snmp3_auth_pass.disabled=true;
document.component.snmp3_privacy_method.style.background="#ddd";
document.component.snmp3_privacy_method.disabled=true;
document.component.snmp3_privacy_pass.style.background="#ddd";
document.component.snmp3_privacy_pass.disabled=true;
document.component.snmp3_auth_method.style.background="#ddd";
document.component.snmp3_auth_method.disabled=true;
document.component.snmp3_security_level.style.background="#ddd";
document.component.snmp3_security_level.disabled=true;
}
}
<?php if ($id_component_type == 2) :?>

View File

@ -33,21 +33,58 @@ echo "<h2>".__('Module management')." &raquo; ";
echo __('Module component management')."</h2>";
echo "<h3>".__('Network component')."</h3>";
$snmp_versions['1'] = 'v. 1';
$snmp_versions['2'] = 'v. 2';
$snmp_versions['2c'] = 'v. 2c';
$snmp_versions['3'] = 'v. 3';
$data = array ();
$data[0] = _('Port');
$data[1] = print_input_text ('tcp_port', $tcp_port, '', 5, 20, true);
$data[2] = __('SNMP community');
$data[3] = print_input_text ('snmp_community', $snmp_community, '', 15, 60, true);
$data[2] = _('SNMP version');
$data[3] = print_select ($snmp_versions, 'snmp_version', $snmp_version,
'', '', '', true, false, false, '');
push_table_row ($data, 'snmp_port');
$data = array ();
$data[0] = __('SNMP OID');
$data[1] = print_input_text ('snmp_oid', $snmp_oid, '', 30, 120, true);
$table->colspan['snmp_2'][1] = 3;
//$table->colspan['snmp_2'][1] = 3;
$data[2] = __('SNMP community');
$data[3] = print_input_text ('snmp_community', $snmp_community, '', 15, 60, true);
push_table_row ($data, 'snmp_2');
$data = array();
$data[0] = __('Auth user');
$data[1] = print_input_text ('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true);
$data[2] = __('Auth password');
$data[3] = print_input_text ('snmp3_auth_pass', $snmp3_auth_pass, '', 15, 60, true);
$data[3] .= print_input_hidden('active_snmp_v3', 0, true);
push_table_row($data, 'field_snmpv3_row1');
$data = array();
$data[0] = __('Privacy method');
$data[1] = print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true);
$data[2] = __('privacy pass');
$data[3] = print_input_text ('snmp3_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true);
push_table_row($data, 'field_snmpv3_row2');
$data = array();
$data[0] = __('Auth method');
$data[1] = print_select(array('MD5' => __('MD5'), 'SHA' => __('SHA')), 'snmp3_auth_method', $snmp3_auth_method, '', '', '', true);
$data[2] = __('Security level');
$data[3] = print_select(array('noAuthNoPriv' => __('Not auth and not privacy method'),
'authNoPriv' => __('Auth and not privacy method'), 'authPriv' => __('Auth and privacy method')), 'snmp3_security_level', $snmp3_security_level, '', '', '', true);
push_table_row($data, 'field_snmpv3_row3');
/* Advanced stuff */
$data = array ();
$data[0] = __('TCP send').' '.print_help_icon ("tcp_send", true);
@ -56,6 +93,7 @@ $table->colspan['tcp_send'][1] = 3;
push_table_row ($data, 'tcp_send');
$data = array();
$data[0] = __('TCP receive');
$data[1] = print_textarea ('tcp_rcv', 2, 65, $tcp_rcv, '', true);
$table->colspan['tcp_receive'][1] = 3;

View File

@ -505,6 +505,11 @@ CREATE TABLE IF NOT EXISTS `tnetwork_component` (
`min_critical` double(18,2) default 0,
`max_critical` double(18,2) default 0,
`min_ff_event` int(4) unsigned default '0',
`custom_string_1` text default '',
`custom_string_2` text default '',
`custom_string_3` text default '',
`custom_integer_1` int(10) default 0,
`custom_integer_2` int(10) default 0,
PRIMARY KEY (`id_nc`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;