2 * collectd - src/connectivity.c
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
24 * Andrew Bays <abays at redhat.com>
25 * Aneesh Puttur <aputtur at redhat.com>
32 #include "utils_complain.h"
33 #include "utils_ignorelist.h"
35 #include <asm/types.h>
38 #include <netinet/in.h>
42 #include <sys/socket.h>
45 #include <libmnl/libmnl.h>
46 #include <linux/netlink.h>
47 #include <linux/rtnetlink.h>
49 #include <yajl/yajl_common.h>
50 #include <yajl/yajl_gen.h>
51 #if HAVE_YAJL_YAJL_VERSION_H
52 #include <yajl/yajl_version.h>
54 #if defined(YAJL_MAJOR) && (YAJL_MAJOR > 1)
55 #define HAVE_YAJL_V2 1
58 #define MYPROTO NETLINK_ROUTE
60 #define LINK_STATE_DOWN 0
61 #define LINK_STATE_UP 1
62 #define LINK_STATE_UNKNOWN 2
64 #define CONNECTIVITY_DOMAIN_FIELD "domain"
65 #define CONNECTIVITY_DOMAIN_VALUE "stateChange"
66 #define CONNECTIVITY_EVENT_ID_FIELD "eventId"
67 #define CONNECTIVITY_EVENT_NAME_FIELD "eventName"
68 #define CONNECTIVITY_EVENT_NAME_DOWN_VALUE "down"
69 #define CONNECTIVITY_EVENT_NAME_UP_VALUE "up"
70 #define CONNECTIVITY_LAST_EPOCH_MICROSEC_FIELD "lastEpochMicrosec"
71 #define CONNECTIVITY_PRIORITY_FIELD "priority"
72 #define CONNECTIVITY_PRIORITY_VALUE "high"
73 #define CONNECTIVITY_REPORTING_ENTITY_NAME_FIELD "reportingEntityName"
74 #define CONNECTIVITY_REPORTING_ENTITY_NAME_VALUE "collectd connectivity plugin"
75 #define CONNECTIVITY_SEQUENCE_FIELD "sequence"
76 #define CONNECTIVITY_SEQUENCE_VALUE "0"
77 #define CONNECTIVITY_SOURCE_NAME_FIELD "sourceName"
78 #define CONNECTIVITY_START_EPOCH_MICROSEC_FIELD "startEpochMicrosec"
79 #define CONNECTIVITY_VERSION_FIELD "version"
80 #define CONNECTIVITY_VERSION_VALUE "1.0"
82 #define CONNECTIVITY_NEW_STATE_FIELD "newState"
83 #define CONNECTIVITY_NEW_STATE_FIELD_DOWN_VALUE "outOfService"
84 #define CONNECTIVITY_NEW_STATE_FIELD_UP_VALUE "inService"
85 #define CONNECTIVITY_OLD_STATE_FIELD "oldState"
86 #define CONNECTIVITY_OLD_STATE_FIELD_DOWN_VALUE "outOfService"
87 #define CONNECTIVITY_OLD_STATE_FIELD_UP_VALUE "inService"
88 #define CONNECTIVITY_STATE_CHANGE_FIELDS_FIELD "stateChangeFields"
89 #define CONNECTIVITY_STATE_CHANGE_FIELDS_VERSION_FIELD \
90 "stateChangeFieldsVersion"
91 #define CONNECTIVITY_STATE_CHANGE_FIELDS_VERSION_VALUE "1.0"
92 #define CONNECTIVITY_STATE_INTERFACE_FIELD "stateInterface"
97 struct interface_list_s {
101 uint32_t prev_status;
103 long long unsigned int timestamp;
105 struct interface_list_s *next;
107 typedef struct interface_list_s interface_list_t;
112 static ignorelist_t *ignorelist = NULL;
114 static interface_list_t *interface_list_head = NULL;
115 static int monitor_all_interfaces = 0;
117 static int connectivity_thread_loop = 0;
118 static int connectivity_thread_error = 0;
119 static pthread_t connectivity_thread_id;
120 static pthread_mutex_t connectivity_lock = PTHREAD_MUTEX_INITIALIZER;
121 static pthread_cond_t connectivity_cond = PTHREAD_COND_INITIALIZER;
122 static struct mnl_socket *sock;
123 static int event_id = 0;
125 static const char *config_keys[] = {"Interface"};
126 static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
132 static int gen_message_payload(int state, int old_state, const char *interface,
133 long long unsigned int timestamp, char **buf) {
134 const unsigned char *buf2;
136 char json_str[DATA_MAX_NAME_LEN];
138 #if !defined(HAVE_YAJL_V2)
139 yajl_gen_config conf = {};
146 g = yajl_gen_alloc(NULL);
147 yajl_gen_config(g, yajl_gen_beautify, 0);
150 g = yajl_gen_alloc(&conf, NULL);
155 // *** BEGIN common event header ***
157 if (yajl_gen_map_open(g) != yajl_gen_status_ok)
161 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_DOMAIN_FIELD,
162 strlen(CONNECTIVITY_DOMAIN_FIELD)) != yajl_gen_status_ok)
165 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_DOMAIN_VALUE,
166 strlen(CONNECTIVITY_DOMAIN_VALUE)) != yajl_gen_status_ok)
170 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_EVENT_ID_FIELD,
171 strlen(CONNECTIVITY_EVENT_ID_FIELD)) !=
175 event_id = event_id + 1;
176 int event_id_len = sizeof(char) * sizeof(int) * 4 + 1;
177 memset(json_str, '\0', DATA_MAX_NAME_LEN);
178 snprintf(json_str, event_id_len, "%d", event_id);
180 if (yajl_gen_number(g, json_str, strlen(json_str)) != yajl_gen_status_ok) {
185 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_EVENT_NAME_FIELD,
186 strlen(CONNECTIVITY_EVENT_NAME_FIELD)) !=
190 int event_name_len = 0;
191 event_name_len = event_name_len + strlen(interface); // interface name
192 event_name_len = event_name_len + (state == 0 ? 4 : 2); // "down" or "up"
194 event_name_len + 12; // "interface", 2 spaces and null-terminator
195 memset(json_str, '\0', DATA_MAX_NAME_LEN);
196 snprintf(json_str, event_name_len, "interface %s %s", interface,
197 (state == 0 ? CONNECTIVITY_EVENT_NAME_DOWN_VALUE
198 : CONNECTIVITY_EVENT_NAME_UP_VALUE));
200 if (yajl_gen_string(g, (u_char *)json_str, strlen(json_str)) !=
201 yajl_gen_status_ok) {
206 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_LAST_EPOCH_MICROSEC_FIELD,
207 strlen(CONNECTIVITY_LAST_EPOCH_MICROSEC_FIELD)) !=
211 int last_epoch_microsec_len =
212 sizeof(char) * sizeof(long long unsigned int) * 4 + 1;
213 memset(json_str, '\0', DATA_MAX_NAME_LEN);
214 snprintf(json_str, last_epoch_microsec_len, "%llu",
215 (long long unsigned int)CDTIME_T_TO_US(cdtime()));
217 if (yajl_gen_number(g, json_str, strlen(json_str)) != yajl_gen_status_ok) {
222 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_PRIORITY_FIELD,
223 strlen(CONNECTIVITY_PRIORITY_FIELD)) !=
227 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_PRIORITY_VALUE,
228 strlen(CONNECTIVITY_PRIORITY_VALUE)) !=
232 // reportingEntityName
233 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_REPORTING_ENTITY_NAME_FIELD,
234 strlen(CONNECTIVITY_REPORTING_ENTITY_NAME_FIELD)) !=
238 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_REPORTING_ENTITY_NAME_VALUE,
239 strlen(CONNECTIVITY_REPORTING_ENTITY_NAME_VALUE)) !=
244 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_SEQUENCE_FIELD,
245 strlen(CONNECTIVITY_SEQUENCE_FIELD)) !=
249 if (yajl_gen_number(g, CONNECTIVITY_SEQUENCE_VALUE,
250 strlen(CONNECTIVITY_SEQUENCE_VALUE)) !=
255 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_SOURCE_NAME_FIELD,
256 strlen(CONNECTIVITY_SOURCE_NAME_FIELD)) !=
260 if (yajl_gen_string(g, (u_char *)interface, strlen(interface)) !=
264 // startEpochMicrosec
265 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_START_EPOCH_MICROSEC_FIELD,
266 strlen(CONNECTIVITY_START_EPOCH_MICROSEC_FIELD)) !=
270 int start_epoch_microsec_len =
271 sizeof(char) * sizeof(long long unsigned int) * 4 + 1;
272 memset(json_str, '\0', DATA_MAX_NAME_LEN);
273 snprintf(json_str, start_epoch_microsec_len, "%llu",
274 (long long unsigned int)timestamp);
276 if (yajl_gen_number(g, json_str, strlen(json_str)) != yajl_gen_status_ok) {
281 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_VERSION_FIELD,
282 strlen(CONNECTIVITY_VERSION_FIELD)) != yajl_gen_status_ok)
285 if (yajl_gen_number(g, CONNECTIVITY_VERSION_VALUE,
286 strlen(CONNECTIVITY_VERSION_VALUE)) != yajl_gen_status_ok)
289 // *** END common event header ***
291 // *** BEGIN state change fields ***
293 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_STATE_CHANGE_FIELDS_FIELD,
294 strlen(CONNECTIVITY_STATE_CHANGE_FIELDS_FIELD)) !=
298 if (yajl_gen_map_open(g) != yajl_gen_status_ok)
302 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_NEW_STATE_FIELD,
303 strlen(CONNECTIVITY_NEW_STATE_FIELD)) !=
308 (state == 0 ? strlen(CONNECTIVITY_NEW_STATE_FIELD_DOWN_VALUE)
309 : strlen(CONNECTIVITY_NEW_STATE_FIELD_UP_VALUE));
312 g, (u_char *)(state == 0 ? CONNECTIVITY_NEW_STATE_FIELD_DOWN_VALUE
313 : CONNECTIVITY_NEW_STATE_FIELD_UP_VALUE),
314 new_state_len) != yajl_gen_status_ok)
318 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_OLD_STATE_FIELD,
319 strlen(CONNECTIVITY_OLD_STATE_FIELD)) !=
324 (old_state == 0 ? strlen(CONNECTIVITY_OLD_STATE_FIELD_DOWN_VALUE)
325 : strlen(CONNECTIVITY_OLD_STATE_FIELD_UP_VALUE));
328 g, (u_char *)(old_state == 0 ? CONNECTIVITY_OLD_STATE_FIELD_DOWN_VALUE
329 : CONNECTIVITY_OLD_STATE_FIELD_UP_VALUE),
330 old_state_len) != yajl_gen_status_ok)
333 // stateChangeFieldsVersion
334 if (yajl_gen_string(g,
335 (u_char *)CONNECTIVITY_STATE_CHANGE_FIELDS_VERSION_FIELD,
336 strlen(CONNECTIVITY_STATE_CHANGE_FIELDS_VERSION_FIELD)) !=
340 if (yajl_gen_number(g, CONNECTIVITY_STATE_CHANGE_FIELDS_VERSION_VALUE,
341 strlen(CONNECTIVITY_STATE_CHANGE_FIELDS_VERSION_VALUE)) !=
346 if (yajl_gen_string(g, (u_char *)CONNECTIVITY_STATE_INTERFACE_FIELD,
347 strlen(CONNECTIVITY_STATE_INTERFACE_FIELD)) !=
351 if (yajl_gen_string(g, (u_char *)interface, strlen(interface)) !=
355 if (yajl_gen_map_close(g) != yajl_gen_status_ok)
358 // *** END state change fields ***
360 if (yajl_gen_map_close(g) != yajl_gen_status_ok)
363 if (yajl_gen_get_buf(g, &buf2, &len) != yajl_gen_status_ok)
366 *buf = malloc(strlen((char *)buf2) + 1);
370 ERROR("connectivity plugin: malloc failed during gen_message_payload: %s",
371 sstrerror(errno, errbuf, sizeof(errbuf)));
375 sstrncpy(*buf, (char *)buf2, strlen((char *)buf2) + 1);
383 ERROR("connectivity plugin: gen_message_payload failed to generate JSON");
387 static interface_list_t *add_interface(const char *interface, int status,
389 interface_list_t *il;
392 il = malloc(sizeof(*il));
395 ERROR("connectivity plugin: malloc failed during add_interface: %s",
396 sstrerror(errno, errbuf, sizeof(errbuf)));
400 interface2 = strdup(interface);
401 if (interface2 == NULL) {
404 ERROR("connectivity plugin: strdup failed during add_interface: %s",
405 sstrerror(errno, errbuf, sizeof(errbuf)));
409 il->interface = interface2;
411 il->prev_status = prev_status;
412 il->timestamp = (long long unsigned int)CDTIME_T_TO_US(cdtime());
414 il->next = interface_list_head;
415 interface_list_head = il;
417 DEBUG("connectivity plugin: added interface %s", interface2);
422 static int connectivity_link_state(struct nlmsghdr *msg) {
424 struct ifinfomsg *ifi = mnl_nlmsg_get_payload(msg);
426 const char *dev = NULL;
428 pthread_mutex_lock(&connectivity_lock);
430 interface_list_t *il = NULL;
432 /* Scan attribute list for device name. */
433 mnl_attr_for_each(attr, msg, sizeof(*ifi)) {
434 if (mnl_attr_get_type(attr) != IFLA_IFNAME)
437 if (mnl_attr_validate(attr, MNL_TYPE_STRING) < 0) {
438 ERROR("connectivity plugin: connectivity_link_state: IFLA_IFNAME "
441 pthread_mutex_unlock(&connectivity_lock);
445 dev = mnl_attr_get_str(attr);
447 // Check the list of interfaces we should monitor, if we've chosen
448 // a subset. If we don't care about this one, abort.
449 if (ignorelist_match(ignorelist, dev) != 0) {
450 DEBUG("connectivity plugin: Ignoring link state change for unmonitored "
456 for (il = interface_list_head; il != NULL; il = il->next)
457 if (strcmp(dev, il->interface) == 0)
460 uint32_t prev_status;
463 // We haven't encountered this interface yet, so add it to the linked list
464 il = add_interface(dev, LINK_STATE_UNKNOWN, LINK_STATE_UNKNOWN);
467 ERROR("connectivity plugin: unable to add interface %s during "
468 "connectivity_link_state",
474 prev_status = il->status;
476 ((ifi->ifi_flags & IFF_RUNNING) ? LINK_STATE_UP : LINK_STATE_DOWN);
477 il->timestamp = (long long unsigned int)CDTIME_T_TO_US(cdtime());
479 // If the new status is different than the previous status,
480 // store the previous status and set sent to zero
481 if (il->status != prev_status) {
482 il->prev_status = prev_status;
486 DEBUG("connectivity plugin (%llu): Interface %s status is now %s",
487 il->timestamp, dev, ((ifi->ifi_flags & IFF_RUNNING) ? "UP" : "DOWN"));
489 // no need to loop again, we found the interface name attr
490 // (otherwise the first if-statement in the loop would
491 // have moved us on with 'continue')
495 pthread_mutex_unlock(&connectivity_lock);
500 static int msg_handler(struct nlmsghdr *msg) {
501 switch (msg->nlmsg_type) {
507 // Not of interest in current version
510 connectivity_link_state(msg);
513 ERROR("connectivity plugin: msg_handler: Unknown netlink nlmsg_type %d\n",
520 static int read_event(struct mnl_socket *nl,
521 int (*msg_handler)(struct nlmsghdr *)) {
530 status = mnl_socket_recvfrom(nl, buf, sizeof(buf));
533 /* Socket non-blocking so bail out once we have read everything */
534 if (errno == EWOULDBLOCK || errno == EAGAIN)
537 /* Anything else is an error */
538 ERROR("connectivity plugin: read_event: Error mnl_socket_recvfrom: %d\n",
544 DEBUG("connectivity plugin: read_event: EOF\n");
547 /* We need to handle more than one message per 'recvmsg' */
548 for (h = (struct nlmsghdr *)buf; NLMSG_OK(h, (unsigned int)status);
549 h = NLMSG_NEXT(h, status)) {
551 if (h->nlmsg_type == NLMSG_DONE)
554 /* Message is some kind of error */
555 if (h->nlmsg_type == NLMSG_ERROR) {
556 ERROR("connectivity plugin: read_event: Message is an error\n");
560 /* Call message handler */
562 ret = (*msg_handler)(h);
564 ERROR("connectivity plugin: read_event: Message handler error %d\n",
569 ERROR("connectivity plugin: read_event: Error NULL message handler\n");
577 static void *connectivity_thread(void *arg) /* {{{ */
579 pthread_mutex_lock(&connectivity_lock);
581 while (connectivity_thread_loop > 0) {
584 pthread_mutex_unlock(&connectivity_lock);
586 status = read_event(sock, msg_handler);
588 pthread_mutex_lock(&connectivity_lock);
591 connectivity_thread_error = 1;
595 if (connectivity_thread_loop <= 0)
597 } /* while (connectivity_thread_loop > 0) */
599 pthread_mutex_unlock(&connectivity_lock);
602 } /* }}} void *connectivity_thread */
604 static int start_thread(void) /* {{{ */
608 pthread_mutex_lock(&connectivity_lock);
610 if (connectivity_thread_loop != 0) {
611 pthread_mutex_unlock(&connectivity_lock);
615 connectivity_thread_loop = 1;
616 connectivity_thread_error = 0;
619 sock = mnl_socket_open(NETLINK_ROUTE);
622 "connectivity plugin: connectivity_thread: mnl_socket_open failed.");
623 pthread_mutex_unlock(&connectivity_lock);
627 if (mnl_socket_bind(sock, RTMGRP_LINK, MNL_SOCKET_AUTOPID) < 0) {
629 "connectivity plugin: connectivity_thread: mnl_socket_bind failed.");
630 pthread_mutex_unlock(&connectivity_lock);
635 status = plugin_thread_create(&connectivity_thread_id, /* attr = */ NULL,
637 /* arg = */ (void *)0, "connectivity");
639 connectivity_thread_loop = 0;
640 ERROR("connectivity plugin: Starting thread failed.");
641 pthread_mutex_unlock(&connectivity_lock);
642 mnl_socket_close(sock);
646 pthread_mutex_unlock(&connectivity_lock);
648 } /* }}} int start_thread */
650 static int stop_thread(int shutdown) /* {{{ */
655 mnl_socket_close(sock);
657 pthread_mutex_lock(&connectivity_lock);
659 if (connectivity_thread_loop == 0) {
660 pthread_mutex_unlock(&connectivity_lock);
664 connectivity_thread_loop = 0;
665 pthread_cond_broadcast(&connectivity_cond);
666 pthread_mutex_unlock(&connectivity_lock);
669 // Since the thread is blocking, calling pthread_join
670 // doesn't actually succeed in stopping it. It will stick around
671 // until a NETLINK message is received on the socket (at which
672 // it will realize that "connectivity_thread_loop" is 0 and will
673 // break out of the read loop and be allowed to die). This is
674 // fine when the process isn't supposed to be exiting, but in
675 // the case of a process shutdown, we don't want to have an
676 // idle thread hanging around. Calling pthread_cancel here in
677 // the case of a shutdown is just assures that the thread is
678 // gone and that the process has been fully terminated.
680 DEBUG("connectivity plugin: Canceling thread for process shutdown");
682 status = pthread_cancel(connectivity_thread_id);
685 ERROR("connectivity plugin: Unable to cancel thread: %d", status);
689 status = pthread_join(connectivity_thread_id, /* return = */ NULL);
691 ERROR("connectivity plugin: Stopping thread failed.");
696 pthread_mutex_lock(&connectivity_lock);
697 memset(&connectivity_thread_id, 0, sizeof(connectivity_thread_id));
698 connectivity_thread_error = 0;
699 pthread_mutex_unlock(&connectivity_lock);
701 DEBUG("connectivity plugin: Finished requesting stop of thread");
704 } /* }}} int stop_thread */
706 static int connectivity_init(void) /* {{{ */
708 if (interface_list_head == NULL) {
709 NOTICE("connectivity plugin: No interfaces have been selected, so all will "
711 monitor_all_interfaces = 1;
714 return (start_thread());
715 } /* }}} int connectivity_init */
717 static int connectivity_config(const char *key, const char *value) /* {{{ */
719 if (ignorelist == NULL)
720 ignorelist = ignorelist_create(/* invert = */ 1);
722 if (strcasecmp(key, "Interface") == 0) {
723 ignorelist_add(ignorelist, value);
729 } /* }}} int connectivity_config */
731 static void connectivity_dispatch_notification(
732 const char *interface, const char *type, /* {{{ */
733 gauge_t value, gauge_t old_value, long long unsigned int timestamp) {
736 NOTIF_FAILURE, cdtime(), "", "", "connectivity", "", "", "", NULL};
738 if (value == LINK_STATE_UP)
739 n.severity = NOTIF_OKAY;
741 sstrncpy(n.host, hostname_g, sizeof(n.host));
742 sstrncpy(n.plugin_instance, interface, sizeof(n.plugin_instance));
743 sstrncpy(n.type, "gauge", sizeof(n.type));
744 sstrncpy(n.type_instance, "interface_status", sizeof(n.type_instance));
746 gen_message_payload(value, old_value, interface, timestamp, &buf);
748 notification_meta_t *m = calloc(1, sizeof(*m));
753 ERROR("connectivity plugin: unable to allocate metadata: %s",
754 sstrerror(errno, errbuf, sizeof(errbuf)));
758 sstrncpy(m->name, "ves", sizeof(m->name));
759 m->nm_value.nm_string = sstrdup(buf);
760 m->type = NM_TYPE_STRING;
763 DEBUG("connectivity plugin: notification message: %s",
764 n.meta->nm_value.nm_string);
766 DEBUG("connectivity plugin: dispatching state %d for interface %s",
767 (int)value, interface);
769 plugin_dispatch_notification(&n);
770 plugin_notification_meta_free(n.meta);
772 // malloc'd in gen_message_payload
777 static int connectivity_read(void) /* {{{ */
779 if (connectivity_thread_error != 0) {
780 ERROR("connectivity plugin: The interface thread had a problem. Restarting "
785 for (interface_list_t *il = interface_list_head; il != NULL;
787 il->status = LINK_STATE_UNKNOWN;
788 il->prev_status = LINK_STATE_UNKNOWN;
795 } /* if (connectivity_thread_error != 0) */
797 for (interface_list_t *il = interface_list_head; il != NULL;
798 il = il->next) /* {{{ */
801 uint32_t prev_status;
804 pthread_mutex_lock(&connectivity_lock);
807 prev_status = il->prev_status;
810 if (status != prev_status && sent == 0) {
811 connectivity_dispatch_notification(il->interface, "gauge", status,
812 prev_status, il->timestamp);
816 pthread_mutex_unlock(&connectivity_lock);
817 } /* }}} for (il = interface_list_head; il != NULL; il = il->next) */
820 } /* }}} int connectivity_read */
822 static int connectivity_shutdown(void) /* {{{ */
824 interface_list_t *il;
826 DEBUG("connectivity plugin: Shutting down thread.");
827 if (stop_thread(1) < 0)
830 il = interface_list_head;
832 interface_list_t *il_next;
836 sfree(il->interface);
842 ignorelist_free(ignorelist);
845 } /* }}} int connectivity_shutdown */
847 void module_register(void) {
848 plugin_register_config("connectivity", connectivity_config, config_keys,
850 plugin_register_init("connectivity", connectivity_init);
851 plugin_register_read("connectivity", connectivity_read);
852 plugin_register_shutdown("connectivity", connectivity_shutdown);
853 } /* void module_register */