Skip to content

Commit

Permalink
Add timestamp to network viewer (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoftsm committed Feb 28, 2024
1 parent 7804df3 commit e5e3e43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/networkviewer.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ static __always_inline void set_common_tcp_nv_data(netdata_nv_idx_t *idx,

data->pid = bpf_get_current_pid_tgid() >> 32;
data->uid = bpf_get_current_uid_gid();
data->ts = bpf_ktime_get_ns();
data->timer = 0;
bpf_probe_read(&data->retransmits, sizeof(data->retransmits), &icsk->icsk_retransmits);
data->expires = 0;
Expand All @@ -165,6 +166,9 @@ static __always_inline void set_common_udp_nv_data(netdata_nv_idx_t *idx,
netdata_nv_data_t *data,
struct sock *sk,
__u16 family) {
data->pid = bpf_get_current_pid_tgid() >> 32;
data->uid = bpf_get_current_uid_gid();
data->ts = bpf_ktime_get_ns();
data->protocol = IPPROTO_UDP;
data->family = family;
unsigned char udp_state;
Expand Down Expand Up @@ -326,6 +330,9 @@ int BPF_KPROBE(netdata_nv_tcp_set_state_kprobe)
if (!monitor_apps(&nv_ctrl))
return 0;

netdata_nv_data_t data = { };
data.state = state;
set_common_tcp_nv_data(&idx, &data, sk, family, 0);

return 0;
}
Expand Down Expand Up @@ -542,6 +549,10 @@ int BPF_PROG(netdata_nv_tcp_set_state_fentry, struct sock *sk, int state)
if (!monitor_apps(&nv_ctrl))
return 0;

netdata_nv_data_t data = { };
data.state = state;
set_common_tcp_nv_data(&idx, &data, sk, family, 0);

return 0;
}

Expand Down

0 comments on commit e5e3e43

Please sign in to comment.