mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Visualization/Retrieval of Host Alerts
This commit is contained in:
parent
031c4c4d4f
commit
dda9a2ea64
7 changed files with 336 additions and 136 deletions
|
|
@ -637,3 +637,122 @@ function scanAlerts(granularity, ifname)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- #################################
|
||||
|
||||
function drawAlertTables(num_alerts, num_engaged_alerts, get_alerts_data_url_params)
|
||||
local alert_items = {}
|
||||
|
||||
if num_engaged_alerts > 0 then
|
||||
alert_items[#alert_items + 1] = {["label"] = "Currently Engaged Alerts", ["div-id"] = "table-engaged-alerts", ["status"] = "engaged", ["date"] = "First Seen"}
|
||||
end
|
||||
|
||||
if num_alerts > 0 then
|
||||
alert_items[#alert_items +1] = {["label"] = "Alerts History", ["div-id"] = "table-alerts-history", ["status"] = "historical", ["date"] = "Time"}
|
||||
end
|
||||
|
||||
local url_extra_params = ""
|
||||
if type(get_alerts_data_url_params) == "table" then
|
||||
for k, v in pairs(get_alerts_data_url_params) do
|
||||
url_extra_params = url_extra_params.."&"..k.."="..v
|
||||
end
|
||||
end
|
||||
|
||||
for k, t in ipairs(alert_items) do
|
||||
print [[
|
||||
<div id="]] print(t["div-id"]) print[["></div>
|
||||
<script>
|
||||
$("#]] print(t["div-id"]) print[[").datatable({
|
||||
url: "]]
|
||||
print (ntop.getHttpPrefix())
|
||||
print [[/lua/get_alerts_data.lua?alerts_impl=new&alert_status=]] print(t["status"]..url_extra_params) print[[",
|
||||
showPagination: true,
|
||||
]]
|
||||
|
||||
if(_GET["currentPage"] ~= nil) then print("currentPage: ".._GET["currentPage"]..",\n") end
|
||||
if(_GET["perPage"] ~= nil) then print("perPage: ".._GET["perPage"]..",\n") end
|
||||
|
||||
print [[
|
||||
title: "]] print(t["label"]) print[[",
|
||||
columns: [
|
||||
{
|
||||
title: "Action",
|
||||
field: "column_key",
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
title: "]] print(t["date"]) print[[",
|
||||
field: "column_date",
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Severity",
|
||||
field: "column_severity",
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
title: "Type",
|
||||
field: "column_type",
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
title: "Description",
|
||||
field: "column_msg",
|
||||
css: {
|
||||
textAlign: 'left'
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
</script>
|
||||
]]
|
||||
|
||||
end
|
||||
|
||||
if (num_alerts > 0 or num_engaged_alerts > 0) then
|
||||
print [[
|
||||
|
||||
<a href="#myModal" role="button" class="btn btn-default" data-toggle="modal"><i type="submit" class="fa fa-trash-o"></i> Purge All Alerts</button></a>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
|
||||
<h3 id="myModalLabel">Confirm Action</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Do you really want to purge all alerts?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
||||
<form class=form-inline style="margin-bottom: 0px;" method=get action="#"><input type=hidden name=id_to_delete value="__all__">
|
||||
]]
|
||||
|
||||
print('<input id="csrf" name="csrf" type="hidden" value="'..ntop.getRandomCSRFValue()..'" />\n')
|
||||
|
||||
print [[
|
||||
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
<button class="btn btn-primary" type="submit">Purge All</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
]]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue