[collectd] Slower interval for postgresql writes than rrd?

Phil Endecott spam_from_collectd at chezphil.org
Fri Sep 14 19:42:54 CEST 2018


Phil Endecott wrote:
> Is there any way to have collectd write values more frequently
> to one writer than another?

I have hacked together the following plugin.  It matches only 
data whose timestamp is within the first interval of each ten 
minute period.  It has some obvious flaws but it does what I 
need.


#include "collectd.h"

#include "common.h"
#include "filter_chain.h"


static int mi_match(const data_set_t *      ds        __attribute__((unused)),
                    const value_list_t *    vl,
                    notification_meta_t * * meta      __attribute__((unused)),
                    void * *                user_data __attribute__((unused)))
{
  cdtime_t time = vl->time;
  cdtime_t interval = vl->interval;
  // cdtime_t is a 64-bit unsigned integer with 30 fractional bits.
  cdtime_t ten_minutes = ((uint64_t)600) << 30;

  if (time % ten_minutes < interval) return FC_MATCH_MATCHES;
  else return FC_MATCH_NO_MATCH;
}
 

void module_register(void)
{
  match_proc_t mproc = {0};
  mproc.match = mi_match;
  fc_register_match("interval", mproc);
}


Usage:

PostCacheChain Filter
<Chain "Filter">
        <Rule "xxxx">
                <Match "interval">
                </Match>
                <Target "write">
                        Plugin "postgresql-xxx"
                </Target>
        </Rule>
        <Target "write">
                Plugin "rrdtool"
        </Target>
</Chain>


Regards, Phil.





More information about the collectd mailing list