-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct snmp function usage #12714
Correct snmp function usage #12714
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ function prep_snmp_setting($device, $setting) | |
}//end prep_snmp_setting() | ||
|
||
/** | ||
* @param $device | ||
* @param array $device | ||
* @return array will contain a list of mib dirs | ||
*/ | ||
function get_mib_dir($device) | ||
|
@@ -78,13 +78,14 @@ function get_mib_dir($device) | |
* If $mibdir is empty '', return an empty string | ||
* | ||
* @param string $mibdir should be the name of the directory within \LibreNMS\Config::get('mib_dir') | ||
* @param array $device | ||
* @param array|null $device | ||
* @return string The option string starting with -M | ||
*/ | ||
function mibdir($mibdir = null, $device = []) | ||
function mibdir($mibdir = null, $device = null) | ||
{ | ||
$dirs = is_array($device) ? get_mib_dir($device) : []; | ||
|
||
$base = Config::get('mib_dir'); | ||
$dirs = get_mib_dir($device); | ||
$dirs[] = "$base/$mibdir"; | ||
|
||
// make sure base directory is included first | ||
|
@@ -779,10 +780,10 @@ function snmp_gen_auth(&$device, $cmd = [], $strIndexing = null) | |
* @param string $mib | ||
* @param string $mibdir the mib directory (relative to the LibreNMS mibs directory) | ||
* @param array|string $options Options to pass to snmptranslate | ||
* @param array $device | ||
* @param array|null $device | ||
* @return string | ||
*/ | ||
function snmp_translate($oid, $mib = 'ALL', $mibdir = null, $options = null, $device = []) | ||
function snmp_translate($oid, $mib = 'ALL', $mibdir = null, $options = null, $device = null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should only accept array. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No that's what we wanted to get away from. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Best would ofc be to send the device object instead... One day. One day. |
||
{ | ||
$cmd = [Config::get('snmptranslate', 'snmptranslate'), '-M', mibdir($mibdir, $device), '-m', $mib]; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this doesn't break/fixes the tests because we don't have any real test data for it :)