After initially setting up Performance Co-Pilot and Arduino, I wanted to improve the data being displayed. As latency is quite important to me, I wanted to display that as well. I did not have too much time on my hands to code a new PMDA that collects that information, so I abused the pmdashping(1) for this purpose. The steps are simple:
- Go to
sample.confwith the following line:
#!/bin/sh # This hack will break if latency > 254 ;) ret=`ping -c 2 -n -q acksyn.org | grep ^rtt | cut -f5 -d\/ | cut -f1 -d\.` exit $ret
- Now it is possible to abuse the
shping.errormetric to fetch that value:
$ pminfo -f shping.error shping.error inst [0 or "22.214.171.124"] value 52
The last step was to fetch this via PMWEBAPI(3). This did not work until I realized, thanks to Fche's suggestion that the issue was related to my inital context initialization. As a matter of fact there is a big difference between the following two:
/pmapi/context?local=ANYTHING- Creates a PM_CONTEXT_LOCAL PMAPI context.
/pmapi/context?hostname=STRING- Creates a PM_CONTEXT_HOST PMAPI context with the given host name and/or extended specification.
The man page of pmNewContext(3) explains this in more detail. Frank has added some more info to the
PMWEBAPI(3) man page via the following commit, to make it a little bit more obvious. It's still a pretty gross hack, but for the time being it's enough for my needs.