2014-04-02 Miguel de Dios <miguel.dedios@artica.es>
* godmode/modules/manage_network_components.php, godmode/modules/manage_network_components_form.php, godmode/agentes/configurar_agente.php, include/functions_snmp_browser.php, operation/snmpconsole/snmp_browser.php: implemented the feature to create a network component from snmp browser. Incident: #684 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9700 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
0963dbec37
commit
15129bf4c8
|
@ -1,3 +1,14 @@
|
|||
2014-04-02 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/modules/manage_network_components.php,
|
||||
godmode/modules/manage_network_components_form.php,
|
||||
godmode/agentes/configurar_agente.php,
|
||||
include/functions_snmp_browser.php,
|
||||
operation/snmpconsole/snmp_browser.php: implemented the feature to
|
||||
create a network component from snmp browser.
|
||||
|
||||
Incident: #684
|
||||
|
||||
2014-04-01 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_modules.php, operation/agentes/exportdata.php:
|
||||
|
|
|
@ -1311,7 +1311,7 @@ if ($delete_module) { // DELETE agent module !
|
|||
}
|
||||
|
||||
// MODULE DUPLICATION
|
||||
// =================
|
||||
// ==================
|
||||
if (!empty($duplicate_module)) { // DUPLICATE agent module !
|
||||
$id_duplicate_module = $duplicate_module;
|
||||
|
||||
|
|
|
@ -127,6 +127,7 @@ $duplicate_network_component = (bool) get_parameter ('duplicate_network_componen
|
|||
$delete_multiple = (bool) get_parameter('delete_multiple');
|
||||
$multiple_delete = (bool)get_parameter('multiple_delete', 0);
|
||||
$create_network_from_module = (bool) get_parameter ('create_network_from_module', 0);
|
||||
$create_network_from_snmp_browser = (bool)get_parameter('create_network_from_snmp_browser', 0);
|
||||
|
||||
if ($duplicate_network_component) {
|
||||
$source_id = (int) get_parameter ('source_id');
|
||||
|
@ -153,6 +154,8 @@ if ($create_component) {
|
|||
$name_check = db_get_value ('name', 'tnetwork_component', 'name',
|
||||
$name);
|
||||
|
||||
//remote_snmp = 15
|
||||
//remote_snmp_proc = 18
|
||||
if ($type >= 15 && $type <= 18) {
|
||||
// New support for snmp v3
|
||||
$tcp_send = $snmp_version;
|
||||
|
@ -168,7 +171,9 @@ if ($create_component) {
|
|||
|
||||
if ($name && !$name_check) {
|
||||
|
||||
$id = network_components_create_network_component ($name, $type, $id_group,
|
||||
$id = network_components_create_network_component ($name,
|
||||
$type,
|
||||
$id_group,
|
||||
array ('description' => $description,
|
||||
'module_interval' => $module_interval,
|
||||
'max' => $max,
|
||||
|
@ -297,7 +302,8 @@ if ($update_component) {
|
|||
$result = '';
|
||||
}
|
||||
if ($result === false || !$result) {
|
||||
db_pandora_audit("Module management", "Fail try to update network component #$id");
|
||||
db_pandora_audit("Module management",
|
||||
"Fail try to update network component #$id");
|
||||
ui_print_error_message (__('Could not be updated'));
|
||||
include_once ('godmode/modules/manage_network_components_form.php');
|
||||
return;
|
||||
|
@ -315,10 +321,12 @@ if ($delete_component) {
|
|||
$result = network_components_delete_network_component ($id);
|
||||
|
||||
if ($result) {
|
||||
db_pandora_audit( "Module management", "Delete network component #$id");
|
||||
db_pandora_audit( "Module management",
|
||||
"Delete network component #$id");
|
||||
}
|
||||
else {
|
||||
db_pandora_audit( "Module management", "Fail try to delete network component #$id");
|
||||
db_pandora_audit( "Module management",
|
||||
"Fail try to delete network component #$id");
|
||||
}
|
||||
|
||||
ui_print_result_message ($result,
|
||||
|
@ -340,10 +348,12 @@ if ($multiple_delete) {
|
|||
|
||||
$str_ids = implode (',', $ids);
|
||||
if ($result) {
|
||||
db_pandora_audit( "Module management", "Multiple delete network component: $str_ids");
|
||||
db_pandora_audit( "Module management",
|
||||
"Multiple delete network component: $str_ids");
|
||||
}
|
||||
else {
|
||||
db_pandora_audit( "Module management", "Fail try to delete network component: $str_ids");
|
||||
db_pandora_audit( "Module management",
|
||||
"Fail try to delete network component: $str_ids");
|
||||
}
|
||||
|
||||
ui_print_result_message ($result,
|
||||
|
@ -353,8 +363,9 @@ if ($multiple_delete) {
|
|||
$id = 0;
|
||||
}
|
||||
|
||||
if ($id || $new_component || $create_network_from_module) {
|
||||
include_once ($config['homedir'] . '/godmode/modules/manage_network_components_form.php');
|
||||
if ($id || $new_component || $create_network_from_module || $create_network_from_snmp_browser) {
|
||||
include_once ($config['homedir'] .
|
||||
'/godmode/modules/manage_network_components_form.php');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -490,7 +501,8 @@ $table->head[3] = __('Description');
|
|||
$table->head[4] = __('Group');
|
||||
$table->head[5] = __('Max/Min');
|
||||
$table->head[6] = __('Action') .
|
||||
html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();');
|
||||
html_print_checkbox('all_delete', 0, false, true, false,
|
||||
'check_all_checkboxes();');
|
||||
$table->size = array ();
|
||||
$table->size[1] = '75px';
|
||||
$table->size[6] = '80px';
|
||||
|
@ -504,22 +516,28 @@ foreach ($components as $component) {
|
|||
$component['max'] = $component['min'] = __('N/A');
|
||||
}
|
||||
|
||||
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/modules/manage_network_components&id='.$component['id_nc'].'&pure='.$pure.'">';
|
||||
$data[0] = '<a href="index.php?sec=' . $sec . '&' .
|
||||
'sec2=godmode/modules/manage_network_components&' .
|
||||
'id=' . $component['id_nc'] . '&pure=' . $pure . '">';
|
||||
$data[0] .= io_safe_output($component['name']);
|
||||
$data[0] .= '</a>';
|
||||
$data[1] = ui_print_moduletype_icon ($component['type'], true);
|
||||
switch ($component['id_modulo']) {
|
||||
case MODULE_NETWORK:
|
||||
$data[1] .= html_print_image('images/network.png', true, array('title' => __('Network module')));
|
||||
$data[1] .= html_print_image('images/network.png', true,
|
||||
array('title' => __('Network module')));
|
||||
break;
|
||||
case MODULE_WMI:
|
||||
$data[1] .= html_print_image('images/wmi.png', true, array('title' => __('WMI module')));
|
||||
$data[1] .= html_print_image('images/wmi.png', true,
|
||||
array('title' => __('WMI module')));
|
||||
break;
|
||||
case MODULE_PLUGIN:
|
||||
$data[1] .= html_print_image('images/plugin.png', true, array('title' => __('Plug-in module')));
|
||||
$data[1] .= html_print_image('images/plugin.png', true,
|
||||
array('title' => __('Plug-in module')));
|
||||
break;
|
||||
}
|
||||
$data[3] = "<span style='font-size: 8px'>". mb_strimwidth (io_safe_output($component['description']), 0, 60, "...") . "</span>";
|
||||
$data[3] = "<span style='font-size: 8px'>".
|
||||
mb_strimwidth (io_safe_output($component['description']), 0, 60, "...") . "</span>";
|
||||
$data[4] = network_components_get_group_name ($component['id_group']);
|
||||
$data[5] = $component['max']." / ".$component['min'];
|
||||
|
||||
|
@ -528,7 +546,7 @@ foreach ($components as $component) {
|
|||
html_print_image('images/copy.png', true, array('alt' => __('Duplicate'), 'title' => __('Duplicate'))) . '</a>';
|
||||
$data[6] .= '<a href="' . $url . '&delete_component=1&id=' . $component['id_nc'] . '&search_id_group=' . $search_id_group .
|
||||
'search_string=' . $search_string .
|
||||
'" onclick="if (! confirm (\''.__('Are you sure?').'\')) return false" >' .
|
||||
'" onclick="if (! confirm (\'' . __('Are you sure?') . '\')) return false" >' .
|
||||
html_print_image('images/cross.png', true, array('alt' => __('Delete'), 'title' => __('Delete'))) . '</a>' .
|
||||
html_print_checkbox_extended ('delete_multiple[]', $component['id_nc'], false, false, '', 'class="check_delete"', true);
|
||||
|
||||
|
@ -546,11 +564,12 @@ if (isset($data)) {
|
|||
echo "</form>";
|
||||
}
|
||||
else {
|
||||
echo "<div class='nf'>" . __('There are no defined network components') . "</div>";
|
||||
echo "<div class='nf'>" .
|
||||
__('There are no defined network components') . "</div>";
|
||||
}
|
||||
|
||||
echo '<form method="post" action="'.$url.'">';
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
echo '<form method="post" action="' . $url . '">';
|
||||
echo '<div class="action-buttons" style="width: ' . $table->width . '">';
|
||||
html_print_input_hidden ('new_component', 1);
|
||||
html_print_select (array(
|
||||
2 => __('Create a new network component'),
|
||||
|
|
|
@ -26,10 +26,11 @@ if (! check_acl ($config['id_user'], 0, "PM")) {
|
|||
}
|
||||
|
||||
$create_network_from_module = get_parameter('create_network_from_module');
|
||||
$create_network_from_snmp_browser = get_parameter('create_network_from_snmp_browser', 0);
|
||||
$pure = get_parameter('pure', 0);
|
||||
|
||||
if ($create_network_from_module) {
|
||||
|
||||
|
||||
$id_agentmodule = get_parameter('create_module_from');
|
||||
$data_module = db_get_row_filter('tagente_modulo', array ('id_agente_modulo' => $id_agentmodule));
|
||||
|
||||
|
@ -76,6 +77,7 @@ if ($create_network_from_module) {
|
|||
$id_component_type = 2;
|
||||
}
|
||||
|
||||
|
||||
if (isset ($id)) {
|
||||
$component = network_components_get_network_component ((int) $id);
|
||||
if ($component !== false) {
|
||||
|
@ -130,7 +132,8 @@ if (isset ($id)) {
|
|||
$snmp3_security_level = $component["custom_string_3"];
|
||||
}
|
||||
}
|
||||
elseif (isset ($new_component) && $new_component) {
|
||||
elseif (isset ($new_component) && $new_component && !$create_network_from_snmp_browser) {
|
||||
|
||||
$name = "";
|
||||
$snmp_oid = "";
|
||||
$description = "";
|
||||
|
@ -177,6 +180,9 @@ if (isset ($id)) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($create_network_from_snmp_browser) {
|
||||
}
|
||||
|
||||
/**
|
||||
* $id_component_type has these values:
|
||||
* 6 - Module WMI
|
||||
|
@ -189,18 +195,24 @@ if (isset ($id)) {
|
|||
|
||||
if ($id_component_type == 6) {
|
||||
$categories = array (0, 1, 2);
|
||||
require ($config['homedir'] . "/godmode/modules/manage_network_components_form_common.php");
|
||||
require ($config['homedir'] . "/godmode/modules/manage_network_components_form_wmi.php");
|
||||
require ($config['homedir'] .
|
||||
"/godmode/modules/manage_network_components_form_common.php");
|
||||
require ($config['homedir'] .
|
||||
"/godmode/modules/manage_network_components_form_wmi.php");
|
||||
}
|
||||
else if ($id_component_type == 4) {
|
||||
$categories = array (0, 1, 2);
|
||||
require ($config['homedir'] . "/godmode/modules/manage_network_components_form_common.php");
|
||||
require ($config['homedir'] . "/godmode/modules/manage_network_components_form_plugin.php");
|
||||
require ($config['homedir'] .
|
||||
"/godmode/modules/manage_network_components_form_common.php");
|
||||
require ($config['homedir'] .
|
||||
"/godmode/modules/manage_network_components_form_plugin.php");
|
||||
}
|
||||
else if ($id_component_type == 2 || $create_network_from_module) {
|
||||
$categories = array (3, 4, 5);
|
||||
require ($config['homedir'] . "/godmode/modules/manage_network_components_form_common.php");
|
||||
require ($config['homedir'] . "/godmode/modules/manage_network_components_form_network.php");
|
||||
require ($config['homedir'] .
|
||||
"/godmode/modules/manage_network_components_form_common.php");
|
||||
require ($config['homedir'] .
|
||||
"/godmode/modules/manage_network_components_form_network.php");
|
||||
}
|
||||
else {
|
||||
return;
|
||||
|
|
|
@ -303,7 +303,8 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = '
|
|||
else {
|
||||
$snmptranslate_bin = $config['snmptranslate'];
|
||||
}
|
||||
exec ($snmptranslate_bin . " -Td " . escapeshellarg($oid), $translate_output);
|
||||
exec ($snmptranslate_bin . " -Td " . escapeshellarg($oid),
|
||||
$translate_output);
|
||||
foreach ($translate_output as $line) {
|
||||
if (preg_match ('/SYNTAX\s+(.*)/', $line, $matches) == 1) {
|
||||
$oid_data['syntax'] = $matches[1];
|
||||
|
@ -347,7 +348,9 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = '
|
|||
*
|
||||
* @return string The OID data.
|
||||
*/
|
||||
function snmp_browser_print_oid ($oid = array(), $custom_action = '', $return = false) {
|
||||
function snmp_browser_print_oid ($oid = array(), $custom_action = '',
|
||||
$return = false, $community = '', $snmp_version = 1) {
|
||||
|
||||
$output = '';
|
||||
|
||||
// OID information table
|
||||
|
@ -361,20 +364,21 @@ function snmp_browser_print_oid ($oid = array(), $custom_action = '', $return =
|
|||
}
|
||||
}
|
||||
|
||||
$table->data[0][0] = '<strong>'.__('OID').'</strong>';
|
||||
$table->data[0][0] = '<strong>' . __('OID') . '</strong>';
|
||||
$table->data[0][1] = $oid['oid'];
|
||||
$table->data[1][0] = '<strong>'.__('Numeric OID').'</strong>';
|
||||
$table->data[1][1] = '<span id="snmp_selected_oid">' . $oid['numeric_oid'] . '</span>';
|
||||
$table->data[2][0] = '<strong>'.__('Value').'</strong>';
|
||||
$table->data[1][0] = '<strong>' . __('Numeric OID') . '</strong>';
|
||||
$table->data[1][1] = '<span id="snmp_selected_oid">' .
|
||||
$oid['numeric_oid'] . '</span>';
|
||||
$table->data[2][0] = '<strong>' . __('Value') . '</strong>';
|
||||
$table->data[2][1] = $oid['value'];
|
||||
$i = 3;
|
||||
if (isset ($oid['type'])) {
|
||||
$table->data[$i][0] = '<strong>'.__('Type').'</strong>';
|
||||
$table->data[$i][0] = '<strong>' . __('Type') . '</strong>';
|
||||
$table->data[$i][1] = $oid['type'];
|
||||
$i++;
|
||||
}
|
||||
if (isset ($oid['description'])) {
|
||||
$table->data[$i][0] = '<strong>'.__('Description').'</strong>';
|
||||
$table->data[$i][0] = '<strong>' . __('Description') . '</strong>';
|
||||
$table->data[$i][1] = $oid['description'];
|
||||
$i++;
|
||||
}
|
||||
|
@ -413,6 +417,31 @@ function snmp_browser_print_oid ($oid = array(), $custom_action = '', $return =
|
|||
|
||||
$output .= html_print_table($table, true);
|
||||
|
||||
$url = "index.php?" .
|
||||
"sec=gmodules&" .
|
||||
"sec2=godmode/modules/manage_network_components";
|
||||
|
||||
$output .= '<form style="text-align: center;" method="post" action="' . $url . '">';
|
||||
$output .= html_print_input_hidden('create_network_from_snmp_browser', 1, true);
|
||||
$output .= html_print_input_hidden('id_component_type', 2, true);
|
||||
$output .= html_print_input_hidden('type', 17, true);
|
||||
$name = '';
|
||||
if (!empty($oid['oid'])) {
|
||||
$name = $oid['oid'];
|
||||
}
|
||||
$output .= html_print_input_hidden('name', $name, true);
|
||||
$description = '';
|
||||
if (!empty($oid['description'])) {
|
||||
$description = $oid['description'];
|
||||
}
|
||||
$output .= html_print_input_hidden('description', $description, true);
|
||||
$output .= html_print_input_hidden('snmp_oid', $oid['numeric_oid'], true);
|
||||
$output .= html_print_input_hidden('snmp_community', $community, true);
|
||||
$output .= html_print_input_hidden('snmp_version', $snmp_version, true);
|
||||
$output .= html_print_submit_button(__('Create network component'),
|
||||
'', false, '', true);
|
||||
$output .= '</form>';
|
||||
|
||||
if ($return) {
|
||||
return $output;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,8 @@ if (is_ajax()) {
|
|||
$target_oid, $snmp_version, $snmp3_auth_user,
|
||||
$snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass,
|
||||
$snmp3_privacy_method, $snmp3_privacy_pass);
|
||||
snmp_browser_print_oid ($oid, $custom_action);
|
||||
snmp_browser_print_oid ($oid, $custom_action, false, $community,
|
||||
$snmp_version);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue