Commit version 24.12.13800

This commit is contained in:
2025-01-06 17:35:06 -05:00
parent b7f6a79c2c
commit 55d9218816
6133 changed files with 4239740 additions and 1374287 deletions

View File

@ -5,9 +5,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage cli
* @copyright (C) Adam Armstrong
*
*/
@ -15,7 +15,7 @@ chdir(dirname($argv[0]));
$options = getopt("h:p:dqrsV");
include("includes/sql-config.inc.php");
include("includes/observium.inc.php");
include("includes/polling/functions.inc.php");
include("html/includes/functions.inc.php");
@ -23,43 +23,43 @@ include("html/includes/functions.inc.php");
$start = utime();
if (isset($options['V'])) {
print_message(OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION);
exit;
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
exit;
}
if (isset($options['s'])) {
// User has asked for spam. LETS MAKE THE SPAM. (sends alerts even if they have already been sent)
$spam = TRUE;
// User has asked for spam. LETS MAKE THE SPAM. (sends alerts even if they have already been sent)
$spam = TRUE;
}
if (!isset($options['q'])) {
print_cli_banner();
print_cli_banner();
}
if ($options['h'] === "all") {
$where = " ";
$doing = "all";
$where = " ";
$doing = "all";
} elseif ($options['h']) {
$params = [];
if (is_numeric($options['h'])) {
$where = "AND `device_id` = ?";
$doing = $options['h'];
$params[] = $options['h'];
} else {
$where = "AND `hostname` LIKE ?";
$doing = $options['h'];
$params[] = str_replace('*','%', $options['h']);
}
$params = [];
if (is_numeric($options['h'])) {
$where = "AND `device_id` = ?";
$doing = $options['h'];
$params[] = $options['h'];
} else {
$where = "AND `hostname` LIKE ?";
$doing = $options['h'];
$params[] = str_replace('*', '%', $options['h']);
}
}
if (isset($options['p'])) {
print_cli_heading("%WConstrained to poller partition id ".$options['p']);
$where .= ' AND `poller_id` = ?';
$params[] = $options['p'];
print_cli_heading("%WConstrained to poller partition id " . $options['p']);
$where .= ' AND `poller_id` = ?';
$params[] = $options['p'];
}
if (!$where) {
print_message("%n
print_message("%n
USAGE:
$scriptname [-drqV] [-p poller_id] [-h device]
@ -82,10 +82,10 @@ DEBUGGING OPTIONS:
-dd More verbose debugging output.
%rInvalid arguments!%n", 'color');
exit;
exit;
}
print_cli_heading("%WStarting alerter run at ".date("Y-m-d H:i:s"), 0);
print_cli_heading("%WStarting alerter run at " . date("Y-m-d H:i:s"), 0);
$polled_devices = 0;
@ -102,17 +102,17 @@ $_SESSION['userlevel'] = 10;
$query = "SELECT * FROM `devices` WHERE `disabled` = 0 $where ORDER BY `device_id` ASC";
foreach (dbFetchRows($query, $params) as $device) {
humanize_device($device);
humanize_device($device);
process_alerts($device);
if ($config['poller-wrapper']['notifications'] || $spam) {
process_notifications([ 'device_id' => $device['device_id'] ]); // Send all notifications (also for syslog from queue)
}
process_alerts($device);
if ($config['poller-wrapper']['notifications'] || $spam) {
process_notifications(['device_id' => $device['device_id']]); // Send all notifications (also for syslog from queue)
}
dbUpdate([ 'last_alerter' => [ 'NOW()' ] ], 'devices', '`device_id` = ?', [ $device['device_id'] ]);
dbUpdate(['last_alerter' => ['NOW()']], 'devices', '`device_id` = ?', [$device['device_id']]);
}
print_cli_heading("%WFinished alerter run at ".date("Y-m-d H:i:s"), 0);
print_cli_heading("%WFinished alerter run at " . date("Y-m-d H:i:s"), 0);
// EOF