Revert "Refactor datastores to classes (#9179)" (#11273)

This reverts commit e5dad7a64e.
This commit is contained in:
Tony Murray
2020-03-11 07:52:52 -05:00
committed by GitHub
parent e5dad7a64e
commit 7fe895bd08
51 changed files with 1007 additions and 2523 deletions

View File

@@ -28,7 +28,6 @@
use LibreNMS\Config;
use LibreNMS\Alert\AlertRules;
use LibreNMS\Data\Store\Datastore;
$init_modules = ['polling', 'alerts', 'laravel'];
require __DIR__ . '/includes/init.php';
@@ -118,11 +117,44 @@ EOH;
update_os_cache(true); // Force update of OS Cache
}
if (isset($options['r'])) {
Config::set('norrd', true);
}
if (isset($options['f'])) {
Config::set('noinfluxdb', true);
}
if (isset($options['p'])) {
$prometheus = false;
}
if (isset($options['g'])) {
Config::set('nographite', true);
}
if (Config::get('base_url') !== true && Config::get('influxdb.enable') === true) {
$influxdb = influxdb_connect();
} else {
$influxdb = false;
}
if (Config::get('base_url') !== true && Config::get('graphite.enable') === true) {
$graphite = fsockopen(Config::get('graphite.host'), Config::get('graphite.port'));
if ($graphite !== false) {
echo "Connection made to " . Config::get('graphite.host') . " for Graphite support\n";
} else {
echo "Connection to " . Config::get('graphite.host') . " has failed, Graphite support disabled\n";
Config::set('nographite', true);
}
} else {
$graphite = false;
}
// If we've specified modules with -m, use them
$module_override = parse_modules('poller', $options);
set_debug($debug);
$datastore = Datastore::init($options);
rrdtool_initialize();
echo "Starting polling run:\n\n";
$polled_devices = 0;
@@ -154,6 +186,10 @@ $poller_end = microtime(true);
$poller_run = ($poller_end - $poller_start);
$poller_time = substr($poller_run, 0, 5);
if ($graphite !== false) {
fclose($graphite);
}
if ($polled_devices) {
dbInsert(array(
'type' => 'poll',
@@ -173,7 +209,8 @@ if (!isset($options['q'])) {
}
logfile($string);
Datastore::terminate();
rrdtool_close();
// Remove this for testing
// print_r(get_defined_vars());