Reviewed learning window regarding contacted peers

This commit is contained in:
Matteo Biscosi 2021-03-01 17:22:52 +01:00
parent 2bb5be7bf6
commit 85d2f7def3
4 changed files with 12 additions and 15 deletions

View file

@ -30,7 +30,7 @@ class LocalHostStats: public HostStats {
ICMPstats *icmp;
FrequentStringItems *top_sites;
/* nextPeriodicUpdate done every 5 min */
time_t nextPeriodicUpdate, nextContactsUpdate;
time_t nextPeriodicUpdate;
u_int32_t num_contacts_as_cli, num_contacts_as_srv;
/* Estimate of the number of critical servers used by this host */

View file

@ -305,7 +305,6 @@
#define CONST_EST_MAX_HOSTS 200000
#define MIN_HOST_RESOLUTION_FREQUENCY 60 /* 1 min */
#define HOST_SITES_REFRESH 300 /* 5 min */
#define HOST_CONTACTS_REFRESH 60 /* 1 min */
#define HOST_SITES_TOP_NUMBER 10
#define HOST_MAX_SERIALIZED_LEN 1048576 /* 1MB, use only when allocating memory in the heap */
#define POOL_MAX_SERIALIZED_LEN 32768 /* bytes */
@ -318,7 +317,7 @@
#define HOST_IS_NTP_SERVER 0x03
#define HOST_IS_SMTP_SERVER 0x04
#define MAX_DYNAMIC_STATS_VALUES 10
#define MAX_DYNAMIC_STATS_VALUES 12
// ICMP
#ifndef ICMP_TIMESTAMP

View file

@ -539,7 +539,7 @@ local lang = {
["too_many_hosts_details"] = "Do you want to double the current number of maximum Hosts?",
["too_many_hosts_err"] = "Unable to double max Hosts. Please tune -X from the configuration file and restart ntopng.",
["too_many_hosts_title"] = "Double Max Hosts",
["unknow_contacted_peers"] = "Too many Peers contacted by %{host} %{host_category}. Unable to retrive the values.",
["unknown_contacted_peers"] = "Too many Peers contacted by %{host} %{host_category}.",
["x_alerts"] = "%{num} alerts",
},
["alerts_dashboard"] = {
@ -570,8 +570,8 @@ local lang = {
["client_and_server_countries_blacklisted"] = "Client country %{cli_country} and server country %{srv_country} are blacklisted",
["client_country_blacklisted"] = "Client country %{country} is blacklisted",
["connection_issues"] = "TCP Issues",
["contacted_peers_description"] = "Trigger an alert when the number of clients or servers contacted exceeds the threshold",
["contacted_peers_title"] = "Peer Contacts Alert",
["contacted_peers_description"] = "Trigger an alert when an host contacts an unexpected number of clients or servers",
["contacted_peers_title"] = "Contacted Peers Alert",
["critical"] = "Critical",
["custom_period"] = "Custom Period",
["debug"] = "Debug",

View file

@ -32,7 +32,7 @@ LocalHostStats::LocalHostStats(Host *_host) : HostStats(_host) {
icmp = new (std::nothrow) ICMPstats();
peers = new (std::nothrow) PeerStats(MAX_DYNAMIC_STATS_VALUES /* 10 as default */ );
nextPeriodicUpdate = 0, nextContactsUpdate = time(NULL)+HOST_CONTACTS_REFRESH;
nextPeriodicUpdate = 0;
num_contacts_as_cli = num_contacts_as_srv = 0;
current_cycle = 0;
@ -70,7 +70,7 @@ LocalHostStats::LocalHostStats(LocalHostStats &s) : HostStats(s) {
dns = s.getDNSstats() ? new (std::nothrow) DnsStats(*s.getDNSstats()) : NULL;
http = NULL;
icmp = NULL;
nextPeriodicUpdate = 0, nextContactsUpdate = time(NULL)+HOST_CONTACTS_REFRESH;
nextPeriodicUpdate = 0;
num_contacts_as_cli = num_contacts_as_srv = 0;
/* hll init, 8 bits -> 256 bytes per LocalHost */
@ -143,15 +143,13 @@ void LocalHostStats::updateStats(const struct timeval *tv) {
if(dns) dns->updateStats(tv);
if(icmp) icmp->updateStats(tv);
if(http) http->updateStats(tv);
if(tv->tv_sec >= nextContactsUpdate) {
updateHostContacts();
nextContactsUpdate = tv->tv_sec+HOST_CONTACTS_REFRESH;
}
if(tv->tv_sec >= nextPeriodicUpdate) {
/* hll visited sites update */
updateContactedHostsBehaviour();
/* Contacted peers update */
updateHostContacts();
/* Top Sites update */
if(top_sites && ntop->getPrefs()->are_top_talkers_enabled()) {
@ -268,9 +266,9 @@ void LocalHostStats::luaPeers(lua_State *vm) {
if (peers->getSlidingWinStatus()) {
lua_newtable(vm);
lua_push_int32_table_entry(vm, "contacted_peers_in_last_min_as_cli",
lua_push_int32_table_entry(vm, "contacted_peers_in_last_5mins_as_cli",
num_contacts_as_cli);
lua_push_int32_table_entry(vm, "contacted_peers_in_last_min_as_srv",
lua_push_int32_table_entry(vm, "contacted_peers_in_last_5mins_as_srv",
num_contacts_as_srv);
lua_push_int32_table_entry(vm, "sliding_avg_peers_as_client",
peers->getCliSlidingEstimate());