--
-- (C) 2014-26 - ntop.org
--
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
local format_utils = require "format_utils"
-- ########################################################
local os_data_utils = {}
-- ########################################################
local now = os.time()
function os_data_utils.os2record(ifId, os)
local discover = require("discover_utils")
-- Get from redis the throughput type bps or pps
local throughput_type = getThroughputType()
local record = {}
record["key"] = tostring(os["os"])
if os["os"] ~= nil then
record["column_id"] = " "
record["column_id"] = record["column_id"] .. discover.getOsAndIcon(os["os"]) ..""
end
if((os["num_alerts"] ~= nil) and (os["num_alerts"] > 0)) then
record["column_alerts"] = ""..formatValue(value["num_alerts"])..""
else
record["column_alerts"] = ""
end
record["column_chart"] = ""
if areOSTimeseriesEnabled(ifId) then
record["column_chart"] = ''
end
record["column_hosts"] = format_high_num_value_for_tables(os, "num_hosts")
record["column_since"] = secondsToTime(now - os["seen.first"] + 1)
local sent2rcvd = round((os["bytes.sent"] * 100) / (os["bytes.sent"] + os["bytes.rcvd"]), 0)
record["column_breakdown"] = format_utils.createBreakdown(sent2rcvd, 100 - sent2rcvd, "Sent", "Rcvd")
if(throughput_type == "pps") then
record["column_thpt"] = pktsToSize(os["throughput_pps"])
else
record["column_thpt"] = bitsToSize(8*os["throughput_bps"])
end
record["column_traffic"] = bytesToSize(os["bytes.sent"] + os["bytes.rcvd"])
return record
end
-- ########################################################
return os_data_utils