2014-07-22 Miguel de Dios <miguel.dedios@artica.es>

* 


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10346 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2014-07-22 16:07:31 +00:00
parent cb19580233
commit 7503a1f5be
3 changed files with 179 additions and 111 deletions

View File

@ -1,3 +1,8 @@
2014-07-22 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/agent_wizard.snmp_explorer.php,
include/functions.php: some fixes for the snmp v3.
2014-07-22 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/agent_manager.php: fixed to show the QR code image

View File

@ -109,6 +109,15 @@ if(!empty($plugin)) {
$fail = false;
$devices = array();
$processes = array();
$disks = array();
$temperatures = array();
$arrow = false;
$other_snmp_data = array();
if ($snmpwalk) {
// OID Used is for DISKS
$snmpis = get_snmpwalk($ip_target, $snmp_version, $snmp_community, $snmp3_auth_user,
@ -120,7 +129,6 @@ if ($snmpwalk) {
$snmpis = array();
}
else {
$disks = array();
// We get here only the interface part of the MIB, not full mib
foreach($snmpis as $key => $snmp) {
@ -153,7 +161,7 @@ if ($snmpwalk) {
$snmpis = array();
}
$processes = array();
// We get here only the interface part of the MIB, not full mib
foreach($snmpis as $key => $snmp) {
@ -191,7 +199,7 @@ if ($snmpwalk) {
$snmpis = array();
}
$temperatures = array();
// We get here only the interface part of the MIB, not full mib
foreach($snmpis as $key => $snmp) {
@ -229,7 +237,7 @@ if ($snmpwalk) {
$snmpis = array();
}
$devices = array();
// We get here only the interface part of the MIB, not full mib
foreach($snmpis as $key => $snmp) {
@ -262,8 +270,15 @@ if ($snmpwalk) {
// Other SNMP Data
$arrow = true;
foreach ($static_snmp_oids as $key => $oid) {
if ($snmp_version == 3) {
$result = false; //It is statics oids.
}
else {
$result = snmpget($ip_target, $snmp_community, $oid);
}
if ($result != false) {
$other_snmp_data[$key] = $static_snmp_descriptions[$key];
}
@ -379,7 +394,8 @@ if ($create_modules) {
if (($name == 'Bytes read') || ($name == 'Bytes written')) {
$module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp_inc');
} else {
}
else {
$module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp');
}
@ -568,19 +584,26 @@ if ($create_modules) {
$success_message = '';
$error_message = '';
if (isset($results[NOERR])) {
if (count($results[NOERR]) > 0) {
$success_message .= sprintf(__('%s modules created succesfully'), count($results[NOERR])) . '<br>';
}
}
if (isset($results[ERR_GENERIC])) {
if (count($results[ERR_GENERIC]) > 0) {
$error_message .= sprintf(__('Error creating %s modules') . ': <br>&nbsp;&nbsp;* ' . implode('<br>&nbsp;&nbsp;* ', $results[ERR_GENERIC]), count($results[ERR_GENERIC])) . '<br>';
}
}
if (isset($results[ERR_EXIST])) {
if (count($results[ERR_EXIST]) > 0) {
$error_message .= sprintf(__('%s modules already exist') . ': <br>&nbsp;&nbsp;* ' . implode('<br>&nbsp;&nbsp;* ', $results[ERR_EXIST]), count($results[ERR_EXIST])) . '<br>';
}
}
if (!empty($error_message)) {
ui_print_error_message($error_message);
} else {
}
else {
if (empty($success_message)) {
$success_message .= sprintf(__('Modules created succesfully')) . '<br>';
}
@ -703,7 +726,7 @@ if (!$fail) {
$table->cellstyle[1][2] = 'vertical-align: middle;';
// Devices list
$table->data[2][0] .= '<div class="wizard_mode_form wizard_mode_devices">';
$table->data[2][0] = '<div class="wizard_mode_form wizard_mode_devices">';
$table->data[2][0] .= html_print_select ($devices, 'devices', '', '',
'', '', true, true, true, '', false, 'width: 300px;');
$table->data[2][0] .= '</div>';
@ -761,7 +784,7 @@ if (!$fail) {
$table->data[2][1] .= '<div class="wizard_mode_form wizard_mode_snmpdata wizard_mode_snmpdata_arrow clickable">' . html_print_image('images/darrowright.png', true, array('title' => __('Add to modules list'))) . '</div>';
}
$table->data[2][1] .= '<br><br><div class="wizard_mode_delete_arrow clickable">' . html_print_image('images/cross.png', true, array('title' => __('Remove from modules list'))) . '</div>';
$table->cellstyle[2][1] .= 'vertical-align: middle; text-align: center;';
$table->cellstyle[2][1] = 'vertical-align: middle; text-align: center;';
$table->data[2][2] = html_print_select (array (), 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:300px; height: 100%;');
$table->data[2][2] .= html_print_input_hidden('agent', $id_agent, true);

View File

@ -1430,9 +1430,11 @@ function array_key_to_offset($array, $key) {
*
* @return array SNMP result.
*/
function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', $snmp3_auth_user = '',
$snmp3_security_level = '', $snmp3_auth_method = '', $snmp3_auth_pass = '',
$snmp3_privacy_method = '', $snmp3_privacy_pass = '', $quick_print = 0, $base_oid = "", $snmp_port = '') {
function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '',
$snmp3_auth_user = '', $snmp3_security_level = '',
$snmp3_auth_method = '', $snmp3_auth_pass = '',
$snmp3_privacy_method = '', $snmp3_privacy_pass = '',
$quick_print = 0, $base_oid = "", $snmp_port = '') {
global $config;
@ -1480,16 +1482,54 @@ function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', $snmp3_au
$rc = 0;
switch ($snmp_version) {
case '3':
exec ($snmpwalk_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2> ' . $error_redir_dir, $output, $rc);
switch ($snmp3_security_level) {
case "authNoPriv":
$command_str = $snmpwalk_bin .
' -m ALL -v 3' .
' -u ' . escapeshellarg($snmp3_auth_user) .
' -A ' . escapeshellarg($snmp3_auth_pass) .
' -l ' . escapeshellarg($snmp3_security_level) .
' -a ' . escapeshellarg($snmp3_auth_method) .
' ' . escapeshellarg($ip_target) .
' ' . $base_oid .
' 2> ' . $error_redir_dir;
break;
case "noAuthNoPriv":
$command_str = $snmpwalk_bin .
' -m ALL -v 3' .
' -u ' . escapeshellarg($snmp3_auth_user) .
' -l ' . escapeshellarg($snmp3_security_level) .
' ' . escapeshellarg($ip_target) .
' ' . $base_oid .
' 2> ' . $error_redir_dir;
break;
default:
$command_str = $snmpwalk_bin .
' -m ALL -v 3' .
' -u ' . escapeshellarg($snmp3_auth_user) .
' -A ' . escapeshellarg($snmp3_auth_pass) .
' -l ' . escapeshellarg($snmp3_security_level) .
' -a ' . escapeshellarg($snmp3_auth_method) .
' -x ' . escapeshellarg($snmp3_privacy_method) .
' -X ' . escapeshellarg($snmp3_privacy_pass) .
' ' . escapeshellarg($ip_target) .
' ' . $base_oid .
' 2> ' . $error_redir_dir;
break;
}
break;
case '2':
case '2c':
case '1':
default:
exec ($snmpwalk_bin . ' -m ALL -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg($snmp_community) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2> ' . $error_redir_dir, $output, $rc);
$command_str = $snmpwalk_bin . ' -m ALL -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg($snmp_community) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2> ' . $error_redir_dir;
break;
}
//html_debug_print($command_str);
exec($command_str, $output, $rc);
// Parse the output of snmpwalk
$snmpwalk = array();
foreach ($output as $line) {