From charlesreid1

Line 16: Line 16:


<pre>
<pre>
<Plugin "write_mongodb">
<Plugin "write_mongodb">
   <Node "default">
   <Node "default">
Line 24: Line 25:
   </Node>
   </Node>
</Plugin>
</Plugin>
</pre>


This registers a new writer called <code>write_mongodb/localhost</code>
This registers a new writer called <code>write_mongodb/localhost</code>
Line 32: Line 35:


<pre>
<pre>
<Plugin logfile>
<Plugin logfile>
LogLevel "info"
LogLevel "info"
Line 38: Line 42:
PrintSeverity false
PrintSeverity false
</Plugin>
</Plugin>
</pre>
</pre>



Revision as of 18:52, 3 February 2018

Write Mongo Plugin

Link: https://collectd.org/wiki/index.php/Plugin:Write_MongoDB

Setup

Revisiting Collectd, you should have collectd installed via your package manager, or installed from source.

The collectd service runs as a daemon, and it reads from a config file when it starts up, so you control collectd by editing the config file.

Config file

The config file is located in /etc/collectd.conf

The file is extremely detailed and extensively documented (sometimes this can be worse than no documentation - I mean, who the hell's going to read through a 1,000 line configuration file???). The section we're interested in is the section <Plugin>.


<Plugin "write_mongodb">
  <Node "default">
    Host "localhost"
    Port     "27017"
    Timeout    2000
    StoreRates true
  </Node>
</Plugin>

This registers a new writer called write_mongodb/localhost

Logging

To turn on logging (to see what's going on if the plugin is not working),


<Plugin logfile>
	LogLevel "info"
	File "/var/log/collectd.log"
	Timestamp true
	PrintSeverity false
</Plugin>

Error

If you see this error in the log:

plugin_load: Could not find plugin "write_mongodb" in /usr/lib/collectd

it means you have to compile collectd from SOURCE to include the plugin.

Data Format

Here is the data format that is used by collectd to store its data in MongoDB:


 /* Collection "collectd.${plugin}" = */
 {
   "time": 1330940612.932, /* BSON date (UTC milliseconds) */
   "host": "localhost",    /* string */
   "plugin_instance": "",  /* string */
   "type": "load",         /* string */
   "type_instance": "",    /* string */
   "values": [             /* array of numbers */
     0.42, 0.37, 0.11
   ],
   "dstypes": [            /* array of strings */
     "gauge", "gauge", "gauge"
   ],
   "dsnames": [            /* array of strings */
     "shortterm", "midterm", "longterm"
   ]
 }

Code

Repository for collectd-related config files here: https://charlesreid1.com:3000/data/collectd-config


Flags

[[Category:2018]