I am using MMV libraries provided by Performance Co-Pilot (PCP) framework. I need to reset the value in the MMV instance on a regular interval basis. I came across the mmv_stats_interval_start() api of PCP. Please explain how this api is working and how to get notification when the interval is elapsed.

mmv_stats_interval_start(void *addr, pmAtomValue *value,
    const char *metric, const char *instance)
{
 if (addr) {
    if (value == NULL)
        value = mmv_lookup_value_desc(addr, metric, instance);
    if (value) {
        struct timeval tv; 
        __pmtimevalNow(&tv);
        mmv_inc_value(addr, value, -(tv.tv_sec*1e6 + tv.tv_usec));
    }   
 }   
 return value;
}

An example in the github page of PCP is mmv_genstats.c

share|improve this question
up vote 1 down vote accepted

The mmv_stats_interval_start function pairs with mmv_stats_interval_end to accumulate time intervals (microseconds) between matching pairs of those calls. See for example http://git.pcp.io/cgi-bin/gitweb.cgi?p=pcp.git;a=blob;f=qa/src/mmv_genstats.c;hb=HEAD

MMV is not about notifications, only about efficiently exposing internal statistics of the program that uses -lpcp_mmv. Notifications would have to arise from another PCP client such as pmie.

share|improve this answer
    
How can I get the interval value when mmv_stats_interval_end is called? Why is the instance "value" ( from the code in question ) is 1 till mmv_stats_interval_end is called ? – anoop.babu Nov 20 '14 at 5:34
    
The (start-to-end) interval length will be added to the metric value after the _end function is called. Between the _start and _end calls, the metric value is not really appropriate to read (so is a race condition). – fche Nov 21 '14 at 11:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.