Skip to main content

Performance Co-Pilot and Arduino (part 2)

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:

  1. Go to /var/lib/pcp/pmdas/shping
  2. Create sample.conf with the following line:
8.8.8.8 /var/lib/pcp/pmdas/shping/ping.sh
  1. Create /var/lib/pcp/pmdas/shping/ping.sh:
#!/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
  1. Launch ./Install and choose [2] ./sample.conf
  2. Now it is possible to abuse the shping.error metric to fetch that value:
    $ pminfo -f shping.error
    shping.error
       inst [0 or "8.8.8.8"] 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.

arduino-pcp

Comments

Comments powered by Disqus