librenms/check-services.php
Tony Murray d2193f76ca feature: allow scripts to be run from any working directory (#4437)
* feature: allow validate.php to be run from any working directory

* remove redundant realpath() call

* re-add realpath() to remove symbolic links

* realpath() isn't needed...

* chdir() in all php scripts in ./ and ./scripts/

* update-sql.php clearly is not used, as it was broken.

* Change some scripts to executable
Remove extra chdir() call in snmp-scan.php

* Missed console-ui.php
Kind of fixed console-ui.php help output

* Re-add newline
2016-09-14 16:53:04 +01:00

56 lines
1.5 KiB
PHP
Executable File

#!/usr/bin/env php
<?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(__DIR__); // cwd to the directory containing this script
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);
} else {
$debug = false;
// ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
ini_set('log_errors', 0);
// ini_set('error_reporting', 0);
}
if (isset($options['f'])) {
$config['noinfluxdb'] = true;
}
if ($config['noinfluxdb'] !== true && $config['influxdb']['enable'] === true) {
$influxdb = influxdb_connect();
} else {
$influxdb = false;
}
rrdtool_initialize();
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
poll_service($service);
} //end foreach
rrdtool_close();