mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-26 14:10:40 +00:00
Rework threads labeling
This commit is contained in:
parent
77f0de2ca8
commit
b6e30f9511
22 changed files with 46 additions and 27 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit fc153f8a9bb27e9375906dc1922cc6075f2d36c1
|
||||
Subproject commit 955f450a17aa17389a54c8b2133f558059b1115e
|
||||
|
|
@ -439,6 +439,7 @@ public:
|
|||
NetworkInterface(const char *name, const char *custom_interface_type = NULL);
|
||||
virtual ~NetworkInterface();
|
||||
|
||||
void setPollerThreadName();
|
||||
bool initFlowChecksLoop(); /* Initialize the loop to dequeue flows for the
|
||||
execution of user script hooks */
|
||||
bool initHostChecksLoop(); /* Same as above but for hosts */
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ void *resolveLoop(void *ptr) {
|
|||
u_int no_resolution_loops = 0;
|
||||
const u_int max_num_idle_loops = 1;
|
||||
|
||||
Utils::setThreadName("ntopng-DNS-res");
|
||||
Utils::setThreadName("n-dns-res");
|
||||
|
||||
while (!ntop->getGlobals()->isShutdown()) {
|
||||
char numeric_ip[64];
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
static void *pollerFctn(void *ptr) {
|
||||
ContinuousPing *cp = (ContinuousPing *)ptr;
|
||||
|
||||
Utils::setThreadName("ntopng-cping");
|
||||
Utils::setThreadName("n-cping");
|
||||
|
||||
while ((!ntop->getGlobals()->isShutdownRequested()) &&
|
||||
(!ntop->getGlobals()->isShutdown()))
|
||||
|
|
|
|||
|
|
@ -82,6 +82,9 @@ void DummyInterface::forgeFlow(u_int iteration) {
|
|||
|
||||
static void* packetPollLoop(void* ptr) {
|
||||
DummyInterface* iface = (DummyInterface*)ptr;
|
||||
|
||||
iface->setPollerThreadName();
|
||||
|
||||
u_int32_t iteration = 0;
|
||||
|
||||
/* Wait until the initialization completes */
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
/* **************************************************** */
|
||||
|
||||
static void *esLoop(void *ptr) {
|
||||
Utils::setThreadName("ntopng-ES");
|
||||
Utils::setThreadName("n-es");
|
||||
|
||||
ElasticSearch *es = (ElasticSearch *)ptr;
|
||||
es->pushEStemplate(); // sends ES ntopng template
|
||||
|
|
|
|||
|
|
@ -4143,7 +4143,7 @@ static int ntop_reload_host_prefs(lua_State *vm) {
|
|||
|
||||
static void *pcapDumpLoop(void *ptr) {
|
||||
NtopngLuaContext *c = (NtopngLuaContext *)ptr;
|
||||
Utils::setThreadName("ntopng-pcap");
|
||||
Utils::setThreadName("n-pcap-dump");
|
||||
|
||||
while (c->pkt_capture.captureInProgress) {
|
||||
u_char *pkt;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
/* ******************************* */
|
||||
|
||||
static void *resolverCheckFctn(void *ptr) {
|
||||
Utils::setThreadName("ntopng-MDNS-res");
|
||||
Utils::setThreadName("n-mdns-res");
|
||||
MDNS *m = (MDNS *)ptr;
|
||||
|
||||
m->initializeResolver();
|
||||
|
|
|
|||
|
|
@ -3912,7 +3912,7 @@ void NetworkInterface::flowAlertsDequeueLoop() {
|
|||
u_int64_t n;
|
||||
char buf[16];
|
||||
|
||||
snprintf(buf, sizeof(buf), "ntopng-%d-fchek", get_id());
|
||||
snprintf(buf, sizeof(buf), "n-fcheck-%d", get_id());
|
||||
Utils::setThreadName(buf);
|
||||
|
||||
ntop->getTrace()->traceEvent(TRACE_NORMAL,
|
||||
|
|
@ -3971,7 +3971,7 @@ void NetworkInterface::hostAlertsDequeueLoop() {
|
|||
u_int64_t n;
|
||||
char buf[16];
|
||||
|
||||
snprintf(buf, sizeof(buf), "ntopng-%d-hcheck", get_id());
|
||||
snprintf(buf, sizeof(buf), "n-hcheck-%d", get_id());
|
||||
Utils::setThreadName(buf);
|
||||
|
||||
ntop->getTrace()->traceEvent(TRACE_NORMAL,
|
||||
|
|
@ -4033,7 +4033,7 @@ void NetworkInterface::dumpFlowLoop() {
|
|||
const u_int idle_flows_budget = 65536;
|
||||
const u_int active_flows_budget = idle_flows_budget / 3; /* lower priority */
|
||||
|
||||
snprintf(buf, sizeof(buf), "ntopng-%d-fdump", get_id());
|
||||
snprintf(buf, sizeof(buf), "n-fdump-%d", get_id());
|
||||
Utils::setThreadName(buf);
|
||||
|
||||
ntop->getTrace()->traceEvent(TRACE_NORMAL, "Started flow dump loop on interface %s [id: %u]...",
|
||||
|
|
@ -4124,6 +4124,16 @@ void NetworkInterface::startFlowDumping() {
|
|||
|
||||
/* **************************************************** */
|
||||
|
||||
void NetworkInterface::setPollerThreadName() {
|
||||
char buf[16];
|
||||
|
||||
snprintf(buf, sizeof(buf), "n-poll-%d", get_id());
|
||||
|
||||
Utils::setThreadName(buf);
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
|
||||
void NetworkInterface::startPacketPolling() {
|
||||
if (pollLoopCreated) {
|
||||
if ((cpu_affinity != -1) && (ntop->getNumCPUs() > 1)) {
|
||||
|
|
@ -4134,12 +4144,6 @@ void NetworkInterface::startPacketPolling() {
|
|||
ntop->getTrace()->traceEvent(TRACE_NORMAL, "Setting affinity of interface %s to core %d",
|
||||
get_description(), cpu_affinity);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
char buf[16];
|
||||
snprintf(buf, sizeof(buf), "ntopng-%d-pkt", get_id());
|
||||
pthread_setname_np(pollLoop, buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
ntop->getTrace()->traceEvent(TRACE_NORMAL, "Started polling on interface '%s' [id: %u]...",
|
||||
|
|
|
|||
|
|
@ -678,7 +678,7 @@ void Ntop::start() {
|
|||
gettimeofday(&begin, NULL);
|
||||
_usleep((5 - begin.tv_sec % 5) * 1e6 - begin.tv_usec);
|
||||
|
||||
Utils::setThreadName("ntopng-main");
|
||||
Utils::setThreadName("n-main");
|
||||
|
||||
globals->setInitialized(); /* We're ready to go */
|
||||
|
||||
|
|
|
|||
|
|
@ -286,6 +286,8 @@ void PF_RINGInterface::multiPacketPollLoop() {
|
|||
static void *packetPollLoop(void *ptr) {
|
||||
PF_RINGInterface *iface = (PF_RINGInterface *)ptr;
|
||||
|
||||
iface->setPollerThreadName();
|
||||
|
||||
/* Wait until the initialization completes */
|
||||
while (iface->isStartingUp()) sleep(1);
|
||||
|
||||
|
|
|
|||
|
|
@ -250,6 +250,9 @@ static bool idle_flow_account(GenericHashEntry *h, void *user_data, bool *matche
|
|||
|
||||
static void *packetPollLoop(void *ptr) {
|
||||
PcapInterface *iface = (PcapInterface *)ptr;
|
||||
|
||||
iface->setPollerThreadName();
|
||||
|
||||
std::vector<std::string> *pcap_files_queue = iface->get_pcap_files_queue();
|
||||
int fds[MAX_NUM_PCAP_INTERFACES] = { -1 };
|
||||
int socks[MAX_NUM_PCAP_INTERFACES] = { -1 };
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ void PeriodicActivities::lua(NetworkInterface *iface, lua_State *vm) {
|
|||
/* **************************************************** */
|
||||
|
||||
static void *startActivity(void *ptr) {
|
||||
Utils::setThreadName("ntopng-periodic");
|
||||
Utils::setThreadName("n-periodic");
|
||||
|
||||
((PeriodicActivities *)ptr)->run();
|
||||
|
||||
|
|
|
|||
|
|
@ -284,9 +284,9 @@ void Ping::pollResults() {
|
|||
char thread_name[64];
|
||||
|
||||
if (ifname)
|
||||
snprintf(thread_name, sizeof(thread_name), "ntopng-ping-%s", ifname);
|
||||
snprintf(thread_name, sizeof(thread_name), "n-ping-%s", ifname);
|
||||
else
|
||||
snprintf(thread_name, sizeof(thread_name), "ntopng-ping");
|
||||
snprintf(thread_name, sizeof(thread_name), "n-ping");
|
||||
|
||||
Utils::setThreadName(thread_name);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,9 +54,9 @@ void QueuedThreadData::run() {
|
|||
hourly_daily_activity ? "hour/daily" : "sec/min");
|
||||
#endif
|
||||
if (iface->get_id() == -1)
|
||||
snprintf(name, sizeof(name), "ntopng-S-%s", label);
|
||||
snprintf(name, sizeof(name), "n-s-%s", label);
|
||||
else
|
||||
snprintf(name, sizeof(name), "ntopng-%d-%s", iface->get_id(), label);
|
||||
snprintf(name, sizeof(name), "n-%d-%s", iface->get_id(), label);
|
||||
|
||||
Utils::setThreadName(name);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
/* **************************************************** */
|
||||
|
||||
static void *doRun(void *ptr) {
|
||||
Utils::setThreadName("ntopng-th-pool");
|
||||
Utils::setThreadName("n-th-pool");
|
||||
|
||||
((ThreadPool *)ptr)->run();
|
||||
return (NULL);
|
||||
|
|
@ -145,7 +145,7 @@ void ThreadPool::run() {
|
|||
q->run();
|
||||
delete q;
|
||||
|
||||
Utils::setThreadName("ntopng-idle-thpool");
|
||||
Utils::setThreadName("n-idle-thpool");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ bool TimelineExtract::extractLive(struct mg_connection *conn,
|
|||
|
||||
static void *extractionThread(void *ptr) {
|
||||
TimelineExtract *extr = (TimelineExtract *)ptr;
|
||||
Utils::setThreadName("ntopng-extract");
|
||||
Utils::setThreadName("n-extract");
|
||||
|
||||
extr->extractToDisk(extr->getID(), extr->getNetworkInterface(),
|
||||
extr->getFrom(), extr->getTo(), extr->getFilter(),
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ void ZCCollectorInterface::collect_flows() {
|
|||
static void *packetPollLoop(void *ptr) {
|
||||
ZCCollectorInterface *iface = (ZCCollectorInterface *)ptr;
|
||||
|
||||
iface->setPollerThreadName();
|
||||
|
||||
/* Wait until the initialization completes */
|
||||
while (iface->isStartingUp()) sleep(1);
|
||||
|
||||
|
|
|
|||
|
|
@ -612,6 +612,8 @@ void ZMQCollectorInterface::collect_flows() {
|
|||
static void *packetPollLoop(void *ptr) {
|
||||
ZMQCollectorInterface *iface = (ZMQCollectorInterface *)ptr;
|
||||
|
||||
iface->setPollerThreadName();
|
||||
|
||||
/* Wait until the initialization completes */
|
||||
while (iface->isStartingUp()) sleep(1);
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@ void sFlowPktInterface::sflowPacketPollLoop() {
|
|||
static void *packetPollLoop(void *ptr) {
|
||||
sFlowPktInterface *iface = (sFlowPktInterface *)ptr;
|
||||
|
||||
iface->setPollerThreadName();
|
||||
|
||||
/* Wait until the initialization completes */
|
||||
while (iface->isStartingUp()) sleep(1);
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 83dbbcd4871a12f882dded739a434da7a025e52f
|
||||
Subproject commit 6caf427ca51a2a3ef9f8af002f45387133abcd4a
|
||||
4
third-party/mongoose/mongoose.c
vendored
4
third-party/mongoose/mongoose.c
vendored
|
|
@ -5269,7 +5269,7 @@ static void *worker_thread(void *thread_func_param) {
|
|||
struct mg_context *ctx = (struct mg_context *)thread_func_param;
|
||||
struct mg_connection *conn;
|
||||
|
||||
Utils::setThreadName("ntopng-http-worker");
|
||||
Utils::setThreadName("n-http-worker");
|
||||
|
||||
conn = (struct mg_connection *) calloc(1, sizeof(*conn) + MAX_REQUEST_SIZE);
|
||||
if (conn == NULL) {
|
||||
|
|
@ -5405,7 +5405,7 @@ static void *master_thread(void *thread_func_param) {
|
|||
struct pollfd *pfd;
|
||||
int i;
|
||||
|
||||
Utils::setThreadName("ntopng-mongoose");
|
||||
Utils::setThreadName("n-mongoose");
|
||||
|
||||
// Increase priority of the master thread
|
||||
#if defined(_WIN32)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue