sysevent_post_event - post system event for applications
cc [ flag... ] file... -lsysevent -lnvpair [ library... ] #include <libsysevent.h> #include <libnvpair.h> int sysevent_post_event(char *class, char *subclass, char *vendor, char *publisher, nvlist_t *attr_list, sysevent_id_t *eid);
attr_list
class
eid
publisher
subclass
vendor
The sysevent_post_event() function causes a system event of the specified class, subclass, vendor, and publisher to be generated on behalf of the caller and queued for delivery to the sysevent daemon syseventd(1M).
The vendor should be the company stock symbol (or similarly enduring identifier) of the event posting application. The publisher should be the name of the application generating the event.
For example, all events posted by Sun applications begin with the company's stock symbol, "SUNW". The publisher is usually the name of the application generating the system event. A system event generated by devfsadm(1M) has a publisher string of devfsadm.
The publisher information is used by sysevent consumers to filter unwanted event publishers.
Upon successful queuing of the system event, a unique identifier is assigned to eid.
The sysevent_post_event() function returns 0 if the system event has been queued successfully for delivery. Otherwise it returns -1 and sets errno to indicate the error.
The sysevent_post_event() function will fail if:
ENOMEM
EIO
EINVAL
EPERM
EFAULT
Example 1 Post a system event event with no attributes.
The following example posts a system event event with no attributes.
if (sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS", "SUNW", argv[0], NULL), &eid == -1) { fprintf(stderr, "error logging system event\n"); }
Example 2 Post a system event with two name-value pair attributes.
The following example posts a system event event with two name-value pair attributes, an integer value and a string.
nvlist_t *attr_list; uint32_t uint32_val = 0XFFFFFFFF; char *string_val = "string value data"; if (nvlist_alloc(&attr_list, 0, 0) == 0) { err = nvlist_add_uint32(attr_list, "uint32 data", uint32_val); if (err == 0) err = nvlist_add_string(attr_list, "str data", string_val); if (err == 0) err = sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS", "SUNW", argv[0], attr_list, &eid); if (err != 0) fprintf(stderr, "error logging system event\n"); nvlist_free(attr_list); }
See attributes(5) for descriptions of the following attributes:
|
devfsadm(1M), syseventd(1M), nvlist_add_boolean(3NVPAIR), nvlist_alloc(3NVPAIR), attributes(5)
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |