'GPRINT:total_max_ms:MAX:%5.1lf%s Max,',
'GPRINT:total_avg_ms:LAST:%5.1lf%s Last'
],
+ dns_traffic => ['DEF:rsp_min_raw={file}:responses:MIN',
+ 'DEF:rsp_avg_raw={file}:responses:AVERAGE',
+ 'DEF:rsp_max_raw={file}:responses:MAX',
+ 'DEF:qry_min_raw={file}:queries:MIN',
+ 'DEF:qry_avg_raw={file}:queries:AVERAGE',
+ 'DEF:qry_max_raw={file}:queries:MAX',
+ 'CDEF:rsp_min=rsp_min_raw,8,*',
+ 'CDEF:rsp_avg=rsp_avg_raw,8,*',
+ 'CDEF:rsp_max=rsp_max_raw,8,*',
+ 'CDEF:qry_min=qry_min_raw,8,*',
+ 'CDEF:qry_avg=qry_avg_raw,8,*',
+ 'CDEF:qry_max=qry_max_raw,8,*',
+ 'CDEF:overlap=rsp_avg,qry_avg,GT,qry_avg,rsp_avg,IF',
+ 'CDEF:mytime=rsp_avg_raw,TIME,TIME,IF',
+ 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
+ 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
+ 'CDEF:rsp_avg_sample=rsp_avg_raw,UN,0,rsp_avg_raw,IF,sample_len,*',
+ 'CDEF:rsp_avg_sum=PREV,UN,0,PREV,IF,rsp_avg_sample,+',
+ 'CDEF:qry_avg_sample=qry_avg_raw,UN,0,qry_avg_raw,IF,sample_len,*',
+ 'CDEF:qry_avg_sum=PREV,UN,0,PREV,IF,qry_avg_sample,+',
+ "AREA:rsp_avg#$HalfGreen",
+ "AREA:qry_avg#$HalfBlue",
+ "AREA:overlap#$HalfBlueGreen",
+ "LINE1:rsp_avg#$FullGreen:Responses",
+ 'GPRINT:rsp_avg:AVERAGE:%5.1lf%s Avg,',
+ 'GPRINT:rsp_max:MAX:%5.1lf%s Max,',
+ 'GPRINT:rsp_avg:LAST:%5.1lf%s Last',
+ 'GPRINT:rsp_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
+ "LINE1:qry_avg#$FullBlue:Queries ",
+ #'GPRINT:qry_min:MIN:%5.1lf %s Min,',
+ 'GPRINT:qry_avg:AVERAGE:%5.1lf%s Avg,',
+ 'GPRINT:qry_max:MAX:%5.1lf%s Max,',
+ 'GPRINT:qry_avg:LAST:%5.1lf%s Last',
+ 'GPRINT:qry_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
+ ],
fanspeed => [
'DEF:temp_avg={file}:value:AVERAGE',
'DEF:temp_min={file}:value:MIN',
delay => ['-t', 'NTPd peer delay ({inst})', '-v', 'Seconds'],
df => ['-t', '{host}:{inst} usage', '-v', 'Percent', '-l', '0'],
disk => ['-t', '{host} disk {inst} usage', '-v', 'Byte/s'],
+ dns_traffic => ['-t', '{host} DNS traffic', '-v', 'Bit/s'],
fanspeed => ['-t', '{host} fanspeed {inst}', '-v', 'rpm'],
frequency_offset => ['-t', 'NTPd frequency offset ({inst})', '-v', 'Parts per million'],
hddtemp => ['-t', '{host} hdd temperature {inst}', '-v', '°Celsius'],
};
typedef struct counter_list_s counter_list_t;
+static char *traffic_file = "dns/dns_traffic.rrd";
static char *qtype_file = "dns/qtype-%s.rrd";
static char *opcode_file = "dns/opcode-%s.rrd";
static char *rcode_file = "dns/rcode-%s.rrd";
+static char *traffic_ds_def[] =
+{
+ /* Limit to 1GBit/s */
+ "DS:queries:COUNTER:"COLLECTD_HEARTBEAT":0:125000000",
+ "DS:responses:COUNTER:"COLLECTD_HEARTBEAT":0:125000000",
+ NULL
+};
+static int traffic_ds_num = 2;
+
static char *qtype_ds_def[] =
{
"DS:value:COUNTER:"COLLECTD_HEARTBEAT":0:65535",
#endif
}
+static void traffic_write (char *host, char *inst, char *val)
+{
+ rrd_update_file (host, traffic_file, val,
+ traffic_ds_def, traffic_ds_num);
+}
+
static void qtype_write (char *host, char *inst, char *val)
{
char file[512];
rrd_update_file (host, file, val, opcode_ds_def, opcode_ds_num);
}
+static void traffic_submit (unsigned int queries, unsigned int replies)
+{
+ char buffer[64];
+ int status;
+
+ status = snprintf (buffer, 64, "N:%u:%u", queries, replies);
+ if ((status < 1) || (status >= 64))
+ return;
+
+ plugin_submit ("dns_traffic", "-", buffer);
+}
+
static void qtype_submit (int qtype, unsigned int counter)
{
char inst[32];
}
DBG ("sread (pipe_fd = %i, tr_responses = %u)", pipe_fd, tr_responses);
+ traffic_submit (tr_queries, tr_responses);
+
values_num = dns_read_array (values);
for (i = 0; i < values_num; i++)
{
void module_register (void)
{
plugin_register (MODULE_NAME, dns_init, dns_read, NULL);
+ plugin_register ("dns_traffic", NULL, NULL, traffic_write);
plugin_register ("dns_qtype", NULL, NULL, qtype_write);
plugin_register ("dns_rcode", NULL, NULL, rcode_write);
plugin_register ("dns_opcode", NULL, NULL, opcode_write);