Skip to content

Commit

Permalink
new(sinsp): add some debug logs when the capture is closed
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
  • Loading branch information
Andreagit97 committed Aug 21, 2023
1 parent 6024bda commit 5461298
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions userspace/libsinsp/sinsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,33 @@ void sinsp::stop_capture()
{
throw sinsp_exception(scap_getlasterr(m_h));
}

/* Print scap stats */
print_capture_stats(sinsp_logger::SEV_DEBUG);

/* Print the number of threads and fds in our tables */
uint64_t thread_cnt = 0;
uint64_t fd_cnt = 0;
m_thread_manager->m_threadtable.loop([&thread_cnt, &fd_cnt] (sinsp_threadinfo& tinfo) {
thread_cnt++;

/* Only main threads have an associated fdtable */
if(tinfo.is_main_thread())
{
auto fdtable_ptr = tinfo.get_fd_table();
if(fdtable_ptr != nullptr)
{
fd_cnt += fdtable_ptr->size();
}
}
return true;
});
g_logger.format(sinsp_logger::SEV_DEBUG,
"total threads in the table:%" PRIu64
", total fds in all threads:%" PRIu64
"\n",
thread_cnt,
fd_cnt);
}

void sinsp::start_capture()
Expand Down

0 comments on commit 5461298

Please sign in to comment.