2013-05-20 Junichi Satoh <junichi@rworks.jp>

* include/functions_snmp_browser.php: Added default binary path for
	snmpget and snmpwalk in *BSD. The paths can also be defined specific
	ones by using config['snmpget'] and config['snmpwalk'].



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8155 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
jsatoh 2013-05-20 00:55:36 +00:00
parent b011826210
commit 78fe77dbc4
2 changed files with 40 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2013-05-20 Junichi Satoh <junichi@rworks.jp>
* include/functions_snmp_browser.php: Added default binary path for
snmpget and snmpwalk in *BSD. The paths can also be defined specific
ones by using config['snmpget'] and config['snmpwalk'].
2013-05-17 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_ui.php: added first version of function

View File

@ -146,8 +146,24 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.') {
}
// Call snmpwalk
if ($config['snmpwalk'] == '') {
switch (PHP_OS) {
case "FreeBSD":
$snmpwalk_bin = '/usr/local/bin/snmpwalk';
break;
case "NetBSD":
$snmpwalk_bin = '/usr/pkg/bin/snmpwalk';
braek;
default:
$snmpwalk_bin = 'snmpwalk';
break;
}
}
else {
$snmpwalk_bin = $config['snmpwalk'];
}
$oid_tree = array('__LEAVES__' => array());
exec ('snmpwalk -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v 1 ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid), $output, $rc);
exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v 1 ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid), $output, $rc);
//if ($rc != 0) {
// return __('No data');
@ -228,7 +244,23 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid) {
}
$oid_data['oid'] = $target_oid;
exec ('snmpget -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -v1 -c ' . escapeshellarg($community) . " " . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid), $output, $rc);
if ($config['snmpget'] == '') {
switch (PHP_OS) {
case "FreeBSD":
$snmpget_bin = '/usr/local/bin/snmpget';
break;
case "NetBSD":
$snmpget_bin = '/usr/pkg/bin/snmpget';
braek;
default:
$snmpget_bin = 'snmpget';
break;
}
}
else {
$snmpget_bin = $config['snmpget'];
}
exec ($snmpget_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -v1 -c ' . escapeshellarg($community) . " " . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid), $output, $rc);
if ($rc != 0) {
return $oid_data;
}