X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fdpdkevents.c;h=6fd642ba669dba66fef6ec4f003608e9de7d877c;hp=b7429273530f9086677070f31c90c638fc44b380;hb=06a86a60a7dabc685bdbd81ce3d36ea5f7e2c2d4;hpb=e0ec7ff9351918c400b88890d1be2d4de7b0dedb diff --git a/src/dpdkevents.c b/src/dpdkevents.c index b7429273..6fd642ba 100644 --- a/src/dpdkevents.c +++ b/src/dpdkevents.c @@ -66,19 +66,19 @@ typedef struct dpdk_ka_monitor_s { typedef struct dpdk_link_status_config_s { int enabled; - _Bool send_updated; + bool send_updated; uint32_t enabled_port_mask; char port_name[RTE_MAX_ETHPORTS][DATA_MAX_NAME_LEN]; - _Bool notify; + bool notify; } dpdk_link_status_config_t; typedef struct dpdk_keep_alive_config_s { int enabled; - _Bool send_updated; + bool send_updated; uint128_t lcore_mask; dpdk_keepalive_shm_t *shm; char shm_name[DATA_MAX_NAME_LEN]; - _Bool notify; + bool notify; int fd; } dpdk_keep_alive_config_t; @@ -129,12 +129,11 @@ static int dpdk_event_keep_alive_shm_open(void) { shm_name); } - char errbuf[ERR_BUF_SIZE]; int fd = shm_open(shm_name, O_RDONLY, 0); if (fd < 0) { ERROR(DPDK_EVENTS_PLUGIN ": Failed to open %s as SHM:%s. Is DPDK KA " "primary application running?", - shm_name, sstrerror(errno, errbuf, sizeof(errbuf))); + shm_name, STRERRNO); return errno; } @@ -166,8 +165,7 @@ static int dpdk_event_keep_alive_shm_open(void) { ec->config.keep_alive.shm = (dpdk_keepalive_shm_t *)mmap( 0, sizeof(*(ec->config.keep_alive.shm)), PROT_READ, MAP_SHARED, fd, 0); if (ec->config.keep_alive.shm == MAP_FAILED) { - ERROR(DPDK_EVENTS_PLUGIN ": Failed to mmap KA SHM:%s", - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR(DPDK_EVENTS_PLUGIN ": Failed to mmap KA SHM:%s", STRERRNO); close(fd); return errno; } @@ -187,8 +185,8 @@ static void dpdk_events_default_config(void) { /* Link Status */ ec->config.link_status.enabled = 1; ec->config.link_status.enabled_port_mask = ~0; - ec->config.link_status.send_updated = 1; - ec->config.link_status.notify = 0; + ec->config.link_status.send_updated = true; + ec->config.link_status.notify = false; for (int i = 0; i < RTE_MAX_ETHPORTS; i++) { ec->config.link_status.port_name[i][0] = 0; @@ -196,8 +194,8 @@ static void dpdk_events_default_config(void) { /* Keep Alive */ ec->config.keep_alive.enabled = 1; - ec->config.keep_alive.send_updated = 1; - ec->config.keep_alive.notify = 0; + ec->config.keep_alive.send_updated = true; + ec->config.keep_alive.notify = false; /* by default enable 128 cores */ memset(&ec->config.keep_alive.lcore_mask, 1, sizeof(ec->config.keep_alive.lcore_mask)); @@ -488,7 +486,6 @@ static void dpdk_events_gauge_submit(const char *plugin_instance, .plugin = DPDK_EVENTS_PLUGIN, .type = "gauge", .meta = NULL}; - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance)); sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance)); plugin_dispatch_values(&vl); @@ -510,17 +507,17 @@ static int dpdk_events_link_status_dispatch(dpdk_helper_ctx_t *phc) { char dev_name[DATA_MAX_NAME_LEN]; if (ec->config.link_status.port_name[i][0] != 0) { - ssnprintf(dev_name, sizeof(dev_name), "%s", - ec->config.link_status.port_name[i]); + snprintf(dev_name, sizeof(dev_name), "%s", + ec->config.link_status.port_name[i]); } else { - ssnprintf(dev_name, sizeof(dev_name), "port.%d", i); + snprintf(dev_name, sizeof(dev_name), "port.%d", i); } if (ec->config.link_status.notify) { int sev = ec->link_info[i].link_status ? NOTIF_OKAY : NOTIF_WARNING; char msg[DATA_MAX_NAME_LEN]; - ssnprintf(msg, sizeof(msg), "Link Status: %s", - ec->link_info[i].link_status ? "UP" : "DOWN"); + snprintf(msg, sizeof(msg), "Link Status: %s", + ec->link_info[i].link_status ? "UP" : "DOWN"); dpdk_events_notification_dispatch(sev, dev_name, ec->link_info[i].read_time, msg); } else { @@ -556,7 +553,7 @@ static void dpdk_events_keep_alive_dispatch(dpdk_helper_ctx_t *phc) { } char core_name[DATA_MAX_NAME_LEN]; - ssnprintf(core_name, sizeof(core_name), "lcore%u", i); + snprintf(core_name, sizeof(core_name), "lcore%u", i); if (!ec->config.keep_alive.send_updated || (ec->core_info[i].lcore_state != @@ -571,34 +568,34 @@ static void dpdk_events_keep_alive_dispatch(dpdk_helper_ctx_t *phc) { switch (ec->config.keep_alive.shm->core_state[i]) { case RTE_KA_STATE_ALIVE: sev = NOTIF_OKAY; - ssnprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: ALIVE", i); + snprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: ALIVE", i); break; case RTE_KA_STATE_MISSING: - ssnprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: MISSING", i); + snprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: MISSING", i); sev = NOTIF_WARNING; break; case RTE_KA_STATE_DEAD: - ssnprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: DEAD", i); + snprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: DEAD", i); sev = NOTIF_FAILURE; break; case RTE_KA_STATE_UNUSED: - ssnprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: UNUSED", i); + snprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: UNUSED", i); sev = NOTIF_OKAY; break; case RTE_KA_STATE_GONE: - ssnprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: GONE", i); + snprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: GONE", i); sev = NOTIF_FAILURE; break; case RTE_KA_STATE_DOZING: - ssnprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: DOZING", i); + snprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: DOZING", i); sev = NOTIF_OKAY; break; case RTE_KA_STATE_SLEEP: - ssnprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: SLEEP", i); + snprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: SLEEP", i); sev = NOTIF_OKAY; break; default: - ssnprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: UNKNOWN", i); + snprintf(msg, sizeof(msg), "lcore %u Keep Alive Status: UNKNOWN", i); sev = NOTIF_FAILURE; }