librenms-librenms/scripts/gen_smokeping.php

37 lines
1.1 KiB
PHP
Raw Normal View History

2015-10-04 19:15:12 +02:00
#!/usr/bin/env php
<?php
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>
2020-09-18 06:04:54 +01:00
/**
* gen_smokeping.php
*
* Legacy wrapper for generating smokeping configurations
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
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>
2020-09-18 06:04:54 +01:00
*
* @link https://www.librenms.org
2021-09-10 20:09:53 +02:00
*
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>
2020-09-18 06:04:54 +01:00
* @copyright 2020 Adam Bishop
* @author Adam Bishop <adam@omega.org.uk>
*/
if (php_sapi_name() === 'cli') {
$init_modules = [];
require realpath(__DIR__ . '/..') . '/includes/init.php';
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>
2020-09-18 06:04:54 +01:00
$return = \Artisan::call('smokeping:generate --targets --no-header --no-dns --single-process --compat');
echo \Artisan::Output();
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>
2020-09-18 06:04:54 +01:00
exit($return);
}
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>
2020-09-18 06:04:54 +01:00
exit();