"variant" is now required for test data (#12531)
* Stop snmpsim after we done * "variant" is now required for test data
This commit is contained in:
parent
8b105ba162
commit
b851e140dc
|
@ -33,6 +33,12 @@ if (isset($options['snmpsim'])) {
|
|||
exit;
|
||||
}
|
||||
|
||||
if (isset($options['v'])) {
|
||||
$variant = $options['v'];
|
||||
} elseif (isset($options['variant'])) {
|
||||
$variant = $options['variant'];
|
||||
}
|
||||
|
||||
// check for hostname
|
||||
if (isset($options['h'])) {
|
||||
$hostname = $options['h'];
|
||||
|
@ -59,22 +65,28 @@ if (isset($hostname)) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($options['help']) || empty($target_os)) {
|
||||
if (isset($options['help']) || empty($target_os) || ! isset($variant)) {
|
||||
echo 'Script to collect snmp data from devices to be used for testing.
|
||||
Snmp data is saved in tests/snmpsim.
|
||||
|
||||
Usage:
|
||||
You must specify an existing device to collect data from.
|
||||
Required
|
||||
|
||||
Required:
|
||||
-h, --hostname ID, IP, or hostname of the device to collect data from
|
||||
-v, --variant The variant of the OS to use, usually the device model
|
||||
|
||||
Optional:
|
||||
-m, --modules The discovery/poller module(s) to collect data for, comma delimited
|
||||
-n, --prefer-new Prefer new snmprec data over existing data
|
||||
-o, --os Name of the OS to save test data for (only used if device is generic)
|
||||
-v, --variant The variant of the OS to use, usually the device model
|
||||
-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.
|
||||
|
||||
Example:
|
||||
./collect-snmp-data.php -h 192.168.0.1 -v 2960x
|
||||
./collect-snmp-data.php -h 127.0.0.1 -v freeradius -m freeradius
|
||||
';
|
||||
exit;
|
||||
}
|
||||
|
@ -92,13 +104,6 @@ if (isset($options['m'])) {
|
|||
$modules = [];
|
||||
}
|
||||
|
||||
$variant = '';
|
||||
if (isset($options['v'])) {
|
||||
$variant = $options['v'];
|
||||
} elseif (isset($options['variant'])) {
|
||||
$variant = $options['variant'];
|
||||
}
|
||||
|
||||
if (Str::contains($variant, '_')) {
|
||||
exit("Variant name cannot contain an underscore (_).\n");
|
||||
}
|
||||
|
|
|
@ -38,20 +38,28 @@ if (isset($options['snmpsim'])) {
|
|||
|
||||
if (isset($options['h'])
|
||||
|| isset($options['help'])
|
||||
|| (isset($options['o']) || isset($options['os'])) && ! (isset($options['v']) || isset($options['variant']))
|
||||
|| ! (isset($options['o']) || isset($options['os']) || isset($options['m']) || isset($options['modules']))
|
||||
) {
|
||||
echo "Script to update test data. Database data is saved in tests/data.
|
||||
|
||||
Usage:
|
||||
You must specify a valid OS and/or module(s).
|
||||
You must specify a valid OS (and variant) and/or module(s).
|
||||
|
||||
Required:
|
||||
-o, --os Name of the OS to save test data for
|
||||
-v, --variant The variant of the OS to use, usually the device model
|
||||
|
||||
Optional:
|
||||
-m, --modules The discovery/poller module(s) to collect data for, comma delimited
|
||||
-n, --no-save Don't save database entries, print them out instead
|
||||
-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.
|
||||
|
||||
Example:
|
||||
./save-test-data.php -o ios -v 2960x
|
||||
./save-test-data.php -o linux -v freeradius -m freeradius
|
||||
";
|
||||
exit;
|
||||
}
|
||||
|
@ -138,3 +146,5 @@ try {
|
|||
} catch (InvalidModuleException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
$snmpsim->stop();
|
||||
|
|
Loading…
Reference in New Issue