aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/dns.php
blob: d0322f173825f4144748fff9d5068ab0afba2e83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php

# Collectd DNS plugin

require_once 'conf/common.inc.php';
require_once 'type/GenericStacked.class.php';
require_once 'inc/collectd.inc.php';

## LAYOUT
# dns/
# dns/dns_octets.rrd
# dns/dns_opcode-X.rrd
# dns/dns_qtype-X.rrd

$obj = new Type_GenericStacked($CONFIG);
$obj->width = $width;
$obj->heigth = $heigth;
$obj->rrd_format = '%5.1lf%s';

switch($obj->args['type']) {
	case 'dns_octets':
		$obj->data_sources = array(
			'queries',
			'responses',
		);
		$obj->ds_names = array(
			'queries'   => 'Queries',
			'responses' => 'Responses',
		);
		$obj->colors = array(
			'queries'   => '0000ff',
			'responses' => '00ff00',
		);
		$obj->rrd_title = 'DNS traffic';
		$obj->rrd_vertical = 'Bit/s';
	break;
	case 'dns_opcode':
		$obj->data_sources = array('value');
		$obj->rrd_title = 'DNS Opcode Query';
		$obj->rrd_vertical = 'Queries/s';
	break;
	case 'dns_qtype':
		$obj->data_sources = array('value');
		$obj->rrd_title = 'DNS QType';
		$obj->rrd_vertical = 'Queries/s';
	break;
	case 'dns_rcode':
		$obj->data_sources = array('value');
		$obj->rrd_title = 'DNS Reply code';
		$obj->rrd_vertical = 'Queries/s';
	break;
}

collectd_flush($obj->identifiers);
$obj->rrd_graph();