mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 19:15:03 +00:00
Updates host pools stats also in community mode
This commit is contained in:
parent
d1c5275302
commit
54473f7883
4 changed files with 32 additions and 35 deletions
|
|
@ -221,11 +221,9 @@ class Flow : public GenericHashEntry {
|
|||
inline bool isProto(u_int16_t p) const { return(((ndpiDetectedProtocol.master_protocol == p)
|
||||
|| (ndpiDetectedProtocol.app_protocol == p))
|
||||
? true : false); }
|
||||
#ifdef NTOPNG_PRO
|
||||
void update_pools_stats(const struct timeval *tv,
|
||||
u_int64_t diff_sent_packets, u_int64_t diff_sent_bytes,
|
||||
u_int64_t diff_rcvd_packets, u_int64_t diff_rcvd_bytes);
|
||||
#endif
|
||||
bool triggerAlerts() const;
|
||||
void dumpFlowAlert();
|
||||
void updateJA3();
|
||||
|
|
|
|||
12
src/Flow.cpp
12
src/Flow.cpp
|
|
@ -1185,10 +1185,10 @@ void Flow::update_hosts_stats(struct timeval *tv, bool dump_alert) {
|
|||
if(trafficProfile)
|
||||
trafficProfile->incBytes(diff_sent_bytes+diff_rcvd_bytes);
|
||||
#endif
|
||||
|
||||
update_pools_stats(tv, diff_sent_packets, diff_sent_bytes, diff_rcvd_packets, diff_rcvd_bytes);
|
||||
}
|
||||
#endif
|
||||
update_pools_stats(tv, diff_sent_packets, diff_sent_bytes, diff_rcvd_packets, diff_rcvd_bytes);
|
||||
|
||||
if(iface && iface->hasSeenVlanTaggedPackets() && (vl = iface->getVlan(vlanId, false, false /* NOT an inline call */))) {
|
||||
/* Note: source and destination hosts have, by definition, the same VLAN so the increase is done only one time. */
|
||||
/* Note: vl will never be null as we're in a flow with that vlan. Hence, it is guaranteed that at least
|
||||
|
|
@ -1471,8 +1471,6 @@ void Flow::update_hosts_stats(struct timeval *tv, bool dump_alert) {
|
|||
|
||||
/* *************************************** */
|
||||
|
||||
#ifdef NTOPNG_PRO
|
||||
|
||||
void Flow::update_pools_stats(const struct timeval *tv,
|
||||
u_int64_t diff_sent_packets, u_int64_t diff_sent_bytes,
|
||||
u_int64_t diff_rcvd_packets, u_int64_t diff_rcvd_bytes) {
|
||||
|
|
@ -1502,6 +1500,7 @@ void Flow::update_pools_stats(const struct timeval *tv,
|
|||
hp->incPoolStats(tv->tv_sec, cli_host_pool_id, ndpiDetectedProtocol.master_protocol, category_id,
|
||||
diff_sent_packets, diff_sent_bytes, diff_rcvd_packets, diff_rcvd_bytes);
|
||||
|
||||
#ifdef NTOPNG_PRO
|
||||
/* Per host quota-enforcement stats */
|
||||
if(hp->enforceQuotasPerPoolMember(cli_host_pool_id)) {
|
||||
cli_host->incQuotaEnforcementStats(tv->tv_sec, ndpiDetectedProtocol.master_protocol,
|
||||
|
|
@ -1510,6 +1509,7 @@ void Flow::update_pools_stats(const struct timeval *tv,
|
|||
diff_sent_packets, diff_sent_bytes, diff_rcvd_packets, diff_rcvd_bytes);
|
||||
cli_host->incQuotaEnforcementCategoryStats(tv->tv_sec, category_id, diff_sent_bytes, diff_rcvd_bytes);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Server host */
|
||||
|
|
@ -1532,6 +1532,7 @@ void Flow::update_pools_stats(const struct timeval *tv,
|
|||
}
|
||||
|
||||
/* When quotas have to be enforced per pool member, stats must be increased even if cli and srv are on the same pool */
|
||||
#ifdef NTOPNG_PRO
|
||||
if(hp->enforceQuotasPerPoolMember(srv_host_pool_id)) {
|
||||
srv_host->incQuotaEnforcementStats(tv->tv_sec, ndpiDetectedProtocol.master_protocol,
|
||||
diff_rcvd_packets, diff_rcvd_bytes, diff_sent_packets, diff_sent_bytes);
|
||||
|
|
@ -1539,12 +1540,11 @@ void Flow::update_pools_stats(const struct timeval *tv,
|
|||
diff_rcvd_packets, diff_rcvd_bytes, diff_sent_packets, diff_sent_bytes);
|
||||
srv_host->incQuotaEnforcementCategoryStats(tv->tv_sec, category_id, diff_rcvd_bytes, diff_sent_bytes);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* *************************************** */
|
||||
|
||||
bool Flow::equal(const IpAddress *_cli_ip, const IpAddress *_srv_ip,
|
||||
|
|
|
|||
|
|
@ -298,6 +298,32 @@ void HostPools::luaStats(lua_State *vm, u_int16_t pool_id) {
|
|||
|
||||
/* *************************************** */
|
||||
|
||||
void HostPools::updateStats(struct timeval *tv) {
|
||||
HostPoolStats *hps;
|
||||
|
||||
if(stats && tv) {
|
||||
for(int i = 0; i < MAX_NUM_HOST_POOLS; i++)
|
||||
if((hps = stats[i]))
|
||||
hps->updateStats(tv); /* Use hps, stats[i] can become NULL after a swap */
|
||||
}
|
||||
};
|
||||
|
||||
/* *************************************** */
|
||||
|
||||
void HostPools::incPoolStats(u_int32_t when, u_int16_t host_pool_id, u_int16_t ndpi_proto,
|
||||
ndpi_protocol_category_t category_id, u_int64_t sent_packets, u_int64_t sent_bytes,
|
||||
u_int64_t rcvd_packets, u_int64_t rcvd_bytes) {
|
||||
HostPoolStats *hps = getPoolStats(host_pool_id);
|
||||
|
||||
if(!hps) return;
|
||||
|
||||
/* Important to use the assigned hps as a swap can make stats[host_pool_id] NULL */
|
||||
hps->incStats(when, ndpi_proto, sent_packets, sent_bytes, rcvd_packets, rcvd_bytes);
|
||||
hps->incCategoryStats(when, category_id, sent_bytes, rcvd_bytes);
|
||||
};
|
||||
|
||||
/* *************************************** */
|
||||
|
||||
#ifdef NTOPNG_PRO
|
||||
|
||||
void HostPools::reloadVolatileMembers(VlanAddressTree *_trees) {
|
||||
|
|
@ -398,31 +424,6 @@ void HostPools::incPoolNumDroppedFlows(u_int16_t pool_id) {
|
|||
|
||||
/* *************************************** */
|
||||
|
||||
void HostPools::incPoolStats(u_int32_t when, u_int16_t host_pool_id, u_int16_t ndpi_proto,
|
||||
ndpi_protocol_category_t category_id, u_int64_t sent_packets, u_int64_t sent_bytes,
|
||||
u_int64_t rcvd_packets, u_int64_t rcvd_bytes) {
|
||||
HostPoolStats *hps = getPoolStats(host_pool_id);
|
||||
|
||||
if(!hps) return;
|
||||
|
||||
/* Important to use the assigned hps as a swap can make stats[host_pool_id] NULL */
|
||||
hps->incStats(when, ndpi_proto, sent_packets, sent_bytes, rcvd_packets, rcvd_bytes);
|
||||
hps->incCategoryStats(when, category_id, sent_bytes, rcvd_bytes);
|
||||
};
|
||||
|
||||
/* *************************************** */
|
||||
|
||||
void HostPools::updateStats(struct timeval *tv) {
|
||||
HostPoolStats *hps;
|
||||
|
||||
if(stats && tv) {
|
||||
for(int i = 0; i < MAX_NUM_HOST_POOLS; i++)
|
||||
if((hps = stats[i]))
|
||||
hps->updateStats(tv); /* Use hps, stats[i] can become NULL after a swap */
|
||||
}
|
||||
};
|
||||
/* *************************************** */
|
||||
|
||||
void HostPools::resetPoolsStats(u_int16_t pool_filter) {
|
||||
HostPoolStats *hps;
|
||||
|
||||
|
|
|
|||
|
|
@ -3118,10 +3118,8 @@ void NetworkInterface::periodicStatsUpdate() {
|
|||
gettimeofday(&tdebug, NULL);
|
||||
#endif
|
||||
|
||||
#ifdef NTOPNG_PRO
|
||||
if(host_pools)
|
||||
host_pools->updateStats(&tv);
|
||||
#endif
|
||||
|
||||
for(u_int8_t network_id = 0; network_id < ntop->getNumLocalNetworks(); network_id++) {
|
||||
if(NetworkStats *ns = getNetworkStats(network_id))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue