From collectd Wiki
Jump to: navigation, search

The notification_t data structure is used to represent notifications. Data contained in the struct includes:

  • The identification fields also found in value_list_t, but not all rules of the naming schema apply: Each field is optional in notifications.
  • A severity of the notification.
  • A timestamp.
  • A message.

Definition of the struct

The structure is defined in src/plugin.h as follows:

 typedef struct notification_s
   int    severity;
   time_t time;
   char   message[NOTIF_MAX_MSG_LEN];
   char   host[DATA_MAX_NAME_LEN];
   char   plugin[DATA_MAX_NAME_LEN];
   char   plugin_instance[DATA_MAX_NAME_LEN];
   char   type[DATA_MAX_NAME_LEN];
   char   type_instance[DATA_MAX_NAME_LEN];
   notification_meta_t *meta;
 } notification_t;


 notification_t n = { NOTIF_WARNING, time(NULL), "", "", "ipmi",
   "", "", "", NULL };
 sstrncpy (, hostname_g, sizeof (;
 sstrncpy (n.type_instance, list_item->sensor_name,
     sizeof (n.type_instance));
 sstrncpy (n.type, list_item->sensor_type, sizeof (n.type));
 ssnprintf (n.message, sizeof (n.message),
     "sensor %s not present", list_item->sensor_name);
 plugin_dispatch_notification (&n);