From 92270410edaa467d71e841699805d6411ce047fa Mon Sep 17 00:00:00 2001 From: emanuele-f Date: Wed, 19 Sep 2018 17:45:20 +0200 Subject: [PATCH] Cache if_stats_ndpi timeseries query results --- scripts/lua/if_stats_ndpi.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/lua/if_stats_ndpi.lua b/scripts/lua/if_stats_ndpi.lua index 341f8ecc35..5c9881fe63 100644 --- a/scripts/lua/if_stats_ndpi.lua +++ b/scripts/lua/if_stats_ndpi.lua @@ -77,7 +77,17 @@ for _k in pairsByKeys(vals, asc) do end end - if(ts_utils.exists("iface:ndpi", {ifid=ifid, protocol=k})) then + local proto_cache_key = "ntopng.cache.has_ndpi_" .. ifid.."_".. k + local has_ndpi_proto = ntop.getCache(proto_cache_key) + + if has_ndpi_proto ~= "1" then + if ts_utils.exists("iface:ndpi", {ifid=ifid, protocol=k}) then + has_ndpi_proto = "1" + ntop.setCache(proto_cache_key, "1", 300) + end + end + + if(has_ndpi_proto == "1") then if(not(json_format)) then print("".. k .." "..formatBreed(ifstats["ndpi"][k]["breed"]).."") else