Added Unbound Support

This commit is contained in:
Alan Gregory
2016-08-15 17:46:10 -03:00
parent 2615d4abc1
commit 772d7fa28d
3 changed files with 135 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<?php
require 'includes/graphs/common.inc.php';
$i = 0;
$scale_min = 0;
$nototal = 1;
$unit_text = 'Query/s';
$rrd_filename = rrd_name($device['hostname'], array('app', 'unbound-queries', $app['app_id']));
$array = array(
'type0',
'A',
'NS',
'CNAME',
'SOA',
'NULL',
'WKS',
'PTR',
'MX',
'TXT',
'AAAA',
'SRV',
'NAPTR',
'DS',
'DNSKEY',
'SPF',
'ANY',
'other'
);
$colours = 'merged';
$rrd_list = array();
$config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']);
if (rrdtool_check_rrd_exists($rrd_filename)) {
foreach ($array as $ds) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = strtoupper($ds);
$rrd_list[$i]['ds'] = $ds;
$i++;
}
}
else {
echo "file missing: $rrd_filename";
}
require 'includes/graphs/generic_multi_simplex_seperated.inc.php';

View File

@@ -0,0 +1,26 @@
<?php
global $config;
$graphs = array(
'unbound_queries' => 'Unbound - Queries'
);
foreach ($graphs as $key => $text){
$graph_type = $key;
$graph_array['height'] = '100';
$graph_array['width'] = '215';
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = 'application_'.$key;
echo '<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">'.$text.'</h3>
</div>
<div class="panel-body">
<div class="row">';
include 'includes/print-graphrow.inc.php';
echo '</div>';
echo '</div>';
echo '</div>';
}

View File

@@ -0,0 +1,62 @@
<?php
$name = 'unbound';
$app_id = $app['app_id'];
if (!empty($agent_data['app'][$name])) {
$rawdata = $agent_data['app'][$name];
}else{
echo "Unbound Missing";
return;
}
#Format Data
$lines = explode("\n",$rawdata);
$unbound = [];
foreach ($lines as $line) {
list($var,$value) = explode('=',$line);
$unbound[$var] = $value;
}
#Unbound Queries
$rrd_name = array('app', $name."-queries",$app_id);
$rrd_def = array(
'DS:type0:DERIVE:600:0:125000000000',
'DS:A:DERIVE:600:0:125000000000',
'DS:NS:DERIVE:600:0:125000000000',
'DS:CNAME:DERIVE:600:0:125000000000',
'DS:SOA:DERIVE:600:0:125000000000',
'DS:NULL:DERIVE:600:0:125000000000',
'DS:WKS:DERIVE:600:0:125000000000',
'DS:PTR:DERIVE:600:0:125000000000',
'DS:MX:DERIVE:600:0:125000000000',
'DS:TXT:DERIVE:600:0:125000000000',
'DS:AAAA:DERIVE:600:0:125000000000',
'DS:SRV:DERIVE:600:0:125000000000',
'DS:NAPTR:DERIVE:600:0:125000000000',
'DS:DS:DERIVE:600:0:125000000000',
'DS:DNSKEY:DERIVE:600:0:125000000000',
'DS:SPF:DERIVE:600:0:125000000000',
'DS:ANY:DERIVE:600:0:125000000000',
'DS:other:DERIVE:600:0:125000000000'
);
$fields = array (
'type0' => $unbound['num.query.type.TYPE0'],
'a' => $unbound['num.query.type.A'],
'ns' => $unbound['num.query.type.NS'],
'cname' => $unbound['num.query.type.CNAME'],
'soa' => $unbound['num.query.type.SOA'],
'null' => $unbound['num.query.type.NULL'],
'wks' => $unbound['num.query.type.WKS'],
'ptr' => $unbound['num.query.type.PTR'],
'mx' => $unbound['num.query.type.MX'],
'txt' => $unbound['num.query.type.TXT'],
'aaaa' => $unbound['num.query.type.AAAA'],
'srv' => $unbound['num.query.type.SRV'],
'naptr' => $unbound['num.query.type.NAPTR'],
'ds' => $unbound['num.query.type.DS'],
'dnskey' => $unbound['num.query.type.DNSKEY'],
'spf' => $unbound['num.query.type.SPF'],
'any' => $unbound['num.query.type.ANY'],
'other' => $unbound['num.query.type.other']
);
$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
data_update($device, 'app', $tags, $fields);
$status = true;
unset($lines , $unbound, $rrd_name, $rrd_def, $fields, $tags);