2013-05-24 Ramon Novoa <rnovoa@artica.es>

* include/functions.php: Merged from 4.0 branch. Removed calls
	  to PHP's SNMP functions.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8205 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2013-05-24 09:58:44 +00:00
parent 25a17874c8
commit 4e5fdd7e0a
2 changed files with 42 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2013-05-24 Ramon Novoa <rnovoa@artica.es>
* include/functions.php: Merged from 4.0 branch. Removed calls
to PHP's SNMP functions.
2013-05-23 Miguel de Dios <miguel.dedios@artica.es>
* include/javascript/pandora_visual_console.js,

View File

@ -1271,29 +1271,58 @@ function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', $snmp3_au
$snmp3_security_level = '', $snmp3_auth_method = '', $snmp3_auth_pass = '',
$snmp3_privacy_method = '', $snmp3_privacy_pass = '', $quick_print = 0, $base_oid = "", $snmp_port = '') {
snmp_set_quick_print ($quick_print);
// Note: quick_print is ignored
// Fix for snmp port
if (!empty($snmp_port)){
$ip_target = $ip_target.':'.$snmp_port;
}
// Escape the base OID
if ($base_oid != "") {
$base_oid = escapeshellarg ($base_oid);
}
if ($config['snmpwalk'] == '') {
switch (PHP_OS) {
case "FreeBSD":
$snmpwalk_bin = '/usr/local/bin/snmpwalk';
break;
case "NetBSD":
$snmpwalk_bin = '/usr/pkg/bin/snmpwalk';
break;
default:
$snmpwalk_bin = 'snmpwalk';
break;
}
}
else {
$snmpwalk_bin = $config['snmpwalk'];
}
$output = array();
$rc = 0;
switch ($snmp_version) {
case '3':
$snmpwalk = @snmp3_real_walk ($ip_target, $snmp3_auth_user,
$snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass,
$snmp3_privacy_method, $snmp3_privacy_pass, $base_oid);
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>/dev/null', $output, $rc);
break;
case '2':
case '2c':
$snmpwalk = @snmp2_real_walk ($ip_target, $snmp_community, $base_oid);
break;
case '1':
default:
$snmpwalk = @snmprealwalk($ip_target, $snmp_community, $base_oid);
exec ($snmpwalk_bin . ' -m ALL -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg($snmp_community) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2>/dev/null', $output, $rc);
break;
}
// Parse the output of snmpwalk
foreach ($output as $line) {
// Separate the OID from the value
$full_oid = explode (' = ', $line);
if (isset ($full_oid[1])) {
$snmpwalk[$full_oid[0]] = $full_oid[1];
}ge
}
return $snmpwalk;
}