Explorar o código

Fixed #TASK_QT-9810 修改accept sendbytes命名

rock hai 1 ano
pai
achega
7f41c4f980
Modificáronse 4 ficheiros con 15 adicións e 7 borrados
  1. 2 2
      containers/container.go
  2. 4 0
      containers/metrics.go
  3. 5 5
      ebpftracer/ebpf/tcp/state.c
  4. 4 0
      ebpftracer/tracer.go

+ 2 - 2
containers/container.go

@@ -371,8 +371,8 @@ func (c *Container) Collect(ch chan<- prometheus.Metric) {
 
 	for d, stats := range c.acceptsSuccessful {
 		ch <- counter(metrics.NetAcceptsSuccessful, float64(0), d.src.String(), d.dst.String())
-		ch <- counter(metrics.NetBytesSent, float64(stats.BytesSent), d.src.String(), d.dst.String())
-		ch <- counter(metrics.NetBytesReceived, float64(stats.BytesReceived), d.src.String(), d.dst.String())
+		ch <- counter(metrics.NetAcceptBytesSent, float64(stats.BytesSent), d.src.String(), d.dst.String())
+		ch <- counter(metrics.NetAcceptBytesReceived, float64(stats.BytesReceived), d.src.String(), d.dst.String())
 	}
 	for dst, count := range c.connectsFailed {
 		ch <- counter(metrics.NetConnectionsFailed, float64(count), dst.String())

+ 4 - 0
containers/metrics.go

@@ -40,6 +40,8 @@ var metrics = struct {
 
 	NetAcceptsSuccessful 	 *prometheus.Desc
 	NetAcceptsActive     	 *prometheus.Desc
+	NetAcceptBytesSent       *prometheus.Desc
+	NetAcceptBytesReceived    *prometheus.Desc
 
 	LogMessages *prometheus.Desc
 
@@ -89,6 +91,8 @@ var metrics = struct {
 	NetBytesSent:             metric("container_net_tcp_bytes_sent_total", "Total number of bytes sent to the peer", "destination", "actual_destination"),
 	NetBytesReceived:         metric("container_net_tcp_bytes_received_total", "Total number of bytes received from the peer", "destination", "actual_destination"),
 	NetAcceptsSuccessful: 	  metric("container_net_tcp_successful_accept_total", "Total number of successful TCP accepts", "destination", "actual_destination"),
+	NetAcceptBytesSent:       metric("container_net_tcp_bytes_sent_accept_total", "Total number of bytes sent to the peer", "destination", "actual_destination"),
+	NetAcceptBytesReceived:   metric("container_net_tcp_bytes_received_accept_total", "Total number of bytes received from the peer", "destination", "actual_destination"),
 	
 	LogMessages: metric("container_log_messages_total", "Number of messages grouped by the automatically extracted repeated pattern", "source", "level", "pattern_hash", "sample"),
 

+ 5 - 5
ebpftracer/ebpf/tcp/state.c

@@ -244,15 +244,15 @@ int sys_enter_close(void *ctx) {
         bpf_map_delete_elem(&active_connections, &cid);
     }
     cw_bpf_debug("socket accept socket sys_enter_close accept_Connection before cid.pid=%d, cid.fd=%d\n", cid.pid, cid.fd);
-    conn = bpf_map_lookup_elem(&active_accepts, &cid);
-    if (conn) {
+    struct connection *acceptConn = bpf_map_lookup_elem(&active_accepts, &cid);
+    if (acceptConn) {
         struct tcp_event e = {};
         e.type = EVENT_TYPE_ACCEPT_CLOSE;
         e.pid = cid.pid;
         e.fd = cid.fd;
-        e.bytes_sent = conn->bytes_sent;
-        e.bytes_received = conn->bytes_received;
-        e.timestamp = conn->timestamp;
+        e.bytes_sent = acceptConn->bytes_sent;
+        e.bytes_received = acceptConn->bytes_received;
+        e.timestamp = acceptConn->timestamp;
         bpf_perf_event_output(ctx, &tcp_accept_events, BPF_F_CURRENT_CPU, &e, sizeof(e));
         bpf_map_delete_elem(&active_accepts, &cid);
         cw_bpf_debug("socket accept socket sys_enter_close accept_Connection cid.pid=%d, cid.fd=%d\n", cid.pid, cid.fd);

+ 4 - 0
ebpftracer/tracer.go

@@ -245,6 +245,10 @@ func (t *Tracer) ActiveConnectionsIterator() *ebpf.MapIterator {
 	return t.collection.Maps["active_connections"].Iterate()
 }
 
+func (t *Tracer) ActiveAcceptsIterator() *ebpf.MapIterator {
+	return t.collection.Maps["active_accepts"].Iterate()
+}
+
 type ConnectionId struct {
 	FD  uint64
 	PID uint32