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> 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

View File

@ -50,65 +50,74 @@ $create_modules = (int) get_parameter("create_modules", 0);
// Get the plugin // Get the plugin
$plugin = db_get_row_sql('SELECT * FROM tplugin WHERE execute LIKE "%/snmp_remote.pl"'); $plugin = db_get_row_sql('SELECT * FROM tplugin WHERE execute LIKE "%/snmp_remote.pl"');
if(empty($plugin)) { if (empty($plugin)) {
ui_print_info_message(array('message' => __('The SNMP remote plugin doesnt seem to be installed') . '. ' . __('It is necessary to use some features') . '.<br><br>' . __('Please, install the SNMP remote plugin (The name of the plugin must be snmp_remote.pl)'), 'no_close' => true)); ui_print_info_message(array('message' => __('The SNMP remote plugin doesnt seem to be installed') . '. ' . __('It is necessary to use some features') . '.<br><br>' . __('Please, install the SNMP remote plugin (The name of the plugin must be snmp_remote.pl)'), 'no_close' => true));
} }
// Define STATIC SNMP data // Define STATIC SNMP data
$static_snmp_descriptions = array( $static_snmp_descriptions = array(
'Load-1' => 'Load Average (Last minute)', 'Load-1' => 'Load Average (Last minute)',
'Load-5' => 'Load Average (Last 5 minutes)', 'Load-5' => 'Load Average (Last 5 minutes)',
'Load-15' => 'Load Average (Last 5 minutes)', 'Load-15' => 'Load Average (Last 5 minutes)',
'memTotalSwap' => 'Total Swap Size configured for the host', 'memTotalSwap' => 'Total Swap Size configured for the host',
'memAvailSwap' => 'Available Swap Space on the host', 'memAvailSwap' => 'Available Swap Space on the host',
'memTotalReal' => 'Total Real/Physical Memory Size on the host', 'memTotalReal' => 'Total Real/Physical Memory Size on the host',
'memAvailReal' => 'Available Real/Physical Memory Space on the host', 'memAvailReal' => 'Available Real/Physical Memory Space on the host',
'memTotalFree' => 'Total Available Memory on the host', 'memTotalFree' => 'Total Available Memory on the host',
//'memShared' => 'Total Shared Memory', //'memShared' => 'Total Shared Memory',
'memCached' => 'Total Cached Memory', 'memCached' => 'Total Cached Memory',
'memBuffer' => 'Total Buffered Memory', 'memBuffer' => 'Total Buffered Memory',
'ssSwapIn' => 'Amount of memory swapped in from disk (kB/s)', 'ssSwapIn' => 'Amount of memory swapped in from disk (kB/s)',
'ssSwapOut' => 'Amount of memory swapped to disk (kB/s)', 'ssSwapOut' => 'Amount of memory swapped to disk (kB/s)',
'ssIORawSent' => 'Number of blocks sent to a block device', 'ssIORawSent' => 'Number of blocks sent to a block device',
'ssIORawReceived' => 'Number of blocks received from a block device', 'ssIORawReceived' => 'Number of blocks received from a block device',
'ssRawInterrupts' => 'Number of interrupts processed', 'ssRawInterrupts' => 'Number of interrupts processed',
'ssRawContexts' => 'Number of context switches', 'ssRawContexts' => 'Number of context switches',
'ssCpuRawUser' => 'user CPU time', 'ssCpuRawUser' => 'user CPU time',
'ssCpuRawSystem' => 'system CPU time', 'ssCpuRawSystem' => 'system CPU time',
'ssCpuRawIdle' => 'idle CPU time' 'ssCpuRawIdle' => 'idle CPU time'
); );
$static_snmp_oids = array( $static_snmp_oids = array(
'Load-1' => '.1.3.6.1.4.1.2021.10.1.5.1', 'Load-1' => '.1.3.6.1.4.1.2021.10.1.5.1',
'Load-5' => '.1.3.6.1.4.1.2021.10.1.5.2', 'Load-5' => '.1.3.6.1.4.1.2021.10.1.5.2',
'Load-15' => '.1.3.6.1.4.1.2021.10.1.5.3', 'Load-15' => '.1.3.6.1.4.1.2021.10.1.5.3',
'memTotalSwap' => '.1.3.6.1.4.1.2021.4.3.0', 'memTotalSwap' => '.1.3.6.1.4.1.2021.4.3.0',
'memAvailSwap' => '.1.3.6.1.4.1.2021.4.4.0', 'memAvailSwap' => '.1.3.6.1.4.1.2021.4.4.0',
'memTotalReal' => '.1.3.6.1.4.1.2021.4.5.0', 'memTotalReal' => '.1.3.6.1.4.1.2021.4.5.0',
'memAvailReal' => '.1.3.6.1.4.1.2021.4.6.0', 'memAvailReal' => '.1.3.6.1.4.1.2021.4.6.0',
'memTotalFree' => '.1.3.6.1.4.1.2021.4.11.0', 'memTotalFree' => '.1.3.6.1.4.1.2021.4.11.0',
//'memShared' => '.1.3.6.1.4.1.2021.4.13', //'memShared' => '.1.3.6.1.4.1.2021.4.13',
'memCached' => '.1.3.6.1.4.1.2021.4.15.0', 'memCached' => '.1.3.6.1.4.1.2021.4.15.0',
'memBuffer' => '.1.3.6.1.4.1.2021.4.14.0', 'memBuffer' => '.1.3.6.1.4.1.2021.4.14.0',
'ssSwapIn' => '.1.3.6.1.4.1.2021.11.3.0', 'ssSwapIn' => '.1.3.6.1.4.1.2021.11.3.0',
'ssSwapOut' => '.1.3.6.1.4.1.2021.11.4.0', 'ssSwapOut' => '.1.3.6.1.4.1.2021.11.4.0',
'ssIORawSent' => '.1.3.6.1.4.1.2021.11.57.0', 'ssIORawSent' => '.1.3.6.1.4.1.2021.11.57.0',
'ssIORawReceived' => '.1.3.6.1.4.1.2021.11.58.0', 'ssIORawReceived' => '.1.3.6.1.4.1.2021.11.58.0',
'ssRawInterrupts' => '.1.3.6.1.4.1.2021.11.59.0', 'ssRawInterrupts' => '.1.3.6.1.4.1.2021.11.59.0',
'ssRawContexts' => '.1.3.6.1.4.1.2021.11.60.0', 'ssRawContexts' => '.1.3.6.1.4.1.2021.11.60.0',
'ssCpuRawUser' => '.1.3.6.1.4.1.2021.11.50.0', 'ssCpuRawUser' => '.1.3.6.1.4.1.2021.11.50.0',
'ssCpuRawSystem' => '.1.3.6.1.4.1.2021.11.52.0', 'ssCpuRawSystem' => '.1.3.6.1.4.1.2021.11.52.0',
'ssCpuRawIdle' => '.1.3.6.1.4.1.2021.11.53.0' 'ssCpuRawIdle' => '.1.3.6.1.4.1.2021.11.53.0'
); );
// Using plugin // Using plugin
if(!empty($plugin)) { if (!empty($plugin)) {
$static_snmp_descriptions['avgCpuLoad'] = 'Average of CPUs Load (%)'; $static_snmp_descriptions['avgCpuLoad'] = 'Average of CPUs Load (%)';
$static_snmp_descriptions['memoryUse'] = 'Memory use (%)'; $static_snmp_descriptions['memoryUse'] = 'Memory use (%)';
} }
$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) {
@ -136,14 +144,14 @@ if ($snmpwalk) {
if (array_key_exists(1,$data)) { if (array_key_exists(1,$data)) {
$disks[$data[1]] = $data[1]; $disks[$data[1]] = $data[1];
} }
else { else {
$disks[$data[0]] = $data[0]; $disks[$data[0]] = $data[0];
} }
} }
// OID Used is for PROCESSES // OID Used is for PROCESSES
$snmpis = get_snmpwalk($ip_target, $snmp_version, $snmp_community, $snmp3_auth_user, $snmpis = get_snmpwalk($ip_target, $snmp_version, $snmp_community, $snmp3_auth_user,
$snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass, $snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass,
@ -152,8 +160,8 @@ if ($snmpwalk) {
if ($snmpis === false) { if ($snmpis === false) {
$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) {
@ -168,12 +176,12 @@ if ($snmpwalk) {
if (array_key_exists(1,$data)) { if (array_key_exists(1,$data)) {
$process_name = str_replace ( "\"" , "" , $data[1]); $process_name = str_replace ( "\"" , "" , $data[1]);
} }
else { else {
$process_name = str_replace ( "\"" , "" , $data[0]); $process_name = str_replace ( "\"" , "" , $data[0]);
} }
$processes[$process_name] = $process_name; $processes[$process_name] = $process_name;
} }
@ -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) {
@ -208,11 +216,11 @@ if ($snmpwalk) {
if ($keydata2[0] == 'lmTempSensorsDevice') { if ($keydata2[0] == 'lmTempSensorsDevice') {
if (array_key_exists(1,$data)) { if (array_key_exists(1,$data)) {
$temperatures[$keydata2[1]] = $data[1]; $temperatures[$keydata2[1]] = $data[1];
} }
else { else {
$temperatures[$keydata2[1]] = $data[0]; $temperatures[$keydata2[1]] = $data[0];
} }
} }
} }
@ -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) {
$result = snmpget($ip_target, $snmp_community, $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);
}
if ($result != false) { if ($result != false) {
$other_snmp_data[$key] = $static_snmp_descriptions[$key]; $other_snmp_data[$key] = $static_snmp_descriptions[$key];
} }
@ -341,33 +356,33 @@ if ($create_modules) {
// DEVICES // DEVICES
$devices_prefix_oids = array( $devices_prefix_oids = array(
'diskIONRead' => '.1.3.6.1.4.1.2021.13.15.1.1.3.', 'diskIONRead' => '.1.3.6.1.4.1.2021.13.15.1.1.3.',
'diskIONWritten' => '.1.3.6.1.4.1.2021.13.15.1.1.4.', 'diskIONWritten' => '.1.3.6.1.4.1.2021.13.15.1.1.4.',
'diskIONReads' => '.1.3.6.1.4.1.2021.13.15.1.1.5.', 'diskIONReads' => '.1.3.6.1.4.1.2021.13.15.1.1.5.',
'diskIONWrites' => '.1.3.6.1.4.1.2021.13.15.1.1.6.' 'diskIONWrites' => '.1.3.6.1.4.1.2021.13.15.1.1.6.'
); );
$devices_prefix_descriptions = array( $devices_prefix_descriptions = array(
'diskIONRead' => 'The number of bytes read from this device since boot', 'diskIONRead' => 'The number of bytes read from this device since boot',
'diskIONWritten' => 'The number of bytes written to this device since boot', 'diskIONWritten' => 'The number of bytes written to this device since boot',
'diskIONReads' => 'The number of read accesses from this device since boot', 'diskIONReads' => 'The number of read accesses from this device since boot',
'diskIONWrites' => 'The number of write accesses from this device since boot' 'diskIONWrites' => 'The number of write accesses from this device since boot'
); );
$results = array(); $results = array();
foreach ($devices as $device) { foreach ($devices as $device) {
$module_values = $common_values; $module_values = $common_values;
// Split module data to get type, name, etc // Split module data to get type, name, etc
$device_exploded = explode($separator, $device); $device_exploded = explode($separator, $device);
$device_name = $device_exploded[0]; $device_name = $device_exploded[0];
$name_exploded = explode('-', $device_name); $name_exploded = explode('-', $device_name);
$name = ltrim(html_entity_decode($name_exploded[1])); $name = ltrim(html_entity_decode($name_exploded[1]));
$device_type = $device_exploded[1]; $device_type = $device_exploded[1];
// Delete type from device id // Delete type from device id
unset($device_exploded[0]); unset($device_exploded[0]);
unset($device_exploded[1]); unset($device_exploded[1]);
@ -376,10 +391,11 @@ if ($create_modules) {
$device_id = implode($separator, $device_exploded); $device_id = implode($separator, $device_exploded);
$module_values['descripcion'] = $devices_prefix_descriptions[$device_type]; $module_values['descripcion'] = $devices_prefix_descriptions[$device_type];
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');
} }
@ -398,7 +414,7 @@ if ($create_modules) {
foreach ($temperatures as $temperature) { foreach ($temperatures as $temperature) {
$module_values = $common_values; $module_values = $common_values;
// Split module data to get type, name, etc // Split module data to get type, name, etc
$temperature_exploded = explode($separator, $temperature); $temperature_exploded = explode($separator, $temperature);
$temperature_name = $temperature_exploded[0]; $temperature_name = $temperature_exploded[0];
@ -434,14 +450,14 @@ if ($create_modules) {
$module_values['descripcion'] = $static_snmp_descriptions[$snmpdata_name]; $module_values['descripcion'] = $static_snmp_descriptions[$snmpdata_name];
$module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp'); $module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp');
//Average use of CPUs is a plugin module //Average use of CPUs is a plugin module
switch ($snmpdata_name) { switch ($snmpdata_name) {
case 'avgCpuLoad': case 'avgCpuLoad':
case 'memoryUse': case 'memoryUse':
$module_values['id_modulo'] = MODULE_PLUGIN; $module_values['id_modulo'] = MODULE_PLUGIN;
$module_values['id_plugin'] = $plugin['id']; $module_values['id_plugin'] = $plugin['id'];
$macros = json_decode($plugin['macros'], true); $macros = json_decode($plugin['macros'], true);
foreach($macros as $k => $macro) { foreach($macros as $k => $macro) {
@ -497,7 +513,7 @@ if ($create_modules) {
$macros = json_decode($plugin['macros'], true); $macros = json_decode($plugin['macros'], true);
foreach($macros as $k => $macro) { foreach ($macros as $k => $macro) {
switch($macro['macro']) { switch($macro['macro']) {
case '_field1_': case '_field1_':
// Field 1 is the IP Address // Field 1 is the IP Address
@ -519,7 +535,7 @@ if ($create_modules) {
unset($module_values['snmp_community']); //snmp_community unset($module_values['snmp_community']); //snmp_community
unset($module_values['ip_target']); //ip_target unset($module_values['ip_target']); //ip_target
unset($module_values['tcp_send']); //snmp_version unset($module_values['tcp_send']); //snmp_version
$result = modules_create_agent_module ($id_agent, io_safe_input($process), $module_values); $result = modules_create_agent_module ($id_agent, io_safe_input($process), $module_values);
$results[$result][] = $process; $results[$result][] = $process;
@ -537,7 +553,7 @@ if ($create_modules) {
$macros = json_decode($plugin['macros'], true); $macros = json_decode($plugin['macros'], true);
foreach($macros as $k => $macro) { foreach ($macros as $k => $macro) {
switch($macro['macro']) { switch($macro['macro']) {
case '_field1_': case '_field1_':
// Field 1 is the IP Address // Field 1 is the IP Address
@ -559,34 +575,41 @@ if ($create_modules) {
unset($module_values['snmp_community']); //snmp_community unset($module_values['snmp_community']); //snmp_community
unset($module_values['ip_target']); //ip_target unset($module_values['ip_target']); //ip_target
unset($module_values['tcp_send']); //snmp_version unset($module_values['tcp_send']); //snmp_version
$result = modules_create_agent_module ($id_agent, io_safe_input($disk), $module_values); $result = modules_create_agent_module ($id_agent, io_safe_input($disk), $module_values);
$results[$result][] = $disk; $results[$result][] = $disk;
} }
$success_message = ''; $success_message = '';
$error_message = ''; $error_message = '';
if (count($results[NOERR]) > 0) { if (isset($results[NOERR])) {
$success_message .= sprintf(__('%s modules created succesfully'), count($results[NOERR])) . '<br>'; if (count($results[NOERR]) > 0) {
$success_message .= sprintf(__('%s modules created succesfully'), count($results[NOERR])) . '<br>';
}
} }
if (count($results[ERR_GENERIC]) > 0) { if (isset($results[ERR_GENERIC])) {
$error_message .= sprintf(__('Error creating %s modules') . ': <br>&nbsp;&nbsp;* ' . implode('<br>&nbsp;&nbsp;* ', $results[ERR_GENERIC]), count($results[ERR_GENERIC])) . '<br>'; 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 (count($results[ERR_EXIST]) > 0) { if (isset($results[ERR_EXIST])) {
$error_message .= sprintf(__('%s modules already exist') . ': <br>&nbsp;&nbsp;* ' . implode('<br>&nbsp;&nbsp;* ', $results[ERR_EXIST]), count($results[ERR_EXIST])) . '<br>'; 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)) { 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>';
} }
ui_print_success_message($success_message); ui_print_success_message($success_message);
} }
} }
} }
echo '<span id ="none_text" style="display: none;">' . __('None') . '</span>'; echo '<span id ="none_text" style="display: none;">' . __('None') . '</span>';
@ -697,17 +720,17 @@ if (!$fail) {
$table->data[1][0] .= html_print_select ($modes, $table->data[1][0] .= html_print_select ($modes,
'snmp_wizard_modes', '', '', '', '', true, false, false); 'snmp_wizard_modes', '', '', '', '', true, false, false);
$table->cellstyle[1][0] = 'vertical-align: middle;'; $table->cellstyle[1][0] = 'vertical-align: middle;';
$table->colspan[1][0] = 2; $table->colspan[1][0] = 2;
$table->data[1][2] = '<b>'.__('Modules').'</b>'; $table->data[1][2] = '<b>'.__('Modules').'</b>';
$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>';
// If SNMP remote plugin is not installed, show an advice // If SNMP remote plugin is not installed, show an advice
if(empty($plugin)) { if(empty($plugin)) {
// Processes list // Processes list
@ -747,7 +770,7 @@ if (!$fail) {
$table->data[2][0] .= '</div>'; $table->data[2][0] .= '</div>';
$table->cellstyle[2][0] = 'vertical-align: top; text-align: center;'; $table->cellstyle[2][0] = 'vertical-align: top; text-align: center;';
// Devices arrow // Devices arrow
$table->data[2][1] = '<div class="wizard_mode_form wizard_mode_devices wizard_mode_devices_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_devices wizard_mode_devices_arrow clickable">' . html_print_image('images/darrowright.png', true, array('title' => __('Add to modules list'))) . '</div>';
// Processes arrow // Processes arrow
@ -761,15 +784,15 @@ 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);
$table->cellstyle[2][2] = 'vertical-align: top; text-align: center;'; $table->cellstyle[2][2] = 'vertical-align: top; text-align: center;';
html_print_table($table); html_print_table($table);
echo "<div style='text-align:right; width:".$table->width."'>"; echo "<div style='text-align:right; width:" . $table->width . "'>";
html_print_submit_button(__('Create modules'), 'create_modules_btn', false, array('class' => 'sub add')); html_print_submit_button(__('Create modules'), 'create_modules_btn', false, array('class' => 'sub add'));
echo "</div>"; echo "</div>";
unset($table); unset($table);
@ -778,7 +801,7 @@ if (!$fail) {
echo "</form>"; echo "</form>";
echo '</div>'; echo '</div>';
} }
ui_require_jquery_file ('pandora.controls'); ui_require_jquery_file ('pandora.controls');
ui_require_jquery_file ('ajaxqueue'); ui_require_jquery_file ('ajaxqueue');
ui_require_jquery_file ('bgiframe'); ui_require_jquery_file ('bgiframe');

View File

@ -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;
@ -1464,7 +1466,7 @@ function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', $snmp3_au
else { else {
$snmpwalk_bin = $config['snmpwalk']; $snmpwalk_bin = $config['snmpwalk'];
} }
switch (PHP_OS) { switch (PHP_OS) {
case "WIN32": case "WIN32":
case "WINNT": case "WINNT":
@ -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) {