pcp
[Top] [All Lists]

Re: [pcp] Derived metric config file error reporting

To: pcp@xxxxxxxxxxx
Subject: Re: [pcp] Derived metric config file error reporting
From: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Date: Tue, 21 Mar 2017 06:45:17 +1100
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <5730DE9D.6080103@xxxxxxxxxx>
References: <5730DE9D.6080103@xxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0
Marko,

While I'm in derived metric hacking mode I've been reviewing old email that mentions derived metrics ...

On 10/05/16 05:01, Marko Myllynen wrote:
Hi,

$ cat drv.conf
# comment line

bad_in_pkts= network.interface.in.errors + network.interface.in.drops

disk.dev.read_pct = 100 * delta(disk.dev.read) / (delta(disk.dev.read) + 
delta(disk.dev.write))

# another comment
$ PCP_DERIVED_CONFIG=./drv.conf pmrep -e ./drv.conf -s 1 bad_in_pkts
[./drv.conf:3] Error: pmRegisterDerived(bad_in_pkts, ...) syntax error
 network.interface.in.errors + network.interface.in.drops
 ^
Duplicate derived metric name
[./drv.conf:5] Error: pmRegisterDerived(disk.dev.read_pct, ...) syntax error
 100 * delta(disk.dev.read) / (delta(disk.dev.read) + delta(disk.dev.write))
 ^
Duplicate derived metric name
  bad_in_pkts  bad_in_pkts  bad_in_pkts  bad_in_pkts  bad_in_pkts  bad_in_pkts  
bad_in_pkts  bad_in_pkts
           lo   virbr0-nic       virbr0        vnet0         tun0        vnet1  
      vnet2        wlan0
      count/s      count/s      count/s      count/s      count/s      count/s  
    count/s      count/s
          N/A          N/A          N/A          N/A          N/A          N/A  
        N/A          N/A
$

Two questions here:

1) Wouldn't it be clearer if the complete formula would be printed
after the line which now says "syntax error"?

The pmRegisterDerived() api demands that a non-NULL value pointing into expr is returned in the case of an error at registration time (like this) ... so this is a corner case where I'm not sure we can do much better than this ... it is unfortunate that the details of the actual error are on lines 1 and 4 of the output, and lines 2 and 3 of the output are adding some confusion rather than enlightenment.

2) Would it make sense to have libpcp to skip duplicated derived
config files, it might things easier e.g. when scripting? I can't
imagine any valid use case when it would be meaningful to allow
using the same file twice (as it leads to syntax errors as seen
above).

I think this one falls clearly into the camp of user error.

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [pcp] Derived metric config file error reporting, Ken McDonell <=