static int connectivity_netlink_thread_error = 0;
static pthread_t connectivity_netlink_thread_id;
static int connectivity_dequeue_thread_loop = 0;
static int connectivity_netlink_thread_error = 0;
static pthread_t connectivity_netlink_thread_id;
static int connectivity_dequeue_thread_loop = 0;
static pthread_t connectivity_dequeue_thread_id;
static pthread_mutex_t connectivity_threads_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t connectivity_data_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t connectivity_cond = PTHREAD_COND_INITIALIZER;
static pthread_t connectivity_dequeue_thread_id;
static pthread_mutex_t connectivity_threads_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t connectivity_data_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t connectivity_cond = PTHREAD_COND_INITIALIZER;
/* Scan attribute list for device name. */
mnl_attr_for_each(attr, msg, sizeof(*ifi)) {
/* Scan attribute list for device name. */
mnl_attr_for_each(attr, msg, sizeof(*ifi)) {
for (il = interface_list_head; il != NULL; il = il->next)
if (strcmp(dev, il->interface) == 0)
break;
for (il = interface_list_head; il != NULL; il = il->next)
if (strcmp(dev, il->interface) == 0)
break;
if (il == NULL) {
// We haven't encountered this interface yet, so add it to the linked list
il = add_interface(dev, LINK_STATE_UNKNOWN, LINK_STATE_UNKNOWN);
if (il == NULL) {
// We haven't encountered this interface yet, so add it to the linked list
il = add_interface(dev, LINK_STATE_UNKNOWN, LINK_STATE_UNKNOWN);
int status = recv(nl, buf, sizeof(buf), recv_flags);
if (status < 0) {
int status = recv(nl, buf, sizeof(buf), recv_flags);
if (status < 0) {
} /* }}} void *connectivity_netlink_thread */
static void *connectivity_dequeue_thread(void *arg) /* {{{ */
} /* }}} void *connectivity_netlink_thread */
static void *connectivity_dequeue_thread(void *arg) /* {{{ */
} /* while (connectivity_dequeue_thread_loop > 0) */
pthread_mutex_unlock(&connectivity_threads_lock);
} /* while (connectivity_dequeue_thread_loop > 0) */
pthread_mutex_unlock(&connectivity_threads_lock);
pthread_mutex_lock(&connectivity_threads_lock);
if (connectivity_netlink_thread_loop != 0) {
pthread_mutex_unlock(&connectivity_threads_lock);
pthread_mutex_lock(&connectivity_threads_lock);
if (connectivity_netlink_thread_loop != 0) {
pthread_mutex_unlock(&connectivity_threads_lock);
connectivity_dequeue_thread_loop = 0;
ERROR("connectivity plugin: Starting dequeue thread failed.");
pthread_mutex_unlock(&connectivity_threads_lock);
connectivity_dequeue_thread_loop = 0;
ERROR("connectivity plugin: Starting dequeue thread failed.");
pthread_mutex_unlock(&connectivity_threads_lock);
pthread_mutex_unlock(&connectivity_threads_lock);
// Let threads waiting on access to the interface list know to move
pthread_mutex_unlock(&connectivity_threads_lock);
// Let threads waiting on access to the interface list know to move
if (shutdown == 1) {
// Since the thread is blocking, calling pthread_join
// doesn't actually succeed in stopping it. It will stick around
if (shutdown == 1) {
// Since the thread is blocking, calling pthread_join
// doesn't actually succeed in stopping it. It will stick around
pthread_mutex_lock(&connectivity_threads_lock);
if (connectivity_dequeue_thread_loop == 0) {
pthread_mutex_unlock(&connectivity_threads_lock);
pthread_mutex_lock(&connectivity_threads_lock);
if (connectivity_dequeue_thread_loop == 0) {
pthread_mutex_unlock(&connectivity_threads_lock);
// on such that they'll see the threads termination status
pthread_cond_broadcast(&connectivity_cond);
// on such that they'll see the threads termination status
pthread_cond_broadcast(&connectivity_cond);
pthread_mutex_lock(&connectivity_threads_lock);
memset(&connectivity_dequeue_thread_id, 0,
sizeof(connectivity_dequeue_thread_id));
pthread_mutex_lock(&connectivity_threads_lock);
memset(&connectivity_dequeue_thread_id, 0,
sizeof(connectivity_dequeue_thread_id));
pthread_mutex_unlock(&connectivity_threads_lock);
DEBUG("connectivity plugin: Finished requesting stop of dequeue thread");
pthread_mutex_unlock(&connectivity_threads_lock);
DEBUG("connectivity plugin: Finished requesting stop of dequeue thread");
} /* }}} int connectivity_init */
static int connectivity_config(const char *key, const char *value) /* {{{ */
} /* }}} int connectivity_init */
static int connectivity_config(const char *key, const char *value) /* {{{ */
} /* }}} int connectivity_config */
static void
connectivity_dispatch_notification(const char *interface, const char *type,
gauge_t value, gauge_t old_value,
long long unsigned int timestamp) {
} /* }}} int connectivity_config */
static void
connectivity_dispatch_notification(const char *interface, const char *type,
gauge_t value, gauge_t old_value,
long long unsigned int timestamp) {
- char *buf = NULL;
- notification_t n = {
- NOTIF_FAILURE, cdtime(), "", "", "connectivity", "", "", "", NULL};
sstrncpy(n.host, hostname_g, sizeof(n.host));
sstrncpy(n.plugin_instance, interface, sizeof(n.plugin_instance));
sstrncpy(n.type, "gauge", sizeof(n.type));
sstrncpy(n.type_instance, "interface_status", sizeof(n.type_instance));
sstrncpy(n.host, hostname_g, sizeof(n.host));
sstrncpy(n.plugin_instance, interface, sizeof(n.plugin_instance));
sstrncpy(n.type, "gauge", sizeof(n.type));
sstrncpy(n.type_instance, "interface_status", sizeof(n.type_instance));
gen_message_payload(value, old_value, interface, timestamp, &buf);
notification_meta_t *m = calloc(1, sizeof(*m));
gen_message_payload(value, old_value, interface, timestamp, &buf);
notification_meta_t *m = calloc(1, sizeof(*m));
- if (connectivity_dequeue_thread_error != 0) {
-
- pthread_mutex_unlock(&connectivity_threads_lock);
-
- ERROR("connectivity plugin: The dequeue thread had a problem. Restarting "
- "it.");
-
- stop_dequeue_thread(0);
-
- start_dequeue_thread();
-
- return (-1);
- } /* if (connectivity_dequeue_thread_error != 0) */
-
} /* }}} int connectivity_read */
static int connectivity_shutdown(void) /* {{{ */
{
DEBUG("connectivity plugin: Shutting down thread.");
} /* }}} int connectivity_read */
static int connectivity_shutdown(void) /* {{{ */
{
DEBUG("connectivity plugin: Shutting down thread.");