-static void procevent_dispatch_notification(long pid,
- const char *type, /* {{{ */
- gauge_t value, char *process,
- long long unsigned int timestamp) {
- char *buf = NULL;
- notification_t n = {NOTIF_FAILURE, cdtime(), "", "", "procevent", "", "", "",
- NULL};
-
- if (value == 1)
- n.severity = NOTIF_OKAY;
-
- sstrncpy(n.host, hostname_g, sizeof(n.host));
- sstrncpy(n.plugin_instance, process, sizeof(n.plugin_instance));
- sstrncpy(n.type, "gauge", sizeof(n.type));
- sstrncpy(n.type_instance, "process_status", sizeof(n.type_instance));
-
- gen_message_payload(value, pid, process, timestamp, &buf);
-
- notification_meta_t *m = calloc(1, sizeof(*m));
-
- if (m == NULL) {
- sfree(buf);
- ERROR("procevent 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("procevent plugin: notification message: %s",
- n.meta->nm_value.nm_string);
-
- DEBUG("procevent plugin: dispatching state %d for PID %ld (%s)", (int)value,
- pid, process);
-
- plugin_dispatch_notification(&n);
- plugin_notification_meta_free(n.meta);
-
- // strdup'd in gen_message_payload
- if (buf != NULL)
- sfree(buf);
-}
-