Skip to content

Commit

Permalink
Merge branch 'ntop:dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaferret authored Jul 18, 2024
2 parents 411852c + b4b9253 commit a89d972
Show file tree
Hide file tree
Showing 12 changed files with 750 additions and 693 deletions.
3 changes: 2 additions & 1 deletion include/NetworkInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity {
virtual u_int32_t getFlowMaxIdle();

virtual void lua(lua_State *vm, bool fullStats);
virtual void probeLuaStats(lua_State *vm) { };
void luaScore(lua_State *vm);
void luaAlertedFlows(lua_State *vm);
void luaAnomalies(lua_State *vm);
Expand Down Expand Up @@ -995,7 +996,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity {
#ifdef NTOPNG_PRO
void updateBehaviorStats(const struct timeval *tv);

virtual void getFlowDevices(lua_State *vm, bool add_table);
virtual void getFlowDevices(lua_State *vm);
virtual void getFlowDeviceInfo(lua_State *vm, u_int32_t deviceIP, bool showAllStats = true) {
if (flow_interfaces_stats) {
lua_newtable(vm);
Expand Down
3 changes: 2 additions & 1 deletion include/ViewInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ class ViewInterface : public NetworkInterface {
virtual bool hasSeenVLANTaggedPackets() const;

#ifdef NTOPNG_PRO
virtual void getFlowDevices(lua_State *vm, bool add_table);
virtual void getFlowDevices(lua_State *vm);
virtual void getFlowDeviceInfo(lua_State *vm, u_int32_t deviceIP, bool showAllStats);
#endif
virtual void getSFlowDevices(lua_State *vm, bool add_table);
virtual void getSFlowDeviceInfo(lua_State *vm, u_int32_t deviceIP);
virtual void lua(lua_State *vm, bool fullStats);

virtual u_int32_t getFlowsHashSize();
virtual Flow *findFlowByKeyAndHashId(u_int32_t key, u_int hash_id,
Expand Down
10 changes: 5 additions & 5 deletions include/ZMQParserInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class ZMQParserInterface : public ParserInterface {
typedef std::map<string, pen_value_t> labels_map_t;
typedef std::map<pen_value_t, string> descriptions_map_t;
typedef std::map<string, u_int32_t> counters_map_t;
std::unordered_map<u_int32_t, ExporterStats> exporters_stats;
std::unordered_map<u_int32_t, bool> cloud_flow_exporters;
u_int16_t top_vlan_id;
std::unordered_map<std::string, u_int16_t> name_to_vlan;
Expand All @@ -45,16 +44,16 @@ class ZMQParserInterface : public ParserInterface {
u_int32_t flow_max_idle, returned_flow_max_idle;
u_int64_t zmq_initial_bytes, zmq_initial_pkts,
zmq_remote_initial_exported_flows;
std::map<u_int32_t, ZMQ_RemoteStats *> source_id_last_zmq_remote_stats;
ZMQ_RemoteStats *zmq_remote_stats, *zmq_remote_stats_shadow;
std::map<u_int32_t, nProbeStats *> source_id_last_zmq_remote_stats;
nProbeStats *zmq_remote_stats, *zmq_remote_stats_shadow;
u_int32_t remote_lifetime_timeout, remote_idle_timeout;
struct timeval last_zmq_remote_stats_update;
RwLock lock;
#ifdef NTOPNG_PRO
CustomAppMaps *custom_app_maps;
#endif

void exporterLuaStats(lua_State *vm);
void exporterLuaStats(lua_State *vm, nProbeStats *zrs);
void loadVLANMappings();
u_int16_t findVLANMapping(std::string name);

Expand Down Expand Up @@ -131,7 +130,7 @@ class ZMQParserInterface : public ParserInterface {
u_int32_t source_id, u_int32_t msg_id, void *data);

u_int32_t periodicStatsUpdateFrequency() const;
virtual void setRemoteStats(ZMQ_RemoteStats *zrs);
virtual void setRemoteStats(nProbeStats *zrs);
#ifdef NTOPNG_PRO
virtual bool getCustomAppDetails(u_int32_t remapped_app_id,
u_int32_t *const pen,
Expand All @@ -142,6 +141,7 @@ class ZMQParserInterface : public ParserInterface {
return zmq_remote_stats ? zmq_remote_stats->sflow_pkt_sample_drops : 0;
};
virtual void lua(lua_State *vm, bool fullStats);
virtual void probeLuaStats(lua_State *vm);
inline u_int32_t getFlowMaxIdle() { return (returned_flow_max_idle); }
};

Expand Down
63 changes: 63 additions & 0 deletions include/nProbeStats.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
*
* (C) 2013-24 - ntop.org
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/

#ifndef _NPROBE_STATS_H_
#define _NPROBE_STATS_H_

#include "ntop_includes.h"

typedef struct {
u_int64_t nf_ipfix_flows;
u_int64_t sflow_samples;
} FlowCollection;

typedef struct {
time_t time_last_used;
u_int32_t num_sflow_flows;
u_int32_t num_netflow_flows;
u_int32_t num_drops;
u_int32_t unique_source_id;
} ExporterStats;

class nProbeStats {
public:
char remote_ifname[32], remote_ifaddress[64];
char remote_probe_address[64], remote_probe_public_address[64], uuid[36];
char remote_probe_version[64], remote_probe_os[64];
char remote_probe_license[64], remote_probe_edition[64];
char remote_probe_maintenance[64];
u_int32_t source_id, uuid_num, num_exporters;
u_int64_t remote_bytes, remote_pkts, num_flow_exports;
u_int32_t remote_ifspeed, remote_time, local_time, avg_bps, avg_pps;
u_int32_t remote_lifetime_timeout, remote_idle_timeout,
remote_collected_lifetime_timeout;
u_int32_t export_queue_full, too_many_flows, elk_flow_drops,
sflow_pkt_sample_drops, flow_collection_drops,
flow_collection_udp_socket_drops;
FlowCollection flow_collection;

std::map<u_int32_t, ExporterStats> exportersStats;
public:
nProbeStats();
~nProbeStats() {};
};

#endif /* _NPROBE_STATS_H_ */
1 change: 1 addition & 0 deletions include/ntop_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ using namespace std;
#include "Cardinality.h"
#include "PeerStats.h"
#include "IpAddress.h"
#include "nProbeStats.h"
#include "Ping.h"
#include "JobQueue.h"
#include "ContinuousPingStats.h"
Expand Down
28 changes: 0 additions & 28 deletions include/ntop_typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,26 +371,6 @@ PACK_ON struct l2tp_header {
/* IMPORTANT: whenever the Parsed_FlowSerial is changed, nProbe must be updated
* too */

typedef struct zmq_remote_stats {
char remote_ifname[32], remote_ifaddress[64];
char remote_probe_address[64], remote_probe_public_address[64], uuid[36];
char remote_probe_version[64], remote_probe_os[64];
char remote_probe_license[64], remote_probe_edition[64];
char remote_probe_maintenance[64];
u_int32_t source_id, uuid_num, num_exporters;
u_int64_t remote_bytes, remote_pkts, num_flow_exports;
u_int32_t remote_ifspeed, remote_time, local_time, avg_bps, avg_pps;
u_int32_t remote_lifetime_timeout, remote_idle_timeout,
remote_collected_lifetime_timeout;
u_int32_t export_queue_full, too_many_flows, elk_flow_drops,
sflow_pkt_sample_drops, flow_collection_drops,
flow_collection_udp_socket_drops;
struct {
u_int64_t nf_ipfix_flows;
u_int64_t sflow_samples;
} flow_collection;
} ZMQ_RemoteStats;

typedef struct zmq_template {
u_int32_t pen, field;
const char *format, *name, *descr;
Expand Down Expand Up @@ -1216,13 +1196,5 @@ typedef enum {
ESTABLISHED,
CLOSED = 3
} MajorConnectionStates;

typedef struct {
time_t time_last_used;
u_int32_t num_sflow_flows;
u_int32_t num_netflow_flows;
u_int32_t num_drops;
u_int32_t unique_source_id;
} ExporterStats;

#endif /* _NTOP_TYPEDEFS_H_ */
Loading

0 comments on commit a89d972

Please sign in to comment.