Merge pull request #416 from f0o/issue-415

TinyDNS (djbdns) Application & Graphs
This commit is contained in:
Neil Lathwood
2015-01-18 11:54:25 +00:00
10 changed files with 335 additions and 0 deletions
+28
View File
@@ -61,3 +61,31 @@ Verify that everything works by executing `rdnc stats && cat /etc/bind/named.sta
In case you get a `Permission Denied` error, make sure you chown'ed correctly.
Note: if you change the path you will need to change the path in `scripts/agent-local/bind`.
### TinyDNS/djbdns
__Installation__:
1. Get tinystats sources from http://www.morettoni.net/tinystats.en.html
2. Compile like as advised.
_Note_: In case you get `Makefile:9: *** missing separator. Stop.`, compile manually using:
* With IPv6: `gcc -Wall -O2 -fstack-protector -DWITH_IPV6 -o tinystats tinystats.c`
* Without IPv6: `gcc -Wall -O2 -fstack-protector -o tinystats tinystats.c`
3. Install into prefered path, like `/usr/bin/`.
__Configuration__:
_Note_: In this part we assume that you use DJB's [Daemontools](http://cr.yp.to/daemontools.html) to start/stop tinydns.
And that your tinydns-instance is located in `/service/dns`, adjust this path if necesary.
1. Replace your _log_'s `run` file, typically located in `/service/dns/log/run` with:
```
#!/bin/sh
exec setuidgid dnslog tinystats ./main/tinystats/ multilog t n3 s250000 ./main/
```
2. Create tinystats directory and chown:
`mkdir /service/dns/log/main/tinystats && chown dnslog:nofiles /service/dns/log/main/tinystats`
3. Restart TinyDNS and Daemontools: `/etc/init.d/svscan restart`
_Note_: Some say `svc -t /service/dns` is enough, on my install (Gentoo) it doesnt rehook the logging and I'm forced to restart it entirely.
@@ -0,0 +1,49 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <[email protected]>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* TinyDNS DNSSec Graph
* @author Daniel Preussker <[email protected]>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Graphs
*/
include("includes/graphs/common.inc.php");
$i = 0;
$scale_min = 0;
$nototal = 1;
$unit_text = "Query/sec";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
//$array = explode(":","hinfo:rp:sig:key:axfr:total");
$array = array( "key", "sig" );
$colours = "mixed";
$rrd_list = array();
if( is_file($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: $file";
}
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
?>
@@ -0,0 +1,48 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <[email protected]>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* TinyDNS Error Graph
* @author Daniel Preussker <[email protected]>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Graphs
*/
include("includes/graphs/common.inc.php");
$i = 0;
$scale_min = 0;
$nototal = 1;
$unit_text = "Query/sec";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
$array = array( "notauth", "notimpl", "badclass", "noquery" );
$colours = "oranges";
$rrd_list = array();
if( is_file($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: $file";
}
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
?>
@@ -0,0 +1,48 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <[email protected]>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* TinyDNS Other Graph
* @author Daniel Preussker <[email protected]>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Graphs
*/
include("includes/graphs/common.inc.php");
$i = 0;
$scale_min = 0;
$nototal = 1;
$unit_text = "Query/sec";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
$array = array( "other", "hinfo", "rp", "axfr" );
$colours = "mixed";
$rrd_list = array();
if( is_file($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: $file";
}
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
?>
@@ -0,0 +1,51 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <[email protected]>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* TinyDNS Query Graph
* @author Daniel Preussker <[email protected]>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Graphs
*/
include("includes/graphs/common.inc.php");
$i = 0;
$scale_min = 0;
$nototal = 1;
$unit_text = "Query/sec";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
//$array = explode(":","hinfo:rp:sig:key:axfr:total");
$array = array( "any", "a", "aaaa", "cname", "mx", "ns", "ptr", "soa", "txt" );
$colours = "merged";
$rrd_list = array();
$config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']);
if( is_file($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: $file";
}
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
?>
+1
View File
@@ -6,6 +6,7 @@ $graphs['mysql'] = array('network_traffic', 'connections', 'command_counter
$graphs['memcached'] = array('bits', 'commands', 'data', 'items');
$graphs['nginx'] = array('connections', 'req');
$graphs['bind'] = array('queries');
$graphs['tinydns'] = array('queries', 'errors', 'dnssec', 'other');
print_optionbar_start();
+38
View File
@@ -0,0 +1,38 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <[email protected]>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* TinyDNS Application
* @author Daniel Preussker <[email protected]>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Apps
*/
global $config;
$graphs = array('tinydns_queries' => 'Queries', 'tinydns_errors' => 'Errors', 'tinydns_dnssec' => 'DNSSec', 'tinydns_other' => 'Other');
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 "<h3>$text</h3><tr bgcolor='$row_colour'><td colspan=5>";
include("includes/print-graphrow.inc.php");
echo "</td></tr>";
}
?>
@@ -0,0 +1,53 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <[email protected]>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* TinyDNS Statistics
* @author Daniel Preussker <[email protected]>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Polling
*/
if( !empty($agent_data['app']['tinydns']) && $app['app_id'] > 0 ) {
echo " tinydns ";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
if( !is_file($rrd_filename) ) {
rrdtool_create($rrd_filename, "--step 300 \
DS:a:COUNTER:600:0:125000000000 \
DS:ns:COUNTER:600:0:125000000000 \
DS:cname:COUNTER:600:0:125000000000 \
DS:soa:COUNTER:600:0:125000000000 \
DS:ptr:COUNTER:600:0:125000000000 \
DS:hinfo:COUNTER:600:0:125000000000 \
DS:mx:COUNTER:600:0:125000000000 \
DS:txt:COUNTER:600:0:125000000000 \
DS:rp:COUNTER:600:0:125000000000 \
DS:sig:COUNTER:600:0:125000000000 \
DS:key:COUNTER:600:0:125000000000 \
DS:aaaa:COUNTER:600:0:125000000000 \
DS:axfr:COUNTER:600:0:125000000000 \
DS:any:COUNTER:600:0:125000000000 \
DS:total:COUNTER:600:0:125000000000 \
DS:other:COUNTER:600:0:125000000000 \
DS:notauth:COUNTER:600:0:125000000000 \
DS:notimpl:COUNTER:600:0:125000000000 \
DS:badclass:COUNTER:600:0:125000000000 \
DS:noquery:COUNTER:600:0:125000000000 ".$config['rrd_rra']);
}
rrdtool_update($rrd_filename, "N:".$agent_data['app']['tinydns']);
}
?>
+1
View File
@@ -44,6 +44,7 @@ if ($device['os_group'] == "unix")
if ($section == "mysql") { $sa = "app"; $sb = "mysql"; }
if ($section == "nginx") { $sa = "app"; $sb = "nginx"; }
if ($section == "bind") { $sa = "app"; $sb = "bind"; }
if ($section == "tinydns") { $sa = "app"; $sb = "tinydns"; }
# if ($section == "drbd") { $sa = "app"; $sb = "drbd"; }
if (!empty($sa) && !empty($sb))
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
# (c) 2015, [email protected]
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
echo "<<<tinydns>>>"
head -n1 /service/dns/log/main/tinystats/tinystats.out