From 36a5da00ca7596626ffed8d295ea687e395a9070 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Thu, 18 Jul 2019 11:05:43 -0500 Subject: [PATCH] Fix missed alert function renames (#10452) --- LibreNMS/Alert/RunAlerts.php | 6 +++--- daily.php | 3 ++- includes/html/common/worldmap.inc.php | 4 ++-- includes/html/forms/create-alert-item.inc.php | 3 ++- includes/html/forms/test-transport.inc.php | 4 ++-- includes/html/output/query.inc.php | 8 +++++--- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/LibreNMS/Alert/RunAlerts.php b/LibreNMS/Alert/RunAlerts.php index 66287b0e54..8b78eeb544 100644 --- a/LibreNMS/Alert/RunAlerts.php +++ b/LibreNMS/Alert/RunAlerts.php @@ -236,7 +236,7 @@ class RunAlerts { global $rulescache; 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; } } @@ -266,7 +266,7 @@ class RunAlerts } $sql = $alert['query']; $qry = dbFetchRows($sql, array($alert['device_id'])); - $alert['details']['contacts'] = AlertUtil::GetContacts($qry); + $alert['details']['contacts'] = AlertUtil::getContacts($qry); } $obj = $this->describeAlert($alert); @@ -449,7 +449,7 @@ class RunAlerts $noacc = false; } - if (AlertUtil::IsMaintenance($alert['device_id']) > 0) { + if (AlertUtil::isMaintenance($alert['device_id']) > 0) { $noiss = true; $noacc = true; } diff --git a/daily.php b/daily.php index e267f1d54d..2929c99ebe 100644 --- a/daily.php +++ b/daily.php @@ -9,6 +9,7 @@ use App\Models\Device; use App\Models\DeviceGroup; use Illuminate\Database\Eloquent\Collection; +use LibreNMS\Alert\AlertDB; use LibreNMS\Config; use LibreNMS\Exceptions\LockException; use LibreNMS\Util\MemcacheLock; @@ -275,7 +276,7 @@ if ($options['f'] === 'refresh_alert_rules') { foreach ($rules as $rule) { $rule_options = json_decode($rule['extra'], true); 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'])) { dbUpdate($data, 'alert_rules', 'id=?', array($rule['id'])); unset($data); diff --git a/includes/html/common/worldmap.inc.php b/includes/html/common/worldmap.inc.php index b6f8d44fbc..00bb082ac8 100644 --- a/includes/html/common/worldmap.inc.php +++ b/includes/html/common/worldmap.inc.php @@ -23,10 +23,10 @@ */ use Auth; +use LibreNMS\Alert\AlertUtil; use LibreNMS\Config; $install_dir = Config::get('install_dir'); -require_once $install_dir . '/includes/alerts.inc.php'; if (Config::get('map.engine', 'leaflet') == 'leaflet') { $temp_output = ' @@ -110,7 +110,7 @@ var greenMarker = L.AwesomeMarkers.icon({ $map_devices['lng'] = $tmp_loc['lng']; } 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 continue; } else { diff --git a/includes/html/forms/create-alert-item.inc.php b/includes/html/forms/create-alert-item.inc.php index 0da17c6758..5051b8bf30 100644 --- a/includes/html/forms/create-alert-item.inc.php +++ b/includes/html/forms/create-alert-item.inc.php @@ -12,6 +12,7 @@ * the source code distribution for details. */ +use LibreNMS\Alert\AlertDB; use LibreNMS\Authentication\LegacyAuth; if (!LegacyAuth::user()->hasGlobalAdmin()) { @@ -20,7 +21,7 @@ if (!LegacyAuth::user()->hasGlobalAdmin()) { $rule = implode(' ', $_POST['rules']); $rule = rtrim($rule, '&|'); -$query = GenSQL($rule); +$query = AlertDB::genSQL($rule); $alert_id = $_POST['alert_id']; $count = mres($_POST['count']); $delay = mres($_POST['delay']); diff --git a/includes/html/forms/test-transport.inc.php b/includes/html/forms/test-transport.inc.php index 26674ebcac..34f672de84 100644 --- a/includes/html/forms/test-transport.inc.php +++ b/includes/html/forms/test-transport.inc.php @@ -12,6 +12,7 @@ * the source code distribution for details. */ +use LibreNMS\Alert\AlertUtil; use LibreNMS\Authentication\LegacyAuth; use LibreNMS\Config; @@ -23,9 +24,8 @@ if (!LegacyAuth::user()->hasGlobalAdmin()) { $transport = $vars['transport'] ?: 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['contacts'] = GetContacts($tmp); +$tmp['contacts'] = AlertUtil::getContacts($tmp); $obj = array( "hostname" => $tmp[0]['hostname'], "device_id" => $tmp[0]['device_id'], diff --git a/includes/html/output/query.inc.php b/includes/html/output/query.inc.php index a2c35f84f8..1a3d54eb28 100644 --- a/includes/html/output/query.inc.php +++ b/includes/html/output/query.inc.php @@ -23,6 +23,8 @@ * @author Neil Lathwood */ +use LibreNMS\Alert\AlertDB; +use LibreNMS\Alert\AlertUtil; use LibreNMS\Alerting\QueryBuilderParser; use LibreNMS\Authentication\LegacyAuth; @@ -39,12 +41,12 @@ switch ($type) { $filename = "alerts-$hostname.txt"; $device_id = getidbyname($hostname); $device = device_by_id_cache($device_id); - $rules = GetRules($device_id); + $rules = AlertUtil::getRules($device_id); $output = ''; $results = array(); foreach ($rules as $rule) { if (empty($rule['query'])) { - $rule['query'] = GenSQL($rule['rule'], $rule['builder']); + $rule['query'] = AlertDB::genSQL($rule['rule'], $rule['builder']); } $sql = $rule['query']; $qry = dbFetchRow($sql, array($device_id)); @@ -74,7 +76,7 @@ switch ($type) { $output .= 'Rule match: ' . $response . PHP_EOL . PHP_EOL; } if (\LibreNMS\Config::get('alert.transports.mail') === true) { - $contacts = GetContacts($results); + $contacts = AlertUtil::getContacts($results); if (count($contacts) > 0) { $output .= 'Found ' . count($contacts) . ' contacts to send alerts to.' . PHP_EOL; }