From 9da3efe09102ab1c85316c07e03c232d86f93cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Rosiak?= Date: Sun, 19 Apr 2015 13:28:58 +0200 Subject: [PATCH] Include hostname in alerts_list API command - Include hostname in alerts_list API command - Update API docs --- doc/API/API-Docs.md | 1 + html/includes/api_functions.inc.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/API/API-Docs.md b/doc/API/API-Docs.md index 3e3bdabb8..ddd786d54 100644 --- a/doc/API/API-Docs.md +++ b/doc/API/API-Docs.md @@ -487,6 +487,7 @@ Output: "count": 7, "alerts": [ { + "hostname": "localhost", "id": "1", "device_id": "1", "rule_id": "1", diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index 161ce3fc8..019b073c2 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -536,7 +536,7 @@ function list_alerts() { $sql = "AND id=?"; array_push($param,$alert_id); } - $alerts = dbFetchRows("SELECT * FROM `alerts` WHERE `state` IN (?) $sql",$param); + $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); $total_alerts = count($alerts); $output = array("status" => "ok", "err-msg" => '', "count" => $total_alerts, "alerts" => $alerts); $app->response->setStatus('200');