mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add feature to capture a full snmprec (#12706)
This commit is contained in:
@@ -140,9 +140,18 @@ class ModuleTestHelper
|
||||
$this->json_file = $path;
|
||||
}
|
||||
|
||||
public function captureFromDevice($device_id, $write = true, $prefer_new = false)
|
||||
public function captureFromDevice($device_id, $write = true, $prefer_new = false, $full = false)
|
||||
{
|
||||
$snmp_oids = $this->collectOids($device_id);
|
||||
if ($full) {
|
||||
$snmp_oids[] = [
|
||||
'oid' => '.',
|
||||
'method' => 'walk',
|
||||
'mib' => null,
|
||||
'mibdir' => null,
|
||||
];
|
||||
} else {
|
||||
$snmp_oids = $this->collectOids($device_id);
|
||||
}
|
||||
|
||||
$device = device_by_id_cache($device_id, true);
|
||||
DeviceCache::setPrimary($device_id);
|
||||
|
||||
@@ -23,6 +23,7 @@ $options = getopt(
|
||||
'file:',
|
||||
'debug',
|
||||
'snmpsim',
|
||||
'full',
|
||||
'help',
|
||||
]
|
||||
);
|
||||
@@ -83,10 +84,14 @@ Optional:
|
||||
-f, --file Save data to file instead of the standard location
|
||||
-d, --debug Enable debug output
|
||||
--snmpsim Run snmpsimd.py using the collected data for manual testing.
|
||||
--full Walk the whole device (default: only used OIDs)
|
||||
Useful when adding device support when you don\'t have access to it directly,
|
||||
or when discovery/poller causes errors when capturing normally.
|
||||
Do NOT use this to submit test data!
|
||||
|
||||
Example:
|
||||
Examples:
|
||||
./collect-snmp-data.php -h 192.168.0.1 -v 2960x
|
||||
./collect-snmp-data.php -h 127.0.0.1 -v freeradius -m freeradius
|
||||
./collect-snmp-data.php -h 127.0.0.1 -v freeradius -m applications
|
||||
';
|
||||
exit;
|
||||
}
|
||||
@@ -125,10 +130,11 @@ try {
|
||||
}
|
||||
|
||||
$prefer_new_snmprec = isset($options['n']) || isset($options['prefer-new']);
|
||||
$full = isset($options['full']);
|
||||
|
||||
echo 'Capturing Data: ';
|
||||
\LibreNMS\Util\OS::updateCache(true); // Force update of OS Cache
|
||||
$capture->captureFromDevice($device['device_id'], true, $prefer_new_snmprec);
|
||||
$capture->captureFromDevice($device['device_id'], true, $prefer_new_snmprec, $full);
|
||||
} catch (InvalidModuleException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ Optional:
|
||||
-d, --debug Enable debug output
|
||||
--snmpsim Run snmpsimd.py using the collected data for manual testing.
|
||||
|
||||
Example:
|
||||
Examples:
|
||||
./save-test-data.php -o ios -v 2960x
|
||||
./save-test-data.php -o linux -v freeradius -m freeradius
|
||||
./save-test-data.php -o linux -v freeradius -m applications
|
||||
";
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user