1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
'\" te
.\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
.\" 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.
.\" 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
.\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH SYSEVENT_POST_EVENT 3SYSEVENT "Jul 24, 2009"
.SH NAME
sysevent_post_event \- post system event for applications
.SH SYNOPSIS
.LP
.nf
\fBcc\fR [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lsysevent\fR \fB -lnvpair \fR [ \fIlibrary\fR\&.\|.\|. ]
#include <libsysevent.h>
#include <libnvpair.h>
\fBint\fR \fBsysevent_post_event\fR(\fBchar *\fR\fIclass\fR, \fBchar *\fR\fIsubclass\fR, \fBchar *\fR\fIvendor\fR,
\fBchar *\fR\fIpublisher\fR, \fBnvlist_t *\fR\fIattr_list\fR, \fBsysevent_id_t *\fR\fIeid\fR);
.fi
.SH PARAMETERS
.sp
.ne 2
.na
\fB\fIattr_list\fR\fR
.ad
.RS 13n
pointer to an \fBnvlist_t\fR, listing the name-value attributes associated with
the event, or \fINULL\fR if there are no such attributes for this event
.RE
.sp
.ne 2
.na
\fB\fIclass\fR\fR
.ad
.RS 13n
pointer to a string defining the event class
.RE
.sp
.ne 2
.na
\fB\fIeid\fR\fR
.ad
.RS 13n
pointer to a system unique identifier
.RE
.sp
.ne 2
.na
\fB\fIpublisher\fR\fR
.ad
.RS 13n
pointer to a string defining the event's publisher nam
.RE
.sp
.ne 2
.na
\fB\fIsubclass\fR\fR
.ad
.RS 13n
pointer to a string defining the event subclass
.RE
.sp
.ne 2
.na
\fB\fIvendor\fR\fR
.ad
.RS 13n
pointer to a string defining the vendor
.RE
.SH DESCRIPTION
.sp
.LP
The \fBsysevent_post_event()\fR 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 \fBsyseventd\fR(8).
.sp
.LP
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.
.sp
.LP
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 \fBdevfsadm\fR(8) has
a publisher string of \fBdevfsadm\fR.
.sp
.LP
The publisher information is used by sysevent consumers to filter unwanted
event publishers.
.sp
.LP
Upon successful queuing of the system event, a unique identifier is assigned to
\fIeid\fR.
.SH RETURN VALUES
.sp
.LP
The \fBsysevent_post_event()\fR function returns \fB0\fR if the system event
has been queued successfully for delivery. Otherwise it returns \fB\(mi1\fR and
sets \fBerrno\fR to indicate the error.
.SH ERRORS
.sp
.LP
The \fBsysevent_post_event()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBENOMEM\fR\fR
.ad
.RS 10n
Insufficient resources to queue the system event.
.RE
.sp
.ne 2
.na
\fB\fBEIO\fR\fR
.ad
.RS 10n
The \fBsyseventd\fR daemon is not responding and events cannot be queued or
delivered at this time.
.RE
.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
Invalid argument.
.RE
.sp
.ne 2
.na
\fB\fBEPERM\fR\fR
.ad
.RS 10n
Permission denied.
.RE
.sp
.ne 2
.na
\fB\fBEFAULT\fR\fR
.ad
.RS 10n
A copy error occurred.
.RE
.SH EXAMPLES
.LP
\fBExample 1 \fRPost a system event event with no attributes.
.sp
.LP
The following example posts a system event event with no attributes.
.sp
.in +2
.nf
if (sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS", "SUNW", argv[0],
NULL), &eid == -1) {
fprintf(stderr, "error logging system event\en");
}
.fi
.in -2
.LP
\fBExample 2 \fRPost a system event with two name-value pair attributes.
.sp
.LP
The following example posts a system event event with two name-value pair
attributes, an integer value and a string.
.sp
.in +2
.nf
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\en");
nvlist_free(attr_list);
}
.fi
.in -2
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Committed
_
MT-Level MT-Safe
.TE
.SH SEE ALSO
.sp
.LP
.BR nvlist_add_boolean (3NVPAIR),
.BR nvlist_alloc (3NVPAIR),
.BR attributes (7),
.BR devfsadm (8),
.BR syseventd (8)
.SH NOTES
.sp
.LP
The \fBlibsysevent\fR interfaces do not work at all in non-global zones.
|