/usr/include/pcp/pmapi.h is in libpcp3-dev 3.5.11.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | /*
* Copyright (c) 1997,2004 Silicon Graphics, Inc. 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.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _PMAPI_H
#define _PMAPI_H
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
/*
* Platform and environment customization
*/
#include "platform_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PMAPI_VERSION_1 1
#define PMAPI_VERSION_2 2
#define PMAPI_VERSION PMAPI_VERSION_2
/*
* -------- Naming Services --------
*/
typedef unsigned int pmID; /* Metric Identifier */
#define PM_ID_NULL 0xffffffff
typedef unsigned int pmInDom; /* Instance-Domain */
#define PM_INDOM_NULL 0xffffffff
#define PM_IN_NULL 0xffffffff
#define PM_NS_DEFAULT NULL /* default name */
/*
* Encoding for the units (dimensions Time and Space) and scale
* for Performance Metric Values
*
* For example, a pmUnits struct of
* { 1, -1, 0, PM_SPACE_MBYTE, PM_TIME_SEC, 0 }
* represents Mbytes/sec, while
* { 0, 1, -1, 0, PM_TIME_HOUR, 6 }
* represents hours/million-events
*/
typedef struct {
#ifdef HAVE_BITFIELDS_LTOR
signed int dimSpace : 4; /* space dimension */
signed int dimTime : 4; /* time dimension */
signed int dimCount : 4; /* event dimension */
unsigned int scaleSpace : 4; /* one of PM_SPACE_* below */
unsigned int scaleTime : 4; /* one of PM_TIME_* below */
signed int scaleCount : 4; /* one of PM_COUNT_* below */
unsigned int pad : 8;
#else
unsigned int pad : 8;
signed int scaleCount : 4; /* one of PM_COUNT_* below */
unsigned int scaleTime : 4; /* one of PM_TIME_* below */
unsigned int scaleSpace : 4; /* one of PM_SPACE_* below */
signed int dimCount : 4; /* event dimension */
signed int dimTime : 4; /* time dimension */
signed int dimSpace : 4; /* space dimension */
#endif
} pmUnits; /* dimensional units and scale of value */
/* pmUnits.scaleSpace */
#define PM_SPACE_BYTE 0 /* bytes */
#define PM_SPACE_KBYTE 1 /* Kilobytes (1024) */
#define PM_SPACE_MBYTE 2 /* Megabytes (1024^2) */
#define PM_SPACE_GBYTE 3 /* Gigabytes (1024^3) */
#define PM_SPACE_TBYTE 4 /* Terabytes (1024^4) */
#define PM_SPACE_PBYTE 5 /* Petabytes (1024^5) */
#define PM_SPACE_EBYTE 6 /* Exabytes (1024^6) */
/* pmUnits.scaleTime */
#define PM_TIME_NSEC 0 /* nanoseconds */
#define PM_TIME_USEC 1 /* microseconds */
#define PM_TIME_MSEC 2 /* milliseconds */
#define PM_TIME_SEC 3 /* seconds */
#define PM_TIME_MIN 4 /* minutes */
#define PM_TIME_HOUR 5 /* hours */
/*
* pmUnits.scaleCount (e.g. count events, syscalls, interrupts, etc.)
* -- these are simply powers of 10, and not enumerated here,
* e.g. 6 for 10^6, or -3 for 10^-3
*/
#define PM_COUNT_ONE 0 /* 1 */
/* Performance Metric Descriptor */
typedef struct {
pmID pmid; /* unique identifier */
int type; /* base data type (see below) */
pmInDom indom; /* instance domain */
int sem; /* semantics of value (see below) */
pmUnits units; /* dimension and units */
} pmDesc;
/* pmDesc.type -- data type of metric values */
#define PM_TYPE_NOSUPPORT -1 /* not implemented in this version */
#define PM_TYPE_32 0 /* 32-bit signed integer */
#define PM_TYPE_U32 1 /* 32-bit unsigned integer */
#define PM_TYPE_64 2 /* 64-bit signed integer */
#define PM_TYPE_U64 3 /* 64-bit unsigned integer */
#define PM_TYPE_FLOAT 4 /* 32-bit floating point */
#define PM_TYPE_DOUBLE 5 /* 64-bit floating point */
#define PM_TYPE_STRING 6 /* array of char */
#define PM_TYPE_AGGREGATE 7 /* arbitrary binary data (aggregate) */
#define PM_TYPE_AGGREGATE_STATIC 8 /* static pointer to aggregate */
#define PM_TYPE_EVENT 9 /* packed pmEventArray */
#define PM_TYPE_UNKNOWN 255 /* used in pmValueBlock, not pmDesc */
/* pmDesc.sem -- semantics/interpretation of metric values */
#define PM_SEM_COUNTER 1 /* cumulative counter (monotonic increasing) */
/* was PM_SEM_RATE, no longer used now */
#define PM_SEM_INSTANT 3 /* instantaneous value, continuous domain */
#define PM_SEM_DISCRETE 4 /* instantaneous value, discrete domain */
/*
* for PCP 1.x PMDAs and PMCDs, need to map errors unconditionally sometimes
* otherwise mapping is conditional upon value being in range
*/
#define PM_ERR_BASE1 1000
#define PM_ERR_BASE2 12345
#define PM_ERR_BASE PM_ERR_BASE2
#define PM_ERR_V1(e) (e)+PM_ERR_BASE2-PM_ERR_BASE1
#define XLATE_ERR_1TO2(e) \
((e) <= -PM_ERR_BASE1 ? (e)+PM_ERR_BASE1-PM_ERR_BASE2 : (e))
#define XLATE_ERR_2TO1(e) \
((e) <= -PM_ERR_BASE2 ? PM_ERR_V1(e) : (e))
/* PMAPI Error Conditions */
#define PM_ERR_GENERIC (-PM_ERR_BASE-0) /* Generic error, already reported above */
#define PM_ERR_PMNS (-PM_ERR_BASE-1) /* Problems parsing PMNS definitions */
#define PM_ERR_NOPMNS (-PM_ERR_BASE-2) /* PMNS not accessible */
#define PM_ERR_DUPPMNS (-PM_ERR_BASE-3) /* Attempt to reload the PMNS */
#define PM_ERR_TEXT (-PM_ERR_BASE-4) /* Oneline or help text is not available */
#define PM_ERR_APPVERSION (-PM_ERR_BASE-5) /* Metric not supported by this version of monitored application */
#define PM_ERR_VALUE (-PM_ERR_BASE-6) /* Missing metric value(s) */
#define PM_ERR_LICENSE (-PM_ERR_BASE-7) /* Current PCP license does not permit this operation */
#define PM_ERR_TIMEOUT (-PM_ERR_BASE-8) /* Timeout waiting for a response from PMCD */
#define PM_ERR_NODATA (-PM_ERR_BASE-9) /* Empty archive log file */
#define PM_ERR_RESET (-PM_ERR_BASE-10) /* pmcd reset or configuration changed */
#define PM_ERR_FILE (-PM_ERR_BASE-11) /* Cannot locate a file */
#define PM_ERR_NAME (-PM_ERR_BASE-12) /* Unknown metric name */
#define PM_ERR_PMID (-PM_ERR_BASE-13) /* Unknown or illegal metric identifier */
#define PM_ERR_INDOM (-PM_ERR_BASE-14) /* Unknown or illegal instance domain identifier */
#define PM_ERR_INST (-PM_ERR_BASE-15) /* Unknown or illegal instance identifier */
#define PM_ERR_UNIT (-PM_ERR_BASE-16) /* Illegal pmUnits specification */
#define PM_ERR_CONV (-PM_ERR_BASE-17) /* Impossible value or scale conversion */
#define PM_ERR_TRUNC (-PM_ERR_BASE-18) /* Truncation in value conversion */
#define PM_ERR_SIGN (-PM_ERR_BASE-19) /* Negative value in conversion to unsigned */
#define PM_ERR_PROFILE (-PM_ERR_BASE-20) /* Explicit instance identifier(s) required */
#define PM_ERR_IPC (-PM_ERR_BASE-21) /* IPC protocol failure */
#define PM_ERR_NOASCII (-PM_ERR_BASE-22) /* ASCII format not supported for this PDU */
#define PM_ERR_EOF (-PM_ERR_BASE-23) /* IPC channel closed */
#define PM_ERR_NOTHOST (-PM_ERR_BASE-24) /* Operation requires context with host source of metrics */
#define PM_ERR_EOL (-PM_ERR_BASE-25) /* End of PCP archive log */
#define PM_ERR_MODE (-PM_ERR_BASE-26) /* Illegal mode specification */
#define PM_ERR_LABEL (-PM_ERR_BASE-27) /* Illegal label record at start of a PCP archive log file */
#define PM_ERR_LOGREC (-PM_ERR_BASE-28) /* Corrupted record in a PCP archive log */
#define PM_ERR_NOTARCHIVE (-PM_ERR_BASE-29) /* Operation requires context with archive source of metrics */
#define PM_ERR_LOGFILE (-PM_ERR_BASE-30) /* Missing archive file */
#define PM_ERR_NOCONTEXT (-PM_ERR_BASE-31) /* Attempt to use an illegal context */
#define PM_ERR_PROFILESPEC (-PM_ERR_BASE-32) /* NULL pmInDom with non-NULL instlist */
#define PM_ERR_PMID_LOG (-PM_ERR_BASE-33) /* Metric not defined in the PCP archive log */
#define PM_ERR_INDOM_LOG (-PM_ERR_BASE-34) /* Instance domain identifier not defined in the PCP archive log */
#define PM_ERR_INST_LOG (-PM_ERR_BASE-35) /* Instance identifier not defined in the PCP archive log */
#define PM_ERR_NOPROFILE (-PM_ERR_BASE-36) /* Missing profile - protocol botch */
#define PM_ERR_NOAGENT (-PM_ERR_BASE-41) /* No pmcd agent for domain of request */
#define PM_ERR_PERMISSION (-PM_ERR_BASE-42) /* No permission to perform requested operation */
#define PM_ERR_CONNLIMIT (-PM_ERR_BASE-43) /* PMCD connection limit for this host exceeded */
#define PM_ERR_AGAIN (-PM_ERR_BASE-44) /* try again. Info not currently available */
#define PM_ERR_ISCONN (-PM_ERR_BASE-45) /* already connected */
#define PM_ERR_NOTCONN (-PM_ERR_BASE-46) /* not connected */
#define PM_ERR_NEEDPORT (-PM_ERR_BASE-47) /* port name required */
#define PM_ERR_WANTACK (-PM_ERR_BASE-48) /* can not send due to pending acks */
#define PM_ERR_NONLEAF (-PM_ERR_BASE-49) /* PMNS node is not a leaf node */
#define PM_ERR_OBJSTYLE (-PM_ERR_BASE-50) /* user/kernel object style mismatch */
#define PM_ERR_PMCDLICENSE (-PM_ERR_BASE-51) /* PMCD is not licensed to accept connections */
#define PM_ERR_TYPE (-PM_ERR_BASE-52) /* Unknown or illegal metric type */
#define PM_ERR_CTXBUSY (-PM_ERR_BASE-97) /* Context is busy */
#define PM_ERR_TOOSMALL (-PM_ERR_BASE-98) /* Insufficient elements in list */
#define PM_ERR_TOOBIG (-PM_ERR_BASE-99) /* Result size exceeded */
#define PM_ERR_PMDAREADY (-PM_ERR_BASE-1048) /* now ready to respond */
#define PM_ERR_PMDANOTREADY (-PM_ERR_BASE-1049) /* not yet ready to respond */
#define PM_ERR_NYI (-PM_ERR_BASE-8999) /* Functionality not yet implemented */
/*
* Report PMAPI errors messages
*/
extern const char *pmErrStr(int);
/*
* Load a Performance Metrics Name Space
*/
extern int pmLoadNameSpace(const char *);
extern int pmLoadASCIINameSpace(const char *, int);
extern void pmUnloadNameSpace(void);
/*
* Where is PMNS located - added for distributed PMNS.
*/
extern int pmGetPMNSLocation(void);
#define PMNS_LOCAL 1
#define PMNS_REMOTE 2
#define PMNS_ARCHIVE 3
/*
* Trim a name space with respect to the current context
* (usually from an archive, or after processing an archive)
*/
extern int pmTrimNameSpace(void);
/*
* Expand a list of names to a list of metrics ids
*/
extern int pmLookupName(int, char **, pmID *);
/*
* Find the names of descendent nodes in the PMNS
* and in the latter case get the status of each child.
*/
extern int pmGetChildren(const char *, char ***);
extern int pmGetChildrenStatus(const char *, char ***, int **);
#define PMNS_LEAF_STATUS 0 /* leaf node in PMNS tree */
#define PMNS_NONLEAF_STATUS 1 /* non-terminal node in PMNS tree */
/*
* Reverse Lookup: find name(s) given a metric id
*/
extern int pmNameID(pmID, char **); /* one */
extern int pmNameAll(pmID, char ***); /* all */
/*
* Handy recursive descent of the PMNS
*/
extern int pmTraversePMNS(const char *, void(*)(const char *));
/*
* Given a metric, find it's descriptor (caller supplies buffer for desc),
* from the current context.
*/
extern int pmLookupDesc(pmID, pmDesc *);
/*
* Return the internal instance identifier, from the current context,
* given an instance domain and the external instance name.
* Archive variant scans the union of the indom entries in the archive
* log.
*/
extern int pmLookupInDom(pmInDom, const char *);
extern int pmLookupInDomArchive(pmInDom, const char *);
/*
* Return the external instance name, from the current context,
* given an instance domain and the internal instance identifier.
* Archive variant scans the union of the indom entries in the archive
* log.
*/
extern int pmNameInDom(pmInDom, int, char **);
extern int pmNameInDomArchive(pmInDom, int, char **);
/*
* Return all of the internal instance identifiers (instlist) and external
* instance names (namelist) for the given instance domain in the current
* context.
* Archive variant returns the union of the indom entries in the archive
* log.
*/
extern int pmGetInDom(pmInDom, int **, char ***);
extern int pmGetInDomArchive(pmInDom, int **, char ***);
/*
* Given context ID, return a host name, associated with the id
* or empty string if no name can be found
*/
extern const char *pmGetContextHostName(int);
/*
* return the handle of the current context
*/
extern int pmWhichContext(void);
/*
* destroy a context and close it's connection
*/
extern int pmDestroyContext(int);
/*
* Establish a new context (source of performance data + instance profile)
* for the named host
*/
extern int pmNewContext(int, const char *);
#define PM_CONTEXT_HOST 1 /* context types */
#define PM_CONTEXT_ARCHIVE 2
#define PM_CONTEXT_LOCAL 3 /* local host, no pmcd connection */
#define PM_CONTEXT_TYPEMASK 0xff /* Mask to separate types from flags */
#define PM_CTXFLAG_SHALLOW (1<<8) /* Shallow host context - don't connect */
#define PM_CTXFLAG_EXCLUSIVE (1<<9) /* Exclusive host context - don't share socket */
/*
* Duplicate current context -- returns handle to new one for pmUseContext()
*/
extern int pmDupContext(void);
/*
* Restore (previously established or duplicated) context
*/
extern int pmUseContext(int);
/*
* Reconnect an existing context (when pmcd dies, etc). All existing context
* settings are preserved and the previous context settings are restored.
*/
extern int pmReconnectContext(int);
extern int pmGetContextFD(int);
extern int pmGetContextTimeout(int, int*);
struct sockaddr;
extern int pmContextConnectTo(int, const struct sockaddr *);
extern int pmContextConnectChangeState(int);
extern void pmContextUndef(void);
/*
* Add to instance profile.
* If pmInDom == PM_INDOM_NULL, then all instance domains are selected.
* If no inst parameters are given, then all instances are selected.
* e.g. to select all available instances in all domains,
* then use pmAddProfile(PM_INDOM_NULL, 0, NULL).
*/
extern int pmAddProfile(pmInDom, int, int *);
/*
* Delete from instance profile.
* Similar (but negated) functional semantics to pmProfileAdd.
* E.g. to disable all instances in all domains then use
* pmDelProfile(PM_INDOM_NULL, 0, NULL).
*/
extern int pmDelProfile(pmInDom, int, int *);
/*
* ---------- Collection services ----------
*
* Result from pmFetch is encoded as a timestamp and vector of pointers
* to pmValueSet instances (one per PMID in the result).
* Each pmValueSet has a PMID, a value count, a value format, and a vector of
* instance-value pairs. Aggregate, string and non-int values are returned
* via one further level of indirection using pmValueBlocks.
*
* timeStamp
* ->pmID
* value format
* instance, value
* instance, value
* ... etc
*
* ->pmID
* value format
* instance, value
* ... etc
*
*
* Notes on pmValueBlock
* 0. may be used for arbitrary binary data
* 1. only ever allocated dynamically, and vbuf expands to accommodate
* an arbitrary value (don't believe the [1] size!)
* 2. len is the length of the len field + the real size of vbuf
* (which includes the null-byte terminator if there is one)
*/
typedef struct {
#ifdef HAVE_BITFIELDS_LTOR
unsigned int vtype : 8; /* value type */
unsigned int vlen : 24; /* bytes for vtype/vlen + vbuf */
#else
unsigned int vlen : 24; /* bytes for vtype/vlen + vbuf */
unsigned int vtype : 8; /* value type */
#endif
char vbuf[1]; /* the value */
} pmValueBlock;
#define PM_VAL_HDR_SIZE 4 /* bytes for the vtype/vlen header */
#define PM_VAL_VLEN_MAX 0x00ffffff /* maximum vbuf[] size */
typedef struct {
int inst; /* instance identifier */
union {
pmValueBlock *pval; /* pointer to value-block */
int lval; /* integer value insitu (lval 'cuz it WAS a long) */
} value;
} pmValue;
typedef struct {
pmID pmid; /* metric identifier */
int numval; /* number of values */
int valfmt; /* value style */
pmValue vlist[1]; /* set of instances/values */
} pmValueSet;
/* values for valfmt */
#define PM_VAL_INSITU 0 /* value.lval is it */
#define PM_VAL_DPTR 1 /* value.pval->vbuf is it, and dynamic alloc */
#define PM_VAL_SPTR 2 /* value.pval->vbuf is it, and static alloc */
/* Result returned by pmFetch() */
typedef struct {
struct timeval timestamp; /* time stamped by collector */
int numpmid; /* number of PMIDs */
pmValueSet *vset[1]; /* set of value sets, one per PMID */
} pmResult;
/* Generic Union for Value-Type conversions */
typedef union {
__int32_t l; /* 32-bit signed */
__uint32_t ul; /* 32-bit unsigned */
__int64_t ll; /* 64-bit signed */
__uint64_t ull; /* 64-bit unsigned */
float f; /* 32-bit floating point */
double d; /* 64-bit floating point */
char *cp; /* char ptr */
pmValueBlock *vbp; /* pmValueBlock ptr */
} pmAtomValue;
/*
* Fetch metrics. Value/instances returned depends on current instance profile.
* By default, all available instances for each requested metric id are
* returned. The metrics argument is terminated with PM_NULL_ID
*
* The value sets returned are in the same order as the metrics argument,
* and the number of value sets returned is guaranteed to be the same as
* the number of metrics in the agument.
*/
extern int pmFetch(int, pmID *, pmResult **);
/*
* PMCD state changes returned as pmFetch function result for PM_CONTEXT_HOST
* contexts, i.e. when communicating with PMCD
*/
#define PMCD_NO_CHANGE 0
#define PMCD_ADD_AGENT 1
#define PMCD_RESTART_AGENT 2
#define PMCD_DROP_AGENT 4
/*
* variant that is used to return a pmResult from an archive
*/
extern int pmFetchArchive(pmResult **);
/*
* struct timeval is sometimes 2 x 64-bit ... we use a 2 x 32-bit format for
* PDUs, internally within libpcp and for (external) archive logs
*/
typedef struct {
__int32_t tv_sec; /* seconds since Jan. 1, 1970 */
__int32_t tv_usec; /* and microseconds */
} __pmTimeval;
/*
* Label Record at the start of every log file - as exported above
* the PMAPI ...
* NOTE MAXHOSTNAMELEN is a bad choice here for ll_hostname[], as
* it may vary on different hosts ... we use PM_LOG_MAXHOSTLEN instead, and
* size this to be the same as MAXHOSTNAMELEN in IRIX 5.3
* NOTE that the struct timeval means we have another struct (__pmLogLabel)
* for internal use that has a __pmTimeval in place of the struct timeval.
*/
#define PM_TZ_MAXLEN 40
#define PM_LOG_MAXHOSTLEN 64
#define PM_LOG_MAGIC 0x50052600
#define PM_LOG_VERS01 0x1
#define PM_LOG_VERS02 0x2
#define PM_LOG_VOL_TI -2 /* temporal index */
#define PM_LOG_VOL_META -1 /* meta data */
typedef struct {
int ll_magic; /* PM_LOG_MAGIC | log format version no. */
pid_t ll_pid; /* PID of logger */
struct timeval ll_start; /* start of this log */
char ll_hostname[PM_LOG_MAXHOSTLEN]; /* name of collection host */
char ll_tz[PM_TZ_MAXLEN]; /* $TZ at collection host */
} pmLogLabel;
/*
* get the label record from the current archive context, and discover
* when the archive ends
*/
extern int pmGetArchiveLabel(pmLogLabel *);
extern int pmGetArchiveEnd(struct timeval *);
/* Free result buffer */
extern void pmFreeResult(pmResult *);
/* Value extract from pmValue and type conversion */
extern int pmExtractValue(int, const pmValue *, int, pmAtomValue *, int);
/* Print single pmValue */
extern void pmPrintValue(FILE *, int, int, const pmValue *, int);
/* Scale conversion, based on value format, value type and scale */
extern int pmConvScale(int, const pmAtomValue *, const pmUnits *, pmAtomValue *,
const pmUnits *);
/* Sort instances for each metric within a pmResult */
extern void pmSortInstances(pmResult *);
/* Adjust collection time and/or mode for pmFetch */
extern int pmSetMode(int, const struct timeval *, int);
#define PM_MODE_LIVE 0
#define PM_MODE_INTERP 1
#define PM_MODE_FORW 2
#define PM_MODE_BACK 3
/* Modify the value of one or more metrics */
extern int pmStore(const pmResult *);
/* Get help and descriptive text */
extern int pmLookupText(pmID, int, char **);
extern int pmLookupInDomText(pmInDom, int, char **);
#define PM_TEXT_ONELINE 1
#define PM_TEXT_HELP 2
/*
* some handy formatting routines for messages, and other output
*/
extern const char *pmIDStr(pmID);
extern const char *pmInDomStr(pmInDom);
extern const char *pmTypeStr(int);
extern const char *pmUnitsStr(const pmUnits *);
extern const char *pmAtomStr(const pmAtomValue *, int);
extern const char *pmNumberStr(double);
extern const char *pmEventFlagsStr(int);
/* Extended time base definitions and macros */
#define PM_XTB_FLAG 0x1000000
#define PM_XTB_SET(type) (PM_XTB_FLAG | (type << 16))
#define PM_XTB_GET(x) ( (x & PM_XTB_FLAG) ? ( (x & 0xff0000) >> 16) : -1)
/* parse -t, -S, -T, -A and -O options */
extern int pmParseInterval(const char *, struct timeval *, char **);
extern int pmParseTimeWindow(
const char *, const char *, const char *, const char *,
const struct timeval *, const struct timeval *,
struct timeval *, struct timeval *, struct timeval *, char **);
/* reporting timezone */
extern int pmUseZone(const int);
extern int pmNewZone(const char *);
extern int pmNewContextZone(void);
extern int pmWhichZone(char **);
extern char *pmCtime(const time_t *, char *);
extern struct tm *pmLocaltime(const time_t *, struct tm *);
/* Parse host:metric[instances] or archive/metric[instances] */
typedef struct {
int isarch; /* source type: 0 -> live host, 1 -> archive, 2 -> local context */
char *source; /* name of source host or archive */
char *metric; /* name of metric */
int ninst; /* number of instances, 0 -> all */
char *inst[1]; /* array of instance names */
} pmMetricSpec;
/* parsing of host:metric[instances] or archive/metric[instances] */
extern int pmParseMetricSpec(const char *, int, char *, pmMetricSpec **,
char **);
extern void pmFreeMetricSpec(pmMetricSpec *p);
/*
* configurable error reporting
*/
#ifdef __GNUC__
# define __PM_PRINTFLIKE(idx,cnt) __attribute__ ((format (printf, idx,cnt)))
#else
# define __PM_PRINTFLIKE(idx,cnt)
#endif
extern int pmprintf(const char *, ...) __PM_PRINTFLIKE(1,2);
extern int pmflush(void);
/*
* Wrapper for config/environment variables. Warning: this will exit() with
* a FATAL error if /etc/pcp.conf does not exist and $PCP_CONF is not set.
* Return values point to strings in the environment.
*/
extern char *pmGetConfig(const char *);
/*
* Mainloop implementation.
*/
struct rusage;
int pmLoopRegisterInput(int, int, int (*)(int, int, void *), void *, int);
int pmLoopRegisterSignal(int, int (*)(int, void *), void *);
int pmLoopRegisterTimeout(int, int (*)(void *), void *);
int pmLoopRegisterChild(pid_t, int (*)(pid_t, int, const struct rusage *, void *), void *);
int pmLoopRegisterIdle(int (*)(void *), void *);
void pmLoopUnregisterInput(int);
void pmLoopUnregisterSignal(int);
void pmLoopUnregisterTimeout(int);
void pmLoopUnregisterChild(int);
void pmLoopUnregisterIdle(int);
void pmLoopStop(void);
int pmLoopMain(void);
extern int pmLoopDebug;
/*
* Derived Metrics support
*/
int pmLoadDerivedConfig(char *);
char *pmRegisterDerived(char *, char *);
char *pmDerivedErrStr(void);
/*
* Asynchronous versions of main pmapi client routines - each one
* either sends or receives a PDU.
*/
extern int pmReceiveDesc(int, pmDesc *);
extern int pmReceiveFetch(int, pmResult **);
extern int pmReceiveInDom(int, int **, char ***);
extern int pmReceiveInDomInst(int);
extern int pmReceiveInDomName(int, char **);
extern int pmReceiveNameID(int, char **);
extern int pmReceiveNames(int, int, pmID []);
extern int pmReceiveNamesAll(int, char ***);
extern int pmReceiveNamesOfChildren(int, char ***, int **);
extern int pmReceiveStore(int);
extern int pmReceiveText(int, char **);
extern int pmReceiveTraversePMNS(int, void (*)(const char *));
extern int pmRequestDesc(int, pmID);
extern int pmRequestFetch(int, int, pmID *);
extern int pmRequestInDom(int, pmInDom);
extern int pmRequestInDomInst(int, pmInDom, const char *);
extern int pmRequestInDomName(int, pmInDom, int);
extern int pmRequestInDomText(int, pmID, int);
extern int pmRequestNameID(int, pmID);
extern int pmRequestNames(int, int, char *[]);
extern int pmRequestNamesOfChildren(int, const char *, int);
extern int pmRequestStore(int, const pmResult *);
extern int pmRequestText(int, pmID, int);
extern int pmRequestTraversePMNS(int, const char *);
/*
* Event Record support
*/
typedef struct {
pmID ep_pmid;
/* vtype and vlen fields the format same as for pmValueBlock */
#ifdef HAVE_BITFIELDS_LTOR
unsigned int ep_type : 8; /* value type */
unsigned int ep_len : 24; /* bytes for type/len + vbuf */
#else
unsigned int ep_len : 24; /* bytes for type/len + vbuf */
unsigned int ep_type : 8; /* value type */
#endif
/* actual value (vbuf) goes here ... */
} pmEventParameter;
typedef struct {
__pmTimeval er_timestamp; /* must be 2 x 32-bit format */
int er_flags; /* event record characteristics */
int er_nparams; /* number of er_param[] entries */
pmEventParameter er_param[1];
} pmEventRecord;
/* potential flags bits set in er_flags (above) */
#define PM_EVENT_FLAG_POINT (1<<0) /* an observation, default type */
#define PM_EVENT_FLAG_START (1<<1) /* marking start of a new event */
#define PM_EVENT_FLAG_END (1<<2) /* completion of a traced event */
#define PM_EVENT_FLAG_ID (1<<3) /* 1st parameter is a trace ID */
#define PM_EVENT_FLAG_PARENT (1<<4) /* 2nd parameter is parents ID */
#define PM_EVENT_FLAG_MISSED (1<<31) /* nparams shows #missed events */
typedef struct {
/* align initial declarations with start of pmValueBlock */
#ifdef HAVE_BITFIELDS_LTOR
unsigned int ea_type : 8; /* value type */
unsigned int ea_len : 24; /* bytes for type/len + vbuf */
#else
unsigned int ea_len : 24; /* bytes for type/len + vbuf */
unsigned int ea_type : 8; /* value type */
#endif
/* real event records start here */
int ea_nrecords; /* number of ea_record[] entries */
pmEventRecord ea_record[1];
} pmEventArray;
/* unpack a PM_TYPE_EVENT value into a set on pmResults */
extern int pmUnpackEventRecords(pmValueSet *, int, pmResult ***);
/* Free set of pmResults from pmUnpackEventRecords */
extern void pmFreeEventResult(pmResult **);
#ifdef __cplusplus
}
#endif
#endif /* _PMAPI_H */
|