mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
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:
parent
77c4eefe5c
commit
012ae953a0
@ -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>
|
2014-07-22 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* godmode/agentes/agent_manager.php: fixed to show the QR code image
|
* godmode/agentes/agent_manager.php: fixed to show the QR code image
|
||||||
|
@ -109,6 +109,15 @@ if(!empty($plugin)) {
|
|||||||
|
|
||||||
$fail = false;
|
$fail = false;
|
||||||
|
|
||||||
|
$devices = array();
|
||||||
|
$processes = array();
|
||||||
|
$disks = array();
|
||||||
|
$temperatures = array();
|
||||||
|
|
||||||
|
$arrow = false;
|
||||||
|
|
||||||
|
$other_snmp_data = array();
|
||||||
|
|
||||||
if ($snmpwalk) {
|
if ($snmpwalk) {
|
||||||
// OID Used is for DISKS
|
// OID Used is for DISKS
|
||||||
$snmpis = get_snmpwalk($ip_target, $snmp_version, $snmp_community, $snmp3_auth_user,
|
$snmpis = get_snmpwalk($ip_target, $snmp_version, $snmp_community, $snmp3_auth_user,
|
||||||
@ -120,7 +129,6 @@ if ($snmpwalk) {
|
|||||||
$snmpis = array();
|
$snmpis = array();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$disks = array();
|
|
||||||
// We get here only the interface part of the MIB, not full mib
|
// We get here only the interface part of the MIB, not full mib
|
||||||
foreach($snmpis as $key => $snmp) {
|
foreach($snmpis as $key => $snmp) {
|
||||||
|
|
||||||
@ -153,7 +161,7 @@ if ($snmpwalk) {
|
|||||||
$snmpis = array();
|
$snmpis = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$processes = array();
|
|
||||||
// We get here only the interface part of the MIB, not full mib
|
// We get here only the interface part of the MIB, not full mib
|
||||||
foreach($snmpis as $key => $snmp) {
|
foreach($snmpis as $key => $snmp) {
|
||||||
|
|
||||||
@ -191,7 +199,7 @@ if ($snmpwalk) {
|
|||||||
$snmpis = array();
|
$snmpis = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$temperatures = array();
|
|
||||||
// We get here only the interface part of the MIB, not full mib
|
// We get here only the interface part of the MIB, not full mib
|
||||||
foreach($snmpis as $key => $snmp) {
|
foreach($snmpis as $key => $snmp) {
|
||||||
|
|
||||||
@ -229,7 +237,7 @@ if ($snmpwalk) {
|
|||||||
$snmpis = array();
|
$snmpis = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$devices = array();
|
|
||||||
// We get here only the interface part of the MIB, not full mib
|
// We get here only the interface part of the MIB, not full mib
|
||||||
foreach($snmpis as $key => $snmp) {
|
foreach($snmpis as $key => $snmp) {
|
||||||
|
|
||||||
@ -262,8 +270,15 @@ if ($snmpwalk) {
|
|||||||
|
|
||||||
// Other SNMP Data
|
// Other SNMP Data
|
||||||
$arrow = true;
|
$arrow = true;
|
||||||
|
|
||||||
foreach ($static_snmp_oids as $key => $oid) {
|
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);
|
$result = snmpget($ip_target, $snmp_community, $oid);
|
||||||
|
}
|
||||||
|
|
||||||
if ($result != false) {
|
if ($result != false) {
|
||||||
$other_snmp_data[$key] = $static_snmp_descriptions[$key];
|
$other_snmp_data[$key] = $static_snmp_descriptions[$key];
|
||||||
}
|
}
|
||||||
@ -379,7 +394,8 @@ if ($create_modules) {
|
|||||||
|
|
||||||
if (($name == 'Bytes read') || ($name == 'Bytes written')) {
|
if (($name == 'Bytes read') || ($name == 'Bytes written')) {
|
||||||
$module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp_inc');
|
$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');
|
$module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,19 +584,26 @@ if ($create_modules) {
|
|||||||
$success_message = '';
|
$success_message = '';
|
||||||
$error_message = '';
|
$error_message = '';
|
||||||
|
|
||||||
|
if (isset($results[NOERR])) {
|
||||||
if (count($results[NOERR]) > 0) {
|
if (count($results[NOERR]) > 0) {
|
||||||
$success_message .= sprintf(__('%s modules created succesfully'), count($results[NOERR])) . '<br>';
|
$success_message .= sprintf(__('%s modules created succesfully'), count($results[NOERR])) . '<br>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (isset($results[ERR_GENERIC])) {
|
||||||
if (count($results[ERR_GENERIC]) > 0) {
|
if (count($results[ERR_GENERIC]) > 0) {
|
||||||
$error_message .= sprintf(__('Error creating %s modules') . ': <br> * ' . implode('<br> * ', $results[ERR_GENERIC]), count($results[ERR_GENERIC])) . '<br>';
|
$error_message .= sprintf(__('Error creating %s modules') . ': <br> * ' . implode('<br> * ', $results[ERR_GENERIC]), count($results[ERR_GENERIC])) . '<br>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (isset($results[ERR_EXIST])) {
|
||||||
if (count($results[ERR_EXIST]) > 0) {
|
if (count($results[ERR_EXIST]) > 0) {
|
||||||
$error_message .= sprintf(__('%s modules already exist') . ': <br> * ' . implode('<br> * ', $results[ERR_EXIST]), count($results[ERR_EXIST])) . '<br>';
|
$error_message .= sprintf(__('%s modules already exist') . ': <br> * ' . implode('<br> * ', $results[ERR_EXIST]), count($results[ERR_EXIST])) . '<br>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($error_message)) {
|
if (!empty($error_message)) {
|
||||||
ui_print_error_message($error_message);
|
ui_print_error_message($error_message);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (empty($success_message)) {
|
if (empty($success_message)) {
|
||||||
$success_message .= sprintf(__('Modules created succesfully')) . '<br>';
|
$success_message .= sprintf(__('Modules created succesfully')) . '<br>';
|
||||||
}
|
}
|
||||||
@ -703,7 +726,7 @@ if (!$fail) {
|
|||||||
$table->cellstyle[1][2] = 'vertical-align: middle;';
|
$table->cellstyle[1][2] = 'vertical-align: middle;';
|
||||||
|
|
||||||
// Devices list
|
// 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', '', '',
|
$table->data[2][0] .= html_print_select ($devices, 'devices', '', '',
|
||||||
'', '', true, true, true, '', false, 'width: 300px;');
|
'', '', true, true, true, '', false, 'width: 300px;');
|
||||||
$table->data[2][0] .= '</div>';
|
$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] .= '<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->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_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);
|
$table->data[2][2] .= html_print_input_hidden('agent', $id_agent, true);
|
||||||
|
@ -1430,9 +1430,11 @@ function array_key_to_offset($array, $key) {
|
|||||||
*
|
*
|
||||||
* @return array SNMP result.
|
* @return array SNMP result.
|
||||||
*/
|
*/
|
||||||
function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', $snmp3_auth_user = '',
|
function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '',
|
||||||
$snmp3_security_level = '', $snmp3_auth_method = '', $snmp3_auth_pass = '',
|
$snmp3_auth_user = '', $snmp3_security_level = '',
|
||||||
$snmp3_privacy_method = '', $snmp3_privacy_pass = '', $quick_print = 0, $base_oid = "", $snmp_port = '') {
|
$snmp3_auth_method = '', $snmp3_auth_pass = '',
|
||||||
|
$snmp3_privacy_method = '', $snmp3_privacy_pass = '',
|
||||||
|
$quick_print = 0, $base_oid = "", $snmp_port = '') {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -1480,16 +1482,54 @@ function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', $snmp3_au
|
|||||||
$rc = 0;
|
$rc = 0;
|
||||||
switch ($snmp_version) {
|
switch ($snmp_version) {
|
||||||
case '3':
|
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;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
case '2c':
|
case '2c':
|
||||||
case '1':
|
case '1':
|
||||||
default:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//html_debug_print($command_str);
|
||||||
|
|
||||||
|
exec($command_str, $output, $rc);
|
||||||
|
|
||||||
// Parse the output of snmpwalk
|
// Parse the output of snmpwalk
|
||||||
$snmpwalk = array();
|
$snmpwalk = array();
|
||||||
foreach ($output as $line) {
|
foreach ($output as $line) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user