diff options
author | lns <matzeton@googlemail.com> | 2022-04-17 18:56:30 +0200 |
---|---|---|
committer | lns <matzeton@googlemail.com> | 2022-04-17 18:56:30 +0200 |
commit | c7bf94e9f128e9a76a76d355a8ce77c3cc3ca6d9 (patch) | |
tree | 19e5789c61c90c6f5fe138a9e716d53299dd4ad9 /examples/c-collectd/c-collectd.c | |
parent | a2547321bb3d7b5e70ec8eedd02a28adb23881d4 (diff) |
nDPIsrvd.(h|py): Added socket read/recv timeout.
* nDPIsrvd.h: support for O_NONBLOCK nDPIsrvd_socket
Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'examples/c-collectd/c-collectd.c')
-rw-r--r-- | examples/c-collectd/c-collectd.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/examples/c-collectd/c-collectd.c b/examples/c-collectd/c-collectd.c index aef84239a..3abceec83 100644 --- a/examples/c-collectd/c-collectd.c +++ b/examples/c-collectd/c-collectd.c @@ -44,7 +44,6 @@ static struct uint64_t flow_detection_update_count; uint64_t flow_not_detected_count; - uint64_t flow_packet_count; uint64_t flow_total_bytes; uint64_t flow_risky_count; @@ -256,7 +255,7 @@ static void print_collectd_exec_output(void) printf(COLLECTD_PUTVAL_N_FORMAT(flow_new_count) COLLECTD_PUTVAL_N_FORMAT(flow_end_count) COLLECTD_PUTVAL_N_FORMAT(flow_idle_count) COLLECTD_PUTVAL_N_FORMAT(flow_guessed_count) COLLECTD_PUTVAL_N_FORMAT(flow_detected_count) COLLECTD_PUTVAL_N_FORMAT(flow_detection_update_count) - COLLECTD_PUTVAL_N_FORMAT(flow_not_detected_count) COLLECTD_PUTVAL_N_FORMAT(flow_packet_count) + COLLECTD_PUTVAL_N_FORMAT(flow_not_detected_count) COLLECTD_PUTVAL_N_FORMAT(flow_total_bytes) COLLECTD_PUTVAL_N_FORMAT(flow_risky_count), COLLECTD_PUTVAL_N(flow_new_count), @@ -266,7 +265,6 @@ static void print_collectd_exec_output(void) COLLECTD_PUTVAL_N(flow_detected_count), COLLECTD_PUTVAL_N(flow_detection_update_count), COLLECTD_PUTVAL_N(flow_not_detected_count), - COLLECTD_PUTVAL_N(flow_packet_count), COLLECTD_PUTVAL_N(flow_total_bytes), COLLECTD_PUTVAL_N(flow_risky_count)); @@ -428,7 +426,7 @@ static uint64_t get_total_flow_bytes(struct nDPIsrvd_socket * const sock) { nDPIsrvd_ull total_bytes_ull = 0; - if (TOKEN_VALUE_TO_ULL(TOKEN_GET_SZ(sock, "flow_tot_l4_data_len"), &total_bytes_ull) == CONVERSION_OK) + if (TOKEN_VALUE_TO_ULL(TOKEN_GET_SZ(sock, "flow_tot_l4_payload_len"), &total_bytes_ull) == CONVERSION_OK) { return total_bytes_ull; } @@ -670,11 +668,6 @@ static enum nDPIsrvd_callback_return captured_json_callback(struct nDPIsrvd_sock collectd_statistics.flow_not_detected_count++; } - if (TOKEN_GET_SZ(sock, "packet_event_name") != NULL) - { - collectd_statistics.flow_packet_count++; - } - return CALLBACK_OK; } @@ -716,6 +709,13 @@ int main(int argc, char ** argv) return 1; } + if (nDPIsrvd_set_nonblock(sock) != 0) + { + LOG(LOG_DAEMON | LOG_ERR, "nDPIsrvd set nonblock failed: %s", strerror(errno)); + nDPIsrvd_socket_free(&sock); + return 1; + } + signal(SIGINT, sighandler); signal(SIGTERM, sighandler); signal(SIGPIPE, SIG_IGN); |