Skip to content

Commit

Permalink
Update to Observium CE 23.9
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed Sep 21, 2023
1 parent 9b871b7 commit 096c8e6
Show file tree
Hide file tree
Showing 4,106 changed files with 2,180,022 additions and 1,028,227 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Observium CE 23.1
Observium CE 23.9
396 changes: 203 additions & 193 deletions add_device.php

Large diffs are not rendered by default.

77 changes: 38 additions & 39 deletions adduser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,52 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/

chdir(dirname($argv[0]));

$options = getopt("d");
if (isset($options['d'])) { array_shift($argv); } // for compatibility
if (isset($options['d'])) {
array_shift($argv);
} // for compatibility

include("includes/sql-config.inc.php");
include("includes/observium.inc.php");

print_message("%g".OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION."\n%WAdd User%n\n", 'color');
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WAdd User%n\n", 'color');

if (OBS_DEBUG) { print_versions(); }
if (OBS_DEBUG) {
print_versions();
}

$auth_file = $config['html_dir'].'/includes/authentication/' . $config['auth_mechanism'] . '.inc.php';
if (is_file($auth_file))
{
include($auth_file);
$auth_file = $config['html_dir'] . '/includes/authentication/' . $config['auth_mechanism'] . '.inc.php';
if (is_file($auth_file)) {
// Include base auth functions calls
include_once($config['html_dir'] . '/includes/sessions.inc.php');
include_once($config['html_dir'] . '/includes/authenticate-functions.inc.php');

// Include base auth functions calls
include($config['html_dir'].'/includes/authenticate-functions.inc.php');
include_once($auth_file);
} else {
print_error("ERROR: no valid auth_mechanism defined.");
exit();
print_error("ERROR: no valid auth_mechanism defined.");
exit();
}

if (auth_usermanagement())
{
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]))
{
if (!auth_user_exists($argv[1]))
{
if (adduser($argv[1], $argv[2], $argv[3], @$argv[4]))
{
print_success("User ".$argv[1]." added successfully.");
} else {
print_error("User ".$argv[1]." creation failed!");
}
if (auth_usermanagement()) {
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3])) {
if (!auth_user_exists($argv[1])) {
if (adduser($argv[1], $argv[2], $argv[3], @$argv[4])) {
print_success("User " . $argv[1] . " added successfully.");
} else {
print_error("User " . $argv[1] . " creation failed!");
}
} else {
print_warning("User " . $argv[1] . " already exists!");
}
} else {
print_warning("User ".$argv[1]." already exists!");
}
} else {
$msg = "%n
$msg = "%n
USAGE:
$scriptname <username> <password> <level 1-10> [email]
Expand All @@ -59,16 +59,15 @@
USER LEVELS:" . PHP_EOL;

foreach($GLOBALS['config']['user_level'] as $level => $entry)
{
$msg .= ' '.$level.' - %W'.$entry['name'].'%n ('.$entry['subtext'].')'. PHP_EOL;
}
$msg .= PHP_EOL . "%rInvalid arguments!%n";
foreach ($GLOBALS['config']['user_level'] as $level => $entry) {
$msg .= ' ' . $level . ' - %W' . $entry['name'] . '%n (' . $entry['subtext'] . ')' . PHP_EOL;
}
$msg .= PHP_EOL . "%rInvalid arguments!%n";

print_message($msg, 'color', FALSE);
}
print_message($msg, 'color', FALSE);
}
} else {
print_error("Auth module does not allow adding users!");
print_error("Auth module does not allow adding users!");
}

// EOF
68 changes: 34 additions & 34 deletions alerter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,61 @@
*
* 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) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/

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");

$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]
Expand All @@ -82,10 +82,10 @@
-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;

Expand All @@ -102,17 +102,17 @@
$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
55 changes: 28 additions & 27 deletions check-errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,52 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/

chdir(dirname($argv[0]));

$options = getopt("d");
if (isset($options['d'])) { array_shift($argv); } // for compatibility
if (isset($options['d'])) {
array_shift($argv);
} // for compatibility

include("includes/sql-config.inc.php");
include("includes/observium.inc.php");

// Check all of our interface RRD files for errors

if ($argv[1]) { $where = "AND `port_id` = ?"; $params = array($argv[1]); }
if ($argv[1]) {
$where = "AND `port_id` = ?";
$params = [$argv[1]];
}

$i = 0;
$i = 0;
$errored = 0;

foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where", $params) as $interface)
{
$errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta'];
if ($errors > '1')
{
$errored[] = generate_device_link($interface, $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta']);
$errored++;
}
$i++;
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where", $params) as $interface) {
$errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta'];
if ($errors > '1') {
$errored[] = generate_device_link($interface, $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta']);
$errored++;
}
$i++;
}

echo("Checked $i interfaces\n");

if (is_array($errored))
{ // If there are errored ports
$i = 0;
$msg = "Interfaces with errors : \n\n";
if (is_array($errored)) { // If there are errored ports
$i = 0;
$msg = "Interfaces with errors : \n\n";

foreach ($errored as $int)
{
$msg .= "$int\n"; // Add a line to the report email warning about them
$i++;
}
// Send the alert email
//notify($device, "Observium detected errors on $i interface" . ($i != 1 ? 's' : ''), $msg);
foreach ($errored as $int) {
$msg .= "$int\n"; // Add a line to the report email warning about them
$i++;
}
// Send the alert email
//notify($device, "Observium detected errors on $i interface" . ($i != 1 ? 's' : ''), $msg);
}

echo("$errored interfaces with errors over the past 5 minutes.\n");
Expand Down
26 changes: 13 additions & 13 deletions config_to_json.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/

Expand All @@ -17,18 +17,18 @@
// Get options before definitions!
$options = getopt("o:d");

require_once("includes/sql-config.inc.php");
require_once("includes/observium.inc.php");

if (is_cli()) {
if (isset($options['o'])) {
// get filtered options
get_config_json($options['o']);
//print_vars($options);
} else {
// All config options
get_config_json();
//print(safe_json_encode($config));
}
if (isset($options['o'])) {
// get filtered options
get_config_json($options['o']);
//print_vars($options);
} else {
// All config options
get_config_json();
//print(safe_json_encode($config));
}
}

// EOF
Loading

0 comments on commit 096c8e6

Please sign in to comment.