2016-03-22 07:35:39 +10:00
|
|
|
#!/usr/bin/env php
|
2016-03-21 16:47:11 +10:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* LibreNMS module to poll Nagios Services
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
|
|
|
|
*
|
|
|
|
* 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. Please see LICENSE.txt at the top level of
|
|
|
|
* the source code distribution for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
chdir(dirname($argv[0]));
|
|
|
|
|
|
|
|
require 'includes/defaults.inc.php';
|
|
|
|
require 'config.php';
|
|
|
|
require 'includes/definitions.inc.php';
|
|
|
|
require 'includes/functions.php';
|
|
|
|
|
|
|
|
$options = getopt('d::');
|
|
|
|
if (isset($options['d'])) {
|
|
|
|
echo "DEBUG!\n";
|
|
|
|
$debug = true;
|
|
|
|
ini_set('display_errors', 1);
|
|
|
|
ini_set('display_startup_errors', 1);
|
|
|
|
ini_set('log_errors', 1);
|
|
|
|
ini_set('error_reporting', 1);
|
2016-08-11 17:08:44 +10:00
|
|
|
} else {
|
2016-03-21 16:47:11 +10:00
|
|
|
$debug = false;
|
|
|
|
// ini_set('display_errors', 0);
|
|
|
|
ini_set('display_startup_errors', 0);
|
|
|
|
ini_set('log_errors', 0);
|
|
|
|
// ini_set('error_reporting', 0);
|
|
|
|
}
|
|
|
|
|
2016-08-11 17:08:44 +10:00
|
|
|
if (isset($options['f'])) {
|
|
|
|
$config['noinfluxdb'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($config['noinfluxdb'] !== true && $config['influxdb']['enable'] === true) {
|
|
|
|
$influxdb = influxdb_connect();
|
|
|
|
} else {
|
|
|
|
$influxdb = false;
|
|
|
|
}
|
|
|
|
|
2016-08-22 10:32:05 -05:00
|
|
|
rrdtool_initialize();
|
2016-03-22 07:35:39 +10:00
|
|
|
|
2016-03-21 16:47:11 +10:00
|
|
|
foreach (dbFetchRows('SELECT * FROM `devices` AS D, `services` AS S WHERE S.device_id = D.device_id ORDER by D.device_id DESC') as $service) {
|
|
|
|
// Run the polling function
|
2016-03-22 07:35:39 +10:00
|
|
|
poll_service($service);
|
2016-03-21 16:47:11 +10:00
|
|
|
|
|
|
|
} //end foreach
|
2016-08-26 01:50:29 -05:00
|
|
|
rrdtool_close();
|