Fix missed alert function renames (#10452)

This commit is contained in:
Tony Murray 2019-07-18 11:05:43 -05:00 committed by GitHub
parent 851994cfb8
commit 36a5da00ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 12 deletions

View File

@ -236,7 +236,7 @@ class RunAlerts
{ {
global $rulescache; global $rulescache;
if (empty($rulescache[$device_id]) || !isset($rulescache[$device_id])) { if (empty($rulescache[$device_id]) || !isset($rulescache[$device_id])) {
foreach (AlertUtil::GetRules($device_id) as $chk) { foreach (AlertUtil::getRules($device_id) as $chk) {
$rulescache[$device_id][$chk['id']] = true; $rulescache[$device_id][$chk['id']] = true;
} }
} }
@ -266,7 +266,7 @@ class RunAlerts
} }
$sql = $alert['query']; $sql = $alert['query'];
$qry = dbFetchRows($sql, array($alert['device_id'])); $qry = dbFetchRows($sql, array($alert['device_id']));
$alert['details']['contacts'] = AlertUtil::GetContacts($qry); $alert['details']['contacts'] = AlertUtil::getContacts($qry);
} }
$obj = $this->describeAlert($alert); $obj = $this->describeAlert($alert);
@ -449,7 +449,7 @@ class RunAlerts
$noacc = false; $noacc = false;
} }
if (AlertUtil::IsMaintenance($alert['device_id']) > 0) { if (AlertUtil::isMaintenance($alert['device_id']) > 0) {
$noiss = true; $noiss = true;
$noacc = true; $noacc = true;
} }

View File

@ -9,6 +9,7 @@
use App\Models\Device; use App\Models\Device;
use App\Models\DeviceGroup; use App\Models\DeviceGroup;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
use LibreNMS\Alert\AlertDB;
use LibreNMS\Config; use LibreNMS\Config;
use LibreNMS\Exceptions\LockException; use LibreNMS\Exceptions\LockException;
use LibreNMS\Util\MemcacheLock; use LibreNMS\Util\MemcacheLock;
@ -275,7 +276,7 @@ if ($options['f'] === 'refresh_alert_rules') {
foreach ($rules as $rule) { foreach ($rules as $rule) {
$rule_options = json_decode($rule['extra'], true); $rule_options = json_decode($rule['extra'], true);
if ($rule_options['options']['override_query'] !== 'on') { if ($rule_options['options']['override_query'] !== 'on') {
$data['query'] = GenSQL($rule['rule'], $rule['builder']); $data['query'] = AlertDB::genSQL($rule['rule'], $rule['builder']);
if (!empty($data['query'])) { if (!empty($data['query'])) {
dbUpdate($data, 'alert_rules', 'id=?', array($rule['id'])); dbUpdate($data, 'alert_rules', 'id=?', array($rule['id']));
unset($data); unset($data);

View File

@ -23,10 +23,10 @@
*/ */
use Auth; use Auth;
use LibreNMS\Alert\AlertUtil;
use LibreNMS\Config; use LibreNMS\Config;
$install_dir = Config::get('install_dir'); $install_dir = Config::get('install_dir');
require_once $install_dir . '/includes/alerts.inc.php';
if (Config::get('map.engine', 'leaflet') == 'leaflet') { if (Config::get('map.engine', 'leaflet') == 'leaflet') {
$temp_output = ' $temp_output = '
@ -110,7 +110,7 @@ var greenMarker = L.AwesomeMarkers.icon({
$map_devices['lng'] = $tmp_loc['lng']; $map_devices['lng'] = $tmp_loc['lng'];
} }
if ($map_devices['status'] == 0) { if ($map_devices['status'] == 0) {
if (IsMaintenance($map_devices['device_id'])) { if (AlertUtil::isMaintenance($map_devices['device_id'])) {
if ($show_status == 0) { // Don't show icon if only down devices should be shown if ($show_status == 0) { // Don't show icon if only down devices should be shown
continue; continue;
} else { } else {

View File

@ -12,6 +12,7 @@
* the source code distribution for details. * the source code distribution for details.
*/ */
use LibreNMS\Alert\AlertDB;
use LibreNMS\Authentication\LegacyAuth; use LibreNMS\Authentication\LegacyAuth;
if (!LegacyAuth::user()->hasGlobalAdmin()) { if (!LegacyAuth::user()->hasGlobalAdmin()) {
@ -20,7 +21,7 @@ if (!LegacyAuth::user()->hasGlobalAdmin()) {
$rule = implode(' ', $_POST['rules']); $rule = implode(' ', $_POST['rules']);
$rule = rtrim($rule, '&|'); $rule = rtrim($rule, '&|');
$query = GenSQL($rule); $query = AlertDB::genSQL($rule);
$alert_id = $_POST['alert_id']; $alert_id = $_POST['alert_id'];
$count = mres($_POST['count']); $count = mres($_POST['count']);
$delay = mres($_POST['delay']); $delay = mres($_POST['delay']);

View File

@ -12,6 +12,7 @@
* the source code distribution for details. * the source code distribution for details.
*/ */
use LibreNMS\Alert\AlertUtil;
use LibreNMS\Authentication\LegacyAuth; use LibreNMS\Authentication\LegacyAuth;
use LibreNMS\Config; use LibreNMS\Config;
@ -23,9 +24,8 @@ if (!LegacyAuth::user()->hasGlobalAdmin()) {
$transport = $vars['transport'] ?: null; $transport = $vars['transport'] ?: null;
$transport_id = $vars['transport_id'] ?: null; $transport_id = $vars['transport_id'] ?: null;
require_once Config::get('install_dir') . '/includes/alerts.inc.php';
$tmp = array(dbFetchRow('select device_id,hostname,sysDescr,version,hardware,location_id from devices order by device_id asc limit 1')); $tmp = array(dbFetchRow('select device_id,hostname,sysDescr,version,hardware,location_id from devices order by device_id asc limit 1'));
$tmp['contacts'] = GetContacts($tmp); $tmp['contacts'] = AlertUtil::getContacts($tmp);
$obj = array( $obj = array(
"hostname" => $tmp[0]['hostname'], "hostname" => $tmp[0]['hostname'],
"device_id" => $tmp[0]['device_id'], "device_id" => $tmp[0]['device_id'],

View File

@ -23,6 +23,8 @@
* @author Neil Lathwood <neil@lathwood.co.uk> * @author Neil Lathwood <neil@lathwood.co.uk>
*/ */
use LibreNMS\Alert\AlertDB;
use LibreNMS\Alert\AlertUtil;
use LibreNMS\Alerting\QueryBuilderParser; use LibreNMS\Alerting\QueryBuilderParser;
use LibreNMS\Authentication\LegacyAuth; use LibreNMS\Authentication\LegacyAuth;
@ -39,12 +41,12 @@ switch ($type) {
$filename = "alerts-$hostname.txt"; $filename = "alerts-$hostname.txt";
$device_id = getidbyname($hostname); $device_id = getidbyname($hostname);
$device = device_by_id_cache($device_id); $device = device_by_id_cache($device_id);
$rules = GetRules($device_id); $rules = AlertUtil::getRules($device_id);
$output = ''; $output = '';
$results = array(); $results = array();
foreach ($rules as $rule) { foreach ($rules as $rule) {
if (empty($rule['query'])) { if (empty($rule['query'])) {
$rule['query'] = GenSQL($rule['rule'], $rule['builder']); $rule['query'] = AlertDB::genSQL($rule['rule'], $rule['builder']);
} }
$sql = $rule['query']; $sql = $rule['query'];
$qry = dbFetchRow($sql, array($device_id)); $qry = dbFetchRow($sql, array($device_id));
@ -74,7 +76,7 @@ switch ($type) {
$output .= 'Rule match: ' . $response . PHP_EOL . PHP_EOL; $output .= 'Rule match: ' . $response . PHP_EOL . PHP_EOL;
} }
if (\LibreNMS\Config::get('alert.transports.mail') === true) { if (\LibreNMS\Config::get('alert.transports.mail') === true) {
$contacts = GetContacts($results); $contacts = AlertUtil::getContacts($results);
if (count($contacts) > 0) { if (count($contacts) > 0) {
$output .= 'Found ' . count($contacts) . ' contacts to send alerts to.' . PHP_EOL; $output .= 'Found ' . count($contacts) . ' contacts to send alerts to.' . PHP_EOL;
} }