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
|
'\"macro stdmacro
.\"
.\" Copyright (c) 2015 Red Hat.
.\" Copyright (c) 2011-2012 Nathan Scott. All Rights Reserved.
.\"
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
.\" for more details.
.\"
.\"
.TH PMDAEVENTQUEUE 3 "PCP" "Performance Co-Pilot"
.ds xM pmdaEventQueue
.SH NAME
.ad l
\f3pmdaEventNewQueue\f1,
\f3pmdaEventNewActiveQueue\f1,
\f3pmdaEventQueueHandle\f1,
\f3pmdaEventQueueAppend\f1,
\f3pmdaEventQueueShutdown\f1,
\f3pmdaEventQueueRecords\f1,
\f3pmdaEventQueueClients\f1,
\f3pmdaEventQueueCounter\f1,
\f3pmdaEventQueueBytes\f1,
\f3pmdaEventQueueMemory\f1 \- utilities for PMDAs managing event queues
.SH "C SYNOPSIS"
.ft 3
.ad l
.hy 0
#include <pcp/pmapi.h>
.br
#include <pcp/pmda.h>
.sp
int pmdaEventNewQueue(const char *\fIname\fP, size_t \fImaxmem\fP);
.br
int pmdaEventNewActiveQueue(const char *\fIname\fP,
'in +\w'int pmdaEventNewActiveQueue('u
size_t\ \fImaxmem\fP,
int\ \fInclients\fP);
.in
.br
int pmdaEventQueueHandle(const char *\fIname\fP);
.br
int pmdaEventQueueAppend(int \fIhandle\fP,
'in +\w'int pmdaEventQueueAppend('u
void\ *\fIbuffer\fP,
size_t\ \fIbytes\fP,
struct\ timeval\ *\fItv\fP);
.in
.br
int pmdaEventQueueShutdown(int \fIhandle\fP);
.sp
typedef int (*pmdaEventDecodeCallBack)(int,
'in +\w'typedef int ('u
void\ *,
int,
struct\ timeval\ *,
void\ *);
.in
.br
int pmdaEventQueueRecords(int \fIhandle\fP,
'in +\w'int pmdaEventQueueRecords('u
pmAtomValue\ *\fIavp\fP,
int\ \fIcontext\fP,
pmdaEventDecodeCallBack\ \fIdecoder\fP,
void\ *\fIdata\fP);
.in
.br
int pmdaEventQueueClients(int \fIhandle\fP, pmAtomValue *\fIavp\fP);
.br
int pmdaEventQueueCounter(int \fIhandle\fP, pmAtomValue *\fIavp\fP);
.br
int pmdaEventQueueBytes(int \fIhandle\fP, pmAtomValue *\fIavp\fP);
.br
int pmdaEventQueueMemory(int \fIhandle\fP, pmAtomValue *\fIavp\fP);
.sp
cc ... \-lpcp_pmda \-lpcp
.hy
.ad
.ft 1
.SH DESCRIPTION
.de CR
.ie t \f(CR\\$1\f1\\$2
.el \fI\\$1\f1\\$2
..
A Performance Metrics Domain Agent (PMDA) that exports event records
must effectively act an event multiplexer.
Events consumed by the PMDA may have to be forwarded on to any number
of monitoring tools (or "client contexts").
These tools may be requesting events at different sampling intervals,
and are very unlikely to request an event at the exact moment it arrives
at the PMDA, making some form of event buffering and queuing scheme a
necessity.
Events must be held by the PMDA until either all registered clients
have been sent them, or until a memory limit has been reached by the
PMDA at which point it must discard older events as new ones arrive.
.PP
The routines described here are designed to assist the PMDA developer
in managing both client contexts and queues of events at a high level.
These fit logically above lower level primitives, such as those
described in
.BR pmdaEventNewArray (3),
and shield the average PMDA from the details of directly building event
record arrays for individual client contexts.
.PP
The PMDA registers a new queue of events using either
.B pmdaEventNewQueue
or
.BR pmdaEventNewActiveQueue .
These are passed an identifying
.I name
(for diagnostic purposes, and for subsequent lookup by
.BR pmdaEventQueueHandle )
and
.IR maxmem ,
an upper bound on the memory (in bytes) that can be consumed by events
in this queue, before beginning to discard them (resulting in "missed"
events for any client that has not kept up).
If a queue is dynamically allocated (such that the PMDA may already have
clients connected) the
.B pmdaEventNewActiveQueue
interface should be used, with the additional
.I nclients
parameter indicating the count of active client connections.
The return is a negative error code on failure, suitable for decoding
by the
.BR pmErrStr (3)
routine.
Any non-negative value indicates success, and provides a
.I handle
suitable for passing into the other API routines.
.PP
For each new event received by the PMDA, the
.B pmdaEventQueueAppend
routine should be called, placing that event into the queue identified
by
.IR handle .
The event itself must be contained in the passed in
.IR buffer ,
having
.I bytes
length.
The timestamp associated with the event (time at which the event
occurred) is passed in via the final
.I tv
parameter.
.PP
In the PMDAs specific implementation of its fetch callback, when values
for an event metric have been requested, the
.BR pmdaEventQueueRecords
routine should be used.
It is passed the queue
.I handle
and the
.I avp
pmAtomValue structure to fill with event records, for the client making
that fetch request (identified by the
.I context
parameter).
Finally, the PMDA must also pass in an event decoding routine, which is
responsible for decoding the fields of a single event into the individual
event parameters of that event.
The
.I data
parameter is an opaque cookie that can be used to pass situation-specific
information into each
.I decoder
invocation.
.PP
Under some situations it is useful for the PMDA to export state about
the queues under its control.
The accessor routines \-
.BR pmdaEventQueueClients ,
.BR pmdaEventQueueCounter ,
.BR pmdaEventQueueBytes
and
.BR pmdaEventQueueMemory
provide a mechanism for querying a queue by its
.I handle
and filling in a
.B pmAtomValue
structure that the
.B pmdaFetchCallBack
method should return.
.SH SEE ALSO
.BR PMAPI (3),
.BR PMDA (3),
.BR pmdaEventNewClient (3)
and
.BR pmdaEventNewArray (3).
.\" control lines for scripts/man-spell
.\" +ok+ accessor
.\" +ok+ pmdaEventQueue {from generic title for man page}
|