1PMCONTROLLOG(3)            Library Functions Manual            PMCONTROLLOG(3)
2
3
4

NAME

6       __pmControlLog  -  enable,  disable or enquire about logging of perfor‐
7       mance metrics
8

C SYNOPSIS

10       #include <pcp/pmapi.h>
11       #include <pcp/impl.h>
12
13       int __pmControlLog(int fd, const pmResult *request, int control,
14               int state, int delta, pmResult **status);
15
16       cc ... -lpcp
17

DESCRIPTION

19       __pmControlLog may be used to enable or disable the archive logging for
20       particular performance metrics, as identified by the request parameter;
21       see pmFetch(3) for an explanation of the pmResult structure.
22
23       The  application  must have previously issued a call to __pmConnectLog‐
24       ger(3) to establish a control-port connection to  the  pmlogger(1)  in‐
25       stance  to  whom the control request is to be directed, and fd (the re‐
26       sult from __pmConnectLogger(3)) identifies this connection.
27
28       Within request, only the details of the performance metrics  and  their
29       associated  instances will be used, i.e.  the values of the metrics, if
30       any, will be ignored.  request would typically be  constructed  as  the
31       result  of  an earlier call to pmFetch(3).  For metrics with a singular
32       value (having an instance domain of  PM_INDOM_NULL)  the  corresponding
33       pmValueSet should have the value one in the numval field and PM_IN_NULL
34       as the inst field of the single pmValue supplied.  If multiple explicit
35       instances  are  to be logged, the numval field of the pmValueSet should
36       contain the number of instances supplied and the inst fields of the pm‐
37       Value  structures  should  contain specific instance identifiers (which
38       may not have the reserved value PM_IN_NULL).
39
40       If the numval field within any of the pmValueSet structures in  request
41       has  a  value of zero, it indicates that all available instances of the
42       metric should be used.  Enumeration of the instance domain is  deferred
43       until  the  logger  fetches  the metric prior to writing it to the log,
44       rather than being performed when  the  __pmControlLog  request  is  re‐
45       ceived.   This  is useful for metrics with instance domains that change
46       over time.  It is an error to specify numval equal to zero if the  cor‐
47       responding metric has a singular value (no instance domain).
48
49       There  are several sorts of logging control available, namely mandatory
50       or advisory, as defined by the control argument, and on, off  or  maybe
51       as  defined by the state argument. These different types of control may
52       be used to ensure that some performance metrics can  be  guaranteed  to
53       always  be  in the log, while others may be dynamically enabled or dis‐
54       abled as determined by the level and type of system activity.
55
56       The actual action to be performed is defined by the combination of con‐
57       trol and state as follows.  If control is PM_LOG_MANDATORY and state is
58       PM_LOG_ON, then logging is enabled.  If control is PM_LOG_MANDATORY and
59       state   is  PM_LOG_OFF,  then  logging  is  disabled.   If  control  is
60       PM_LOG_MANDATORY and state is PM_LOG_MAYBE,  then  subsequent  advisory
61       controls  will  be  honored.  If the logging state prior to the request
62       was mandatory (on or off), the state is changed to  advisory  off.   If
63       the  logging  state was already advisory (either on or off), it remains
64       unchanged.  If control is PM_LOG_ADVISORY and the last  mandatory  con‐
65       trol  for  the metric was PM_LOG_MAYBE, then logging is enabled or dis‐
66       abled  as  specified  by  the  state  argument,  i.e.    PM_LOG_ON   or
67       PM_LOG_OFF.   When the arguments state and control specify a request to
68       change the logging behavior, the argument delta defines the logging in‐
69       terval in milliseconds to be applied to all metrics and instances iden‐
70       tified in request.
71
72       The result argument status returns the current logging state  for  each
73       of  the  nominated  performance metrics.  There is a 1:1 correspondence
74       between the elements of request and status.   For  metrics  in  request
75       that  have pmValueSets with numval equal to zero, the corresponding pm‐
76       ValueSet in result will contain a value for each available instance  at
77       the  time  of the call.  Each metric value in status will have the cur‐
78       rent logging state encoded in it.  The detailed outcome of  the  opera‐
79       tion  for  each  metric  can be determined by comparing these values to
80       that requested via control, state and delta.
81
82       Macros defined in <pcp/impl.h> may be used to  extract  the  state  and
83       logging  interval from the returned metric values.  PMLC_GET_ON returns
84       true if logging is on, or false if it  is  off;  PMLC_GET_MAND  returns
85       true  if logging is mandatory, or false if it is advisory; PMLC_GET_IN‐
86       LOG returns true if the metric has been logged at least once, or  false
87       otherwise; PMLC_GET_AVAIL returns true if the metric was available from
88       its source the last time it was supposed to be logged, or false  if  it
89       was  unavailable; and PMLC_GET_DELTA returns the current logging inter‐
90       val for the  metric  (in  milliseconds).   PMLC_MAX_DELTA  defines  the
91       greatest delta that can be returned in an encoded metric value.
92
93       As  a special case, when control is PM_LOG_ENQUIRE, state and delta are
94       ignored, and status returns the current logging state of the  nominated
95       performance  metrics  (this  variant  makes  no  changes to the logging
96       state).
97
98       If the value of the logging interval is 0, either for delta  in  a  re‐
99       quest  to  change  state to PM_LOG_ON, or encoded in the value returned
100       from PM_LOG_ENQUIRE, then this corresponds to the special ``once only''
101       logging  of  metrics that appear once in the archive log, and are never
102       logged again.
103
104       __pmControlLog returns zero on success.
105

NOTE

107       This routine is not thread-safe as there is no serialization on the use
108       of the communication channel between the sending of the request and re‐
109       ceiving the reply.  It is assumed that the caller  is  single-threaded,
110       which  is  true  for  the  only  current  user  of this routine, namely
111       pmlc(1).
112

SEE ALSO

114       pmlc(1), pmlogger(1), PMAPI(3), pmFetch(3) and __pmConnectLogger(3).
115

DIAGNOSTICS

117       PM_ERR_TOOSMALL
118              The number of metrics in request is less than one.
119
120       PM_ERR_VALUE
121              One or more of the pmValueSets in request had numval (the number
122              of instances) less than one.
123
124       EINVAL An  invalid  combination  of control and state was specified, or
125              delta was negative.
126
127
128
129Performance Co-Pilot                  PCP                      PMCONTROLLOG(3)
Impressum