2 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
4 .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
5 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH SYSEVENT_POST_EVENT 3SYSEVENT "Jul 24, 2009"
8 sysevent_post_event \- post system event for applications
12 \fBcc\fR [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lsysevent\fR \fB -lnvpair \fR [ \fIlibrary\fR\&.\|.\|. ]
13 #include <libsysevent.h>
14 #include <libnvpair.h>
16 \fBint\fR \fBsysevent_post_event\fR(\fBchar *\fR\fIclass\fR, \fBchar *\fR\fIsubclass\fR, \fBchar *\fR\fIvendor\fR,
17 \fBchar *\fR\fIpublisher\fR, \fBnvlist_t *\fR\fIattr_list\fR, \fBsysevent_id_t *\fR\fIeid\fR);
27 pointer to an \fBnvlist_t\fR, listing the name-value attributes associated with
28 the event, or \fINULL\fR if there are no such attributes for this event
37 pointer to a string defining the event class
46 pointer to a system unique identifier
55 pointer to a string defining the event's publisher nam
64 pointer to a string defining the event subclass
73 pointer to a string defining the vendor
79 The \fBsysevent_post_event()\fR function causes a system event of the specified
80 class, subclass, vendor, and publisher to be generated on behalf of the caller
81 and queued for delivery to the sysevent daemon \fBsyseventd\fR(1M).
84 The vendor should be the company stock symbol (or similarly enduring
85 identifier) of the event posting application. The publisher should be the name
86 of the application generating the event.
89 For example, all events posted by Sun applications begin with the company's
90 stock symbol, "SUNW". The publisher is usually the name of the application
91 generating the system event. A system event generated by \fBdevfsadm\fR(1M) has
92 a publisher string of \fBdevfsadm\fR.
95 The publisher information is used by sysevent consumers to filter unwanted
99 Upon successful queuing of the system event, a unique identifier is assigned to
104 The \fBsysevent_post_event()\fR function returns \fB0\fR if the system event
105 has been queued successfully for delivery. Otherwise it returns \fB\(mi1\fR and
106 sets \fBerrno\fR to indicate the error.
110 The \fBsysevent_post_event()\fR function will fail if:
117 Insufficient resources to queue the system event.
126 The \fBsyseventd\fR daemon is not responding and events cannot be queued or
127 delivered at this time.
154 A copy error occurred.
159 \fBExample 1 \fRPost a system event event with no attributes.
162 The following example posts a system event event with no attributes.
167 if (sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS", "SUNW", argv[0],
169 fprintf(stderr, "error logging system event\en");
175 \fBExample 2 \fRPost a system event with two name-value pair attributes.
178 The following example posts a system event event with two name-value pair
179 attributes, an integer value and a string.
185 uint32_t uint32_val = 0XFFFFFFFF;
186 char *string_val = "string value data";
188 if (nvlist_alloc(&attr_list, 0, 0) == 0) {
189 err = nvlist_add_uint32(attr_list, "uint32 data", uint32_val);
191 err = nvlist_add_string(attr_list, "str data",
194 err = sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS",
195 "SUNW", argv[0], attr_list, &eid);
197 fprintf(stderr, "error logging system event\en");
198 nvlist_free(attr_list);
206 See \fBattributes\fR(5) for descriptions of the following attributes:
214 ATTRIBUTE TYPE ATTRIBUTE VALUE
216 Interface Stability Committed
224 \fBdevfsadm\fR(1M), \fBsyseventd\fR(1M), \fBnvlist_add_boolean\fR(3NVPAIR),
225 \fBnvlist_alloc\fR(3NVPAIR), \fBattributes\fR(5)
229 The \fBlibsysevent\fR interfaces do not work at all in non-global zones.