Eunomia  0.1.0
A lightweight eBPF-based CloudNative Monitor tool for Container Security and Observability
process.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2  *
3  * Copyright (c) 2022, 郑昱笙,濮雯旭,张典典(牛校牛子队)
4  * All rights reserved.
5  */
6 
7 #ifndef PROCESS_CMD_H
8 #define PROCESS_CMD_H
9 
10 #include <string>
11 
12 #include "libbpf_print.h"
13 #include "model/tracker.h"
14 #include "prometheus/counter.h"
15 #include "prometheus_server.h"
16 
17 extern "C" {
18 #include <process/process_tracker.h>
19 }
20 
22 
26 struct process_tracker : public tracker_with_config<process_env, process_event>
27 {
29 
31  static std::unique_ptr<process_tracker> create_tracker_with_default_env(tracker_event_handler handler);
32  static std::unique_ptr<process_tracker> create_tracker_with_args(
33  tracker_event_handler handler,
34  const std::vector<std::string> &args)
35  {
36  return create_tracker_with_default_env(handler);
37  }
38 
40  void start_tracker();
41 
43  struct prometheus_event_handler : public event_handler<process_event>
44  {
45  prometheus::Family<prometheus::Counter> &eunomia_process_start_counter;
46  prometheus::Family<prometheus::Counter> &eunomia_process_exit_counter;
47  void report_prometheus_event(const struct process_event &e, const struct container_info& ct_info);
48 
51  };
52 
54  struct json_event_handler_base : public event_handler<process_event>
55  {
56  std::string to_json(const struct process_event &e);
57  };
58 
61  {
63  };
64 
65  struct plain_text_event_printer : public event_handler<process_event>
66  {
68  };
69 
70  struct csv_event_printer : public event_handler<process_event>
71  {
73  };
74 
75 };
76 
77 #endif
tracker.h
eunomia_mode::server
@ server
process_tracker::json_event_handler_base
convert event to json
Definition: process.h:54
process_tracker::json_event_printer::handle
void handle(tracker_event< process_event > &e)
implement this function to handle the event
Definition: process.cpp:109
process_tracker::csv_event_printer
Definition: process.h:70
process_tracker::prometheus_event_handler::prometheus_event_handler
prometheus_event_handler(prometheus_server &server)
Definition: process.cpp:48
event_handler
the event handler for single type
Definition: event_handler.h:52
process_tracker::process_tracker
process_tracker(config_data config)
Definition: process.cpp:65
process_tracker::prometheus_event_handler::eunomia_process_start_counter
prometheus::Family< prometheus::Counter > & eunomia_process_start_counter
Definition: process.h:45
process_tracker::create_tracker_with_args
static std::unique_ptr< process_tracker > create_tracker_with_args(tracker_event_handler handler, const std::vector< std::string > &args)
Definition: process.h:32
container_info
container info
Definition: container_info.h:32
tracker_with_config< process_env, process_event >::config_data
tracker_config< process_env, process_event > config_data
type alias for env and config
Definition: tracker.h:65
process_tracker::start_tracker
void start_tracker()
start process tracker
Definition: process.cpp:82
tracker_with_config
tracker template with env and data
Definition: tracker.h:59
process_tracker::create_tracker_with_default_env
static std::unique_ptr< process_tracker > create_tracker_with_default_env(tracker_event_handler handler)
create a tracker with deafult config
Definition: process.cpp:71
process_tracker::prometheus_event_handler::report_prometheus_event
void report_prometheus_event(const struct process_event &e, const struct container_info &ct_info)
Definition: process.cpp:20
process_tracker
ebpf process tracker interface
Definition: process.h:26
process_tracker::prometheus_event_handler::handle
void handle(tracker_event< process_event > &e)
implement this function to handle the event
Definition: process.cpp:60
process_tracker::json_event_handler_base::to_json
std::string to_json(const struct process_event &e)
Definition: process.cpp:91
prometheus_server.h
tracker_event
the basic event type
Definition: event_handler.h:31
process_tracker::prometheus_event_handler::eunomia_process_exit_counter
prometheus::Family< prometheus::Counter > & eunomia_process_exit_counter
Definition: process.h:46
process_tracker::prometheus_event_handler
used for prometheus exporter
Definition: process.h:43
libbpf_print.h
process_tracker::plain_text_event_printer::handle
void handle(tracker_event< process_event > &e)
implement this function to handle the event
Definition: process.cpp:114
process_tracker::json_event_printer
used for json exporter, inherits from json_event_handler
Definition: process.h:60
process_tracker::plain_text_event_printer
Definition: process.h:65
process_tracker::csv_event_printer::handle
void handle(tracker_event< process_event > &e)
implement this function to handle the event
Definition: process.cpp:166
prometheus_server
Definition: prometheus_server.h:22
tracker_with_config< process_env, process_event >::tracker_event_handler
std::shared_ptr< event_handler< process_event > > tracker_event_handler
type alias for event handler
Definition: tracker.h:67
config
seccomp_config config
Definition: seccomp_test.cpp:13