api: Add severity on list alerts API method (#4436)

* Added severity field from the alert rule to the output of list_alerts.

* I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md.
This commit is contained in:
Dennis Væversted
2016-09-14 15:29:46 +02:00
committed by Neil Lathwood
parent 0351b54fb8
commit 8e4be8bbb2
2 changed files with 2 additions and 1 deletions

View File

@@ -128,6 +128,7 @@ LibreNMS contributors:
- Piotr Jurga <deutor1361@gmail.com> (deutor)
- Jonathon Koyle <jonathon.koyle@gmail.com> (jonathon-k)
- Tamas Szabo <jobs@szatam.com> (szatam)
- Dennis Væversted <dv@zitcom.dk> (dvaeversted)
[1]: http://observium.org/ "Observium web site"
Observium was written by:

View File

@@ -764,7 +764,7 @@ function list_alerts()
array_push($param, $alert_id);
}
$alerts = dbFetchRows("SELECT `D`.`hostname`, `A`.* FROM `alerts` AS `A`, `devices` AS `D` WHERE `D`.`device_id` = `A`.`device_id` AND `A`.`state` IN (?) $sql", $param);
$alerts = dbFetchRows("SELECT `D`.`hostname`, `A`.*, `R`.`severity` FROM `alerts` AS `A`, `devices` AS `D`, `alert_rules` AS `R` WHERE `D`.`device_id` = `A`.`device_id` AND `A`.`rule_id` = `R`.`id` AND `A`.`state` IN (?) $sql", $param);
$total_alerts = count($alerts);
$output = array(
'status' => 'ok',