Product SiteDocumentation Site

2.7.2. Debugging Information

You can activate debugging options in PMCD and most other PCP tools with the -D command-line option. Supported options can be listed with the pmdbg command; see the pmdbg(1) man page. Setting the debug options for PMCD in ${PCP_PMCDOPTIONS_PATH} might generate too much information to be useful, especially if there are other clients and PMDAs connected to the PMCD process.
The PMCD debugging options can also be changed dynamically by storing a new value into the metric pmcd.control.debug:
# pmstore pmcd.control.debug 5
Most of the pcp_pmda library functions log additional information if the libpmda option is set within the PMDA; see the PMDA(3) man page. The command-line argument -D is trapped by pmdaGetOptions to set the global debugging control options. Adding tests within the PMDA for the appl0, appl1 and appl2 trace flags permits different levels of information to be logged to the PMDA's log file.
All diagnostic, debugging, and tracing output from a PMDA should be written to the standard error stream.
Adding this segment of code to the simple_store metric causes a timestamped log message to be sent to the current log file whenever pmstore attempts to change simple.numfetch and the PCP debugging options have the appl0 option set as shown in Example 2.32, “ simple.numfetch in the Simple PMDA”:

Example 2.32.  simple.numfetch in the Simple PMDA

   case 0: /* simple.numfetch */ 
       	x
        val = vsp->vlist[0].value.lval; 
        if (val < 0) { 
            sts = PM_ERR_SIGN; 
            val = 0; 
        } 
        if (pmDebugOptions.appl0__) { 
            __pmNotifyErr(LOG_DEBUG,
                  "simple: %d stored into numfetch", val); 
        } 
        numfetch = val; 
        break;
For a description of pmstore, see the pmstore(1) man page.