Exec Plugin
In the variety of collectd plugins there’s one ‘to rule them all’. If due to some course of events all collectd plugins except for Exec would be taken from you, you’d still be able to restore all its functionality with Exec.
As the name suggests, Exec starts external program or script and interprets its output as source of data. To be specific, it looks for lines that follow this scheme:
1 |
PUTVAL hostname/source-instance/datatype-instance [Interval=seconds] timestamp:value[:value..] |
To be even more specific, these lines would work:
1 2 |
PUTVAL myhost/cpu-0/cpu-system interval=10 N:51 PUTVAL hostname/vm_count/gauge 1484012951:U |
What’s interesting, Exec doesn’t specify in what language script should be written, so anything, including JavaScript, might work. In fact, using JavaScript would be beneficial in some scenarios, e.g. when dealing with RESTful services returning JSON.
Before we try JavaScript app as data source for collectd, let’s talk about PUTVAL lines a little bit more. Continue reading “Creating collectd data source in JavaScript”