Eunomia
0.1.0
A lightweight eBPF-based CloudNative Monitor tool for Container Security and Observability
|
Go to the documentation of this file. 1 #ifndef CONTAINER_MANAGER_EUNOMIA_H
2 #define CONTAINER_MANAGER_EUNOMIA_H
7 #include <shared_mutex>
8 #include <unordered_map>
14 #include <process/process.h>
36 template<
typename EVENT>
45 if (e.
data.pid == 0) {
62 class container_client
66 httplib::Client dockerd_client;
70 std::string list_all_containers(
void);
72 std::string list_all_process_running_in_container(
const std::string &container_id);
74 std::string inspect_container(
const std::string &container_id);
80 struct process_container_info_data
88 class container_info_map
92 mutable std::shared_mutex mutex_;
94 std::unordered_map<int, process_container_info_data> container_info_map__;
97 container_info_map() =
default;
99 void insert(
int pid, process_container_info_data info)
101 std::unique_lock<std::shared_mutex> lock(mutex_);
102 container_info_map__[pid] = info;
105 std::optional<process_container_info_data> get(
int pid)
const
107 std::shared_lock<std::shared_mutex> lock(mutex_);
108 auto ct_info_p = container_info_map__.find(pid);
109 if (ct_info_p != container_info_map__.end())
111 return ct_info_p->second;
118 std::unique_lock<std::shared_mutex> lock(mutex_);
119 container_info_map__.erase(pid);
123 container_info_map info_map;
124 container_client client;
129 void get_all_process_info(
void);
131 void update_container_map_data(
void);
container_info_handler(container_manager &m)
Definition: container_manager.h:51
Definition: btf_helpers.c:21
the event handler for single type
Definition: event_handler.h:52
container_info get_container_info_for_pid(int pid) const
Definition: container.cpp:80
container info
Definition: container_info.h:32
container_info ct_info
Definition: event_handler.h:34
manager all container or k8s info
Definition: container_manager.h:21
use process tracker to track the processes created in the container
Definition: container_manager.h:25
void fill_process_common_event(common_event &info, int pid)
std::int64_t get_process_namespace(const char *type, int pid)
Definition: container.cpp:105
container_manager()
Definition: container.cpp:101
container_tracking_handler(container_manager &m)
Definition: container_manager.h:31
Definition: container_manager.h:38
the basic event type
Definition: event_handler.h:31
void handle(tracker_event< EVENT > &e)
implement this function to handle the event
Definition: container_manager.h:43
T data
Definition: event_handler.h:33
void init()
Definition: container.cpp:90
void handle(tracker_event< process_event > &e)
implement this function to handle the event
Definition: container.cpp:218