Skip to content

Commit e6d0981

Browse files
committed
feature: add net collector
1 parent d8a913d commit e6d0981

File tree

14 files changed

+1271
-3
lines changed

14 files changed

+1271
-3
lines changed

core/host_monitor/Constants.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ namespace logtail {
2323
std::filesystem::path PROCESS_DIR = "/proc";
2424
const std::filesystem::path PROCESS_STAT = "stat";
2525
const std::filesystem::path PROCESS_LOADAVG = "loadavg";
26+
const std::filesystem::path PROCESS_NET_SOCKSTAT = "net/sockstat";
27+
const std::filesystem::path PROCESS_NET_SOCKSTAT6 = "net/sockstat6";
28+
const std::filesystem::path PROCESS_NET_DEV = "net/dev";
29+
const std::filesystem::path PROCESS_NET_IF_INET6 = "net/if_inet6";
2630
const int64_t SYSTEM_HERTZ = sysconf(_SC_CLK_TCK);
31+
const int NET_INTERFACE_LIST_MAX = 20;
2732

2833
} // namespace logtail

core/host_monitor/Constants.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ namespace logtail {
2525
extern std::filesystem::path PROCESS_DIR;
2626
const extern std::filesystem::path PROCESS_STAT;
2727
const extern std::filesystem::path PROCESS_LOADAVG;
28+
29+
const extern std::filesystem::path PROCESS_NET_SOCKSTAT;
30+
const extern std::filesystem::path PROCESS_NET_SOCKSTAT6;
31+
const extern std::filesystem::path PROCESS_NET_DEV;
32+
const extern std::filesystem::path PROCESS_NET_IF_INET6;
2833
const extern int64_t SYSTEM_HERTZ;
34+
const extern int NET_INTERFACE_LIST_MAX;
2935

3036
#ifdef __ENTERPRISE__
3137
inline constexpr StringView DEFAULT_INSTANCE_ID_LABEL = "instance_id";

core/host_monitor/HostMonitorInputRunner.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "host_monitor/Constants.h"
3636
#include "host_monitor/HostMonitorTimerEvent.h"
3737
#include "host_monitor/collector/CPUCollector.h"
38+
#include "host_monitor/collector/NetCollector.h"
3839
#include "host_monitor/collector/ProcessEntityCollector.h"
3940
#include "host_monitor/collector/SystemCollector.h"
4041
#include "logger/Logger.h"
@@ -55,6 +56,7 @@ HostMonitorInputRunner::HostMonitorInputRunner() {
5556
RegisterCollector<ProcessEntityCollector>();
5657
RegisterCollector<CPUCollector>();
5758
RegisterCollector<SystemCollector>();
59+
RegisterCollector<NetCollector>();
5860

5961
size_t threadPoolSize = 1;
6062
// threadPoolSize should be greater than 0

0 commit comments

Comments
 (0)