Product SiteDocumentation Site

2.2.3. Daemon PMDA

A DSO PMDA provides the most efficient communication between the PMDA and PMCD. This approach has some disadvantages resulting from the DSO PMDA being the same process as PMCD:
  • An error or bug that causes a DSO PMDA to exit also causes PMCD to exit, which affects all connected client tools.
  • There is only one thread of control in PMCD; as a result, a computationally expensive PMDA, or worse, a PMDA that blocks for I/O, adversely affects the performance of PMCD.
  • PMCD runs as the "pcp" user; so all DSO PMDAs must also run as this user.
  • A memory leak in a DSO PMDA also causes a memory leak for PMCD.
Consequently, many PMDAs are implemented as a daemon process.
The libpcp_pmda library is designed to allow simple implementation of a PMDA that runs as a separate process. The library functions provide a message passing layer acting as a generic wrapper that accepts PDUs, makes library calls using the standard DSO PMDA interface, and sends PDUs. Therefore, you can implement a PMDA as a DSO and then install it as either a daemon or a DSO, depending on the presence or absence of the generic wrapper.
The PMCD process launches a daemon PMDA with fork and execv (or CreateProcess on Windows). You can easily connect a pipe to the PMDA using standard input and output. The PMCD process may also connect to a daemon PMDA using IPv4 or IPv6 TCP/IP, or UNIX domain sockets if the platform supports that; see the tcp(7), ip(7), ipv6(7) or unix(7) man pages.
As superuser, install the simple PMDA as a daemon process as shown in Example 2.2, “Simple PMDA as a Daemon”. Again, the output may differ due to operating system differences, other PMDAs already installed, or access control sections in the PMCD configuration file.

Example 2.2. Simple PMDA as a Daemon

The specification for the simple PMDA now states the connection type of pipe to PMCD and the executable image for the PMDA is ${PCP_PMDAS_DIR}/simple/pmdasimple, using domain number 253.
# cd ${PCP_PMDAS_DIR}/simple
# ./Install
Install simple as a daemon or dso agent? [daemon] daemon 
PMCD should communicate with the daemon via pipe or socket? [pipe] pipe
# Performance Metrics Domain Specifications
# This file is automatically generated during the build
# Name  Id      IPC     IPC Params      File/Cmd
root    1       pipe    binary          /var/lib/pcp/pmdas/root/pmdaroot
pmcd    2       dso     pmcd_init       ${PCP_PMDAS_DIR}/pmcd/
proc    3       pipe    binary          ${PCP_PMDAS_DIR}/linux/ -d 3
linux   60      dso     linux_init      ${PCP_PMDAS_DIR}/linux/
mmv     70      dso     mmv_init        /var/lib/pcp/pmdas/mmv/
simple  253     pipe    binary          ${PCP_PMDAS_DIR}/simple/pmdasimple -d 253