- return (-1);
- } /* if (sysevent_thread_error != 0) */
-
- pthread_mutex_lock(&sysevent_lock);
-
- while (ring.head != ring.tail) {
- long long unsigned int timestamp;
- int is_match = 1;
- char *match_str = NULL;
- int next = ring.tail + 1;
-
- if (next >= ring.maxLen)
- next = 0;
-
- DEBUG("sysevent plugin: reading from ring buffer: %s",
- ring.buffer[ring.tail]);
-
- timestamp = ring.timestamp[ring.tail];
-
-#if HAVE_YAJL_V2
- // Try to parse JSON, and if it fails, fall back to plain string
- yajl_val node = NULL;
- char errbuf[1024];
- errbuf[0] = 0;
- node = yajl_tree_parse((const char *)ring.buffer[ring.tail], errbuf,
- sizeof(errbuf));
-
- if (node != NULL) {
- // JSON rsyslog data
-
- // If we have any regex filters, we need to see if the message portion of
- // the data matches any of them (otherwise we're not interested)
- if (monitor_all_messages == 0) {
- char json_val[listen_buffer_size];
- const char *path[] = {"@message", (const char *)0};
- yajl_val v = yajl_tree_get(node, path, yajl_t_string);
-
- memset(json_val, '\0', listen_buffer_size);
-
- snprintf(json_val, listen_buffer_size, "%s%c", YAJL_GET_STRING(v),
- '\0');
-
- match_str = (char *)&json_val;
- }
- } else {
- // non-JSON rsyslog data
-
- // If we have any regex filters, we need to see if the message data
- // matches any of them (otherwise we're not interested)
- if (monitor_all_messages == 0)
- match_str = ring.buffer[ring.tail];
- }
-#else
- // If we have any regex filters, we need to see if the message data
- // matches any of them (otherwise we're not interested)
- if (monitor_all_messages == 0)
- match_str = ring.buffer[ring.tail];
-#endif
-
- // If we care about matching, do that comparison here
- if (match_str != NULL) {
- is_match = 1;