+static void connectivity_dispatch_notification(const char *interface,
+ const char *type, gauge_t value,
+ gauge_t old_value,
+ cdtime_t timestamp) {
+
+ notification_t n = {(value == LINK_STATE_UP ? NOTIF_OKAY : 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));
+
+ char *buf = NULL;
+
+ gen_message_payload(value, old_value, interface, timestamp, &buf);
+
+ notification_meta_t *m = calloc(1, sizeof(*m));
+
+ if (m == NULL) {
+ sfree(buf);
+ ERROR("connectivity plugin: unable to allocate metadata: %s", STRERRNO);
+ return;
+ }
+
+ sstrncpy(m->name, "ves", sizeof(m->name));
+ m->nm_value.nm_string = sstrdup(buf);
+ m->type = NM_TYPE_STRING;
+ n.meta = m;
+
+ DEBUG("connectivity plugin: notification message: %s",
+ n.meta->nm_value.nm_string);
+
+ DEBUG("connectivity plugin: dispatching state %d for interface %s",
+ (int)value, interface);
+
+ plugin_dispatch_notification(&n);
+ plugin_notification_meta_free(n.meta);
+
+ // strdup'd in gen_message_payload
+ if (buf != NULL)
+ sfree(buf);
+}
+
+// NOTE: Caller MUST hold connectivity_data_lock when calling this function
+static void send_interface_status() {
+ for (interface_list_t *il = interface_list_head; il != NULL;
+ il = il->next) /* {{{ */
+ {
+ uint32_t status = il->status;
+ uint32_t prev_status = il->prev_status;
+ uint32_t sent = il->sent;
+
+ if (status != prev_status && sent == 0) {
+ connectivity_dispatch_notification(il->interface, "gauge", status,
+ prev_status, il->timestamp);
+ il->sent = 1;
+ }
+ } /* }}} for (il = interface_list_head; il != NULL; il = il->next) */
+
+ statuses_to_send = 0;
+}
+
+static void read_interface_status() /* {{{ */