Rewrite smokeping script to be an lnms command (#11585)

* Rewrite smokeping script to be an lnms command

* Add a default number of probes for smokeping

* Formatting fixes

* Refactor to simplify a couple of methods

* Fix a name collision when using more than 60 threads

* Simplify

* First pass at documentation

A few climate fixes too.

I'm a little dubious about the + LibreNMS fix - it could be included
in /etc/smokeping/config if it is really needed, but it sounds like
(looking at git blame) it's needed for if the script generates a broken
configuration file.

I'm thinking we should just not generate broken config.

* Improve testability and add some tests

* Load laravel to make translations available

* Second pass at documentation

* Fix brace

* Extend the device factory to include the type

Also adds a device group fake I created before I realised I didn't need it

* Mimic gen_smokeping.php a little more closely

* Update tests to properly verify old and new behaviour against each other

* Replace gen_smokeping with a wrapper

* Don't double whitespace

Render does this automatically.
Explicitly order by hostname too.

* Make faker less likely to generate duplicates

I tried adding a unique constraint here, but it didn't have the
intended effect.

Extending the hostname like this seems to work fine - I tried
generating 10 million hosts and got no duplicates, compared to
duplicates appearing with as few as 100 hosts without this
 change.

A true fix would be to add an 'fqdn' fake upstream.

* Make the tests more robust

* Assorted bug fixes

* Style corrections

* Handle 'generic' devices

* Fix an issue that came up during rebase

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Adam Bishop
2020-09-18 06:04:54 +01:00
committed by GitHub
parent 5e63c34d19
commit bbdb1a2a5d
9 changed files with 1070 additions and 236 deletions

View File

@@ -41,7 +41,29 @@ return [
'os' => 'Specific OS to run tests on. Implies unit, --db, --snmpsim',
'quiet' => 'Hide output unless there is an error',
'snmpsim' => 'Use snmpsim for unit tests',
]
],
],
'smokeping:generate' => [
'args-nonsense' => 'Use one of --probes and --targets',
'config-insufficient' => 'In order to generate a smokeping configuration, you must have set "smokeping.probes", "fping", and "fping6" set in your configuration',
'dns-fail' => 'was not resolvable and was omitted from the configuration',
'description' => 'Generate a configuration suitable for use with smokeping',
'header-first' => 'This file was automatically generated by "lnms smokeping:generate',
'header-second' => 'Local changes may be overwritten without notice or backups being taken',
'header-third' => 'For more information see https://docs.librenms.org/Extensions/Smokeping/"',
'no-devices' => 'No eligible devices found - devices must not be disabled.',
'no-probes' => 'At least one probe is required.',
'options' => [
'probes' => 'Generate probe list - used for splitting the smokeping configuration into multiple files. Conflicts with "--targets"',
'targets' => 'Generate the target list - used for splitting the smokeping configuration into multiple files. Conflicts with "--probes"',
'no-header' => 'Don\'t add the boilerplate comment to the start of the generated file',
'no-dns' => 'Skip DNS lookups',
'single-process' => 'Only use a single process for smokeping',
'compat' => '[deprecated] Mimic the behaviour of gen_smokeping.php',
],
],
'translation:generate' => [
'description' => 'Generate updated json language files for use in the web frontend',
],
'user:add' => [
'description' => 'Add a local user, you can only log in with this user if auth is set to mysql',
@@ -58,8 +80,5 @@ return [
'password-request' => "Please enter the user's password",
'success' => 'Successfully added user: :username',
'wrong-auth' => 'Warning! You will not be able to log in with this user because you are not using MySQL auth',
],
'translation:generate' => [
'description' => 'Generate updated json language files for use in the web frontend',
]
];