sysevent_get_vendor_name(3SYSEVENT) System Event Library Functions sysevent_get_vendor_name(3SYSEVENT)NAME
sysevent_get_vendor_name, sysevent_get_pub_name, sysevent_get_pid - get vendor name, publisher name or processor ID of event
SYNOPSIS
cc [flag ...] file ...-lsysevent [library ...]
#include <libsysevent.h>
char *sysevent_get_vendor_name(sysevent_t *ev);
char *sysevent_get_pub_name(sysevent_t *ev);
pid_t sysevent_get_pid(sysevent_t *ev);
PARAMETERS
ev handle to a system event object
DESCRIPTION
The sysevent_get_pub_name() function returns the publisher name for the sysevent handle, ev. The publisher name identifies the name of the
publishing application or kernel subsystem of the sysevent.
The sysevent_get_pid() function returns the process ID for the publishing application or SE_KERN_PID for sysevents originating in the ker-
nel. The publisher name and PID are useful for implementing event acknowledgement.
The sysevent_get_vendor_name() function returns the vendor string for the publishing application or kernel subsystem. A vendor string is
the company's stock symbol that provided the application or kernel subsystem that generated the system event. This information is useful
for filtering sysevents for one or more vendors.
The interface manages the allocation of the vendor and publisher name strings, but it is the caller's responsibility to free the strings
when they are no longer needed by calling free(3MALLOC). If the new vendor and publisher name strings cannot be created, sysevent_get_ven-
dor_name() and sysevent_get_pub_name() return a null pointer and may set errno to ENOMEM to indicate that the storage space available is
insufficient.
EXAMPLES
Example 1: Parse sysevent header information.
The following example parses sysevent header information from an application's event handler.
char *vendor;
char *pub;
void
event_handler(sysevent_t *ev)
{
if (strcmp(EC_PRIV, sysevent_get_class_name(ev)) != 0) {
return;
}
vendor = sysevent_get_vendor_name(ev);
if (strcmp("SUNW", vendor) != 0) {
free(vendor);
return;
}
pub = sysevent_get_pub_name(ev);
if (strcmp("test_daemon", pub) != 0) {
free(vendor);
free(pub);
return;
}
(void) kill(sysevent_get_pid(ev), SIGUSR1);
free(vendor);
free(pub);
}
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Evolving |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO malloc(3MALLOC), attributes(5)SunOS 5.10 17 Mar 2004 sysevent_get_vendor_name(3SYSEVENT)
Check Out this Related Man Page
sysevent_post_event(3SYSEVENT) System Event Library Functions sysevent_post_event(3SYSEVENT)NAME
sysevent_post_event - post system event for applications
SYNOPSIS
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);
PARAMETERS
attr_list pointer to an nvlist_t, listing the name-value attributes associated with the event, or NULL if there are no such attributes
for this event
class pointer to a string defining the event class
eid pointer to a system unique identifier
publisher pointer to a string defining the event's publisher nam
subclass pointer to a string defining the event subclass
vendor pointer to a string defining the vendor
DESCRIPTION
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.
RETURN VALUES
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.
ERRORS
The sysevent_post_event() function will fail if:
ENOMEM Insufficient resources to queue the system event.
EIO The syseventd daemon is not responding and events cannot be queued or delivered at this time.
EINVAL Invalid argument.
EPERM Permission denied.
EFAULT A copy error occurred.
EXAMPLES
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
");
}
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
");
nvlist_free(attr_list);
}
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Evolving |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO devfsadm(1M), syseventd(1M), nvlist_add_boolean(3NVPAIR), nvlist_alloc(3NVPAIR), attributes(5)SunOS 5.11 26 May 2004 sysevent_post_event(3SYSEVENT)