1sysevent_post_event(3SYSESVyEsNtTe)m Event Library Funcstyisoenvsent_post_event(3SYSEVENT)
2
3
4

NAME

6       sysevent_post_event - post system event for applications
7

SYNOPSIS

9       cc  [ flag... ]  file... -lsysevent  -lnvpair  [ library... ]
10       #include <libsysevent.h>
11       #include <libnvpair.h>
12
13       int sysevent_post_event(char *class, char *subclass, char *vendor,
14            char *publisher, nvlist_t *attr_list, sysevent_id_t *eid);
15
16

PARAMETERS

18       attr_list    pointer  to an nvlist_t, listing the name-value attributes
19                    associated with the event, or NULL if there  are  no  such
20                    attributes for this event
21
22
23       class        pointer to a string defining the event class
24
25
26       eid          pointer to a system unique identifier
27
28
29       publisher    pointer to a string defining the event's publisher nam
30
31
32       subclass     pointer to a string defining the event subclass
33
34
35       vendor       pointer to a string defining the vendor
36
37

DESCRIPTION

39       The  sysevent_post_event() function causes a system event of the speci‐
40       fied class, subclass, vendor, and publisher to be generated  on  behalf
41       of  the  caller  and queued for delivery to  the sysevent daemon sysev‐
42       entd(1M).
43
44
45       The vendor should be the company stock symbol  (or  similarly  enduring
46       identifier)  of  the event posting application. The publisher should be
47       the name of the application generating the event.
48
49
50       For example, all events posted by Sun applications begin with the  com‐
51       pany's  stock  symbol, "SUNW". The publisher is usually the name of the
52       application generating the system event. A system  event  generated  by
53       devfsadm(1M) has a publisher string of devfsadm.
54
55
56       The  publisher  information  is  used  by  sysevent consumers to filter
57       unwanted event publishers.
58
59
60       Upon successful queuing of the system event,  a  unique  identifier  is
61       assigned to eid.
62

RETURN VALUES

64       The  sysevent_post_event()  function  returns 0 if the system event has
65       been queued successfully for delivery. Otherwise it returns −1 and sets
66       errno to indicate the error.
67

ERRORS

69       The sysevent_post_event() function will fail if:
70
71       ENOMEM    Insufficient resources to queue the system event.
72
73
74       EIO       The  syseventd  daemon is not responding and events cannot be
75                 queued or delivered at this time.
76
77
78       EINVAL    Invalid argument.
79
80
81       EPERM     Permission denied.
82
83
84       EFAULT    A copy error occurred.
85
86

EXAMPLES

88       Example 1 Post a system event event with no attributes.
89
90
91       The following example posts a system event event with no attributes.
92
93
94         if (sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS", "SUNW", argv[0],
95             NULL), &eid == -1) {
96                 fprintf(stderr, "error logging system event\n");
97         }
98
99
100       Example 2 Post a system event with two name-value pair attributes.
101
102
103       The following example posts a system event event  with  two  name-value
104       pair attributes, an integer value and a string.
105
106
107         nvlist_t        *attr_list;
108         uint32_t        uint32_val = 0XFFFFFFFF;
109         char            *string_val = "string value data";
110
111         if (nvlist_alloc(&attr_list, 0, 0) == 0) {
112                 err = nvlist_add_uint32(attr_list, "uint32 data", uint32_val);
113                 if (err == 0)
114                         err = nvlist_add_string(attr_list, "str data",
115                             string_val);
116                 if (err == 0)
117                         err = sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS",
118                             "SUNW", argv[0], attr_list, &eid);
119                 if (err != 0)
120                         fprintf(stderr, "error logging system event\n");
121                 nvlist_free(attr_list);
122         }
123
124

ATTRIBUTES

126       See attributes(5) for descriptions of the following attributes:
127
128
129
130
131       ┌─────────────────────────────┬─────────────────────────────┐
132       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
133       ├─────────────────────────────┼─────────────────────────────┤
134       │Interface Stability          │Committed                    │
135       ├─────────────────────────────┼─────────────────────────────┤
136       │MT-Level                     │MT-Safe                      │
137       └─────────────────────────────┴─────────────────────────────┘
138

SEE ALSO

140       devfsadm(1M),        syseventd(1M),        nvlist_add_boolean(3NVPAIR),
141       nvlist_alloc(3NVPAIR), attributes(5)
142

NOTES

144       The libsysevent interfaces do not work at all in non-global zones.
145
146
147
148SunOS 5.11                        24 Jul 2009   sysevent_post_event(3SYSEVENT)
Impressum