mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-02 08:50:12 +00:00
add select inside active monitoring for am pools
This commit is contained in:
parent
e71f1a3e45
commit
1a72ce58c8
10 changed files with 278 additions and 154 deletions
|
|
@ -12,6 +12,8 @@ local plugins_utils = require("plugins_utils")
|
|||
local template = require("template_utils")
|
||||
local json = require("dkjson")
|
||||
local active_monitoring_utils = plugins_utils.loadModule("active_monitoring", "am_utils")
|
||||
local active_monitoring_pools = require("active_monitoring_pools")
|
||||
local am_pool = active_monitoring_pools:create()
|
||||
|
||||
local graph_utils = require("graph_utils")
|
||||
local alert_utils = require("alert_utils")
|
||||
|
|
@ -160,6 +162,7 @@ if(page == "overview") then
|
|||
</div>]])
|
||||
|
||||
print(plugins_utils.renderTemplate("active_monitoring", "am_edit_host_modal.html", {
|
||||
pools = am_pool,
|
||||
dialog = {
|
||||
measurement = i18n("active_monitoring_stats.measurement"),
|
||||
edit_measurement_select = generate_select("select-edit-measurement", "measurement", true, false, {}, "measurement-select"),
|
||||
|
|
@ -180,20 +183,21 @@ if(page == "overview") then
|
|||
}))
|
||||
|
||||
print(plugins_utils.renderTemplate("active_monitoring", "am_add_host_modal.html", {
|
||||
pools = am_pool,
|
||||
dialog = {
|
||||
add_record = i18n("active_monitoring_stats.add_record"),
|
||||
measurement = i18n("active_monitoring_stats.measurement"),
|
||||
add_measurement_select = generate_select("select-add-measurement", "measurement", true, false, {}, "measurement-select"),
|
||||
am_host = i18n("about.host_callbacks_directory"),
|
||||
periodicity = i18n("internals.periodicity"),
|
||||
add_granularity_select = generate_select("select-add-granularity", "granularity", true, false, {}, "measurement-granularity"),
|
||||
threshold = i18n("threshold"),
|
||||
notes = i18n("notes"),
|
||||
note_icmp = i18n("active_monitoring_stats.am_note_icmp"),
|
||||
note_http = i18n("active_monitoring_stats.am_note_http"),
|
||||
note_alert = i18n("active_monitoring_stats.note_alert"),
|
||||
cancel = i18n("cancel"),
|
||||
add = i18n("add"),
|
||||
add_record = i18n("active_monitoring_stats.add_record"),
|
||||
measurement = i18n("active_monitoring_stats.measurement"),
|
||||
add_measurement_select = generate_select("select-add-measurement", "measurement", true, false, {}, "measurement-select"),
|
||||
am_host = i18n("about.host_callbacks_directory"),
|
||||
periodicity = i18n("internals.periodicity"),
|
||||
add_granularity_select = generate_select("select-add-granularity", "granularity", true, false, {}, "measurement-granularity"),
|
||||
threshold = i18n("threshold"),
|
||||
notes = i18n("notes"),
|
||||
note_icmp = i18n("active_monitoring_stats.am_note_icmp"),
|
||||
note_http = i18n("active_monitoring_stats.am_note_http"),
|
||||
note_alert = i18n("active_monitoring_stats.note_alert"),
|
||||
cancel = i18n("cancel"),
|
||||
add = i18n("add"),
|
||||
}
|
||||
}))
|
||||
|
||||
|
|
@ -250,6 +254,7 @@ if(page == "overview") then
|
|||
i18n.search = "]].. i18n("search") ..[[:";
|
||||
i18n.msec = "]] .. i18n("active_monitoring_stats.msec") .. [[";
|
||||
i18n.edit = "]] .. i18n("users.edit") .. [[";
|
||||
i18n.success = "]] .. i18n("success") .. [[";
|
||||
i18n.delete = "]] .. i18n("delete") .. [[";
|
||||
i18n.expired_csrf = "]] .. i18n("expired_csrf") .. [[";
|
||||
i18n.all = "]] .. i18n("all") .. [[";
|
||||
|
|
|
|||
|
|
@ -4,12 +4,16 @@
|
|||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/pools/?.lua;" .. package.path
|
||||
|
||||
require "lua_utils"
|
||||
local json = require("dkjson")
|
||||
local plugins_utils = require("plugins_utils")
|
||||
local am_utils = plugins_utils.loadModule("active_monitoring", "am_utils")
|
||||
|
||||
local active_monitoring_pools = require("active_monitoring_pools")
|
||||
local am_pool = active_monitoring_pools:create()
|
||||
|
||||
sendHTTPContentTypeHeader('application/json')
|
||||
|
||||
-- ################################################
|
||||
|
|
@ -17,6 +21,7 @@ sendHTTPContentTypeHeader('application/json')
|
|||
local action = _POST["action"]
|
||||
local host = _POST["am_host"]
|
||||
local measurement = _POST["measurement"]
|
||||
local pool = _POST["pool"]
|
||||
|
||||
local rv = {}
|
||||
|
||||
|
|
@ -91,8 +96,11 @@ if(action == "add") then
|
|||
end
|
||||
|
||||
am_utils.addHost(host, measurement, threshold, granularity)
|
||||
am_pool:bind_member(measurement.. "@".. host, pool)
|
||||
rv.message = i18n("active_monitoring_stats.host_add_ok", {host=url})
|
||||
|
||||
elseif(action == "edit") then
|
||||
|
||||
local existing
|
||||
local threshold = _POST["threshold"]
|
||||
local granularity = _POST["granularity"]
|
||||
|
|
@ -135,8 +143,8 @@ elseif(action == "edit") then
|
|||
existing = am_utils.hasHost(host, measurement)
|
||||
|
||||
if existing then
|
||||
reportError(i18n("active_monitoring_stats.host_exists", {host=url}))
|
||||
return
|
||||
reportError(i18n("active_monitoring_stats.host_exists", {host=url}))
|
||||
return
|
||||
end
|
||||
|
||||
am_utils.deleteHost(old_am_host, old_measurement) -- also calls discardHostTimeseries
|
||||
|
|
@ -146,6 +154,8 @@ elseif(action == "edit") then
|
|||
am_utils.editHost(host, measurement, threshold, granularity)
|
||||
end
|
||||
|
||||
am_pool:bind_member(measurement.. "@".. host, pool)
|
||||
|
||||
rv.message = i18n("active_monitoring_stats.host_edit_ok", {host=old_url})
|
||||
elseif(action == "delete") then
|
||||
local url = am_utils.formatAmHost(host, measurement)
|
||||
|
|
@ -155,6 +165,12 @@ elseif(action == "delete") then
|
|||
reportError(i18n("active_monitoring_stats.host_not_exists", {host=url}))
|
||||
end
|
||||
|
||||
-- unbind the host
|
||||
local result = am_pool:bind_member(measurement.. "@".. host, pool)
|
||||
if not result then
|
||||
|
||||
end
|
||||
|
||||
am_utils.deleteHost(host, measurement)
|
||||
rv.message = i18n("active_monitoring_stats.host_delete_ok", {host=url})
|
||||
else
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/pools/?.lua;" .. package.path
|
||||
|
||||
require "lua_utils"
|
||||
local format_utils = require("format_utils")
|
||||
|
|
@ -11,6 +12,9 @@ local json = require("dkjson")
|
|||
local plugins_utils = require("plugins_utils")
|
||||
local am_utils = plugins_utils.loadModule("active_monitoring", "am_utils")
|
||||
|
||||
local active_monitoring_pools = require("active_monitoring_pools")
|
||||
local am_pool = active_monitoring_pools:create()
|
||||
local assigned_members = am_pool:get_assigned_members()
|
||||
sendHTTPContentTypeHeader('application/json')
|
||||
|
||||
local charts_available = plugins_utils.timeseriesCreationEnabled()
|
||||
|
|
@ -40,7 +44,7 @@ for key, am_host in pairs(am_hosts) do
|
|||
local column_jitter = ""
|
||||
local last_update = am_utils.getLastAmUpdate(am_host.host, am_host.measurement)
|
||||
local alerted = 0
|
||||
|
||||
|
||||
if(last_update ~= nil) then
|
||||
local tdiff = os.time() - last_update.when
|
||||
|
||||
|
|
@ -75,7 +79,14 @@ for key, am_host in pairs(am_hosts) do
|
|||
|
||||
column_jitter = string.format("%.1f / %.1f %s", last_update.mean, last_update.jitter, jitter_unit)
|
||||
end
|
||||
|
||||
|
||||
local pool_id
|
||||
if assigned_members[am_host.measurement .. "@" .. am_host.host] ~= nil then
|
||||
pool_id = assigned_members[am_host.measurement .. "@" .. am_host.host].pool_id
|
||||
else
|
||||
pool_id = am_pool.DEFAULT_POOL_ID
|
||||
end
|
||||
|
||||
res[#res + 1] = {
|
||||
key = key,
|
||||
url = am_host.label,
|
||||
|
|
@ -93,6 +104,7 @@ for key, am_host in pairs(am_hosts) do
|
|||
hours = hourly_stats or {},
|
||||
unit = i18n(m_info.i18n_unit) or m_info.i18n_unit,
|
||||
jitter = column_jitter,
|
||||
pool = pool_id
|
||||
}
|
||||
|
||||
::continue::
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue