From dd6f1f63fff89538222e04d20f6090a1d517a92a Mon Sep 17 00:00:00 2001 From: f0o Date: Sat, 17 Jan 2015 19:27:44 +0000 Subject: [PATCH 1/3] Added TinyDNS (djbdns) Graphs & Application. Data obtained by tinystats (http://www.morettoni.net/tinystats.en.html) via check_mk --- .../graphs/application/tinydns_dnssec.inc.php | 49 +++++++++++++++++ .../graphs/application/tinydns_errors.inc.php | 48 +++++++++++++++++ .../graphs/application/tinydns_other.inc.php | 48 +++++++++++++++++ .../application/tinydns_queries.inc.php | 51 ++++++++++++++++++ html/pages/device/apps/tinydns.inc.php | 38 +++++++++++++ includes/polling/applications/tinydns.inc.php | 53 +++++++++++++++++++ includes/polling/unix-agent.inc.php | 1 + scripts/agent-local/tinydns | 18 +++++++ 8 files changed, 306 insertions(+) create mode 100644 html/includes/graphs/application/tinydns_dnssec.inc.php create mode 100644 html/includes/graphs/application/tinydns_errors.inc.php create mode 100644 html/includes/graphs/application/tinydns_other.inc.php create mode 100644 html/includes/graphs/application/tinydns_queries.inc.php create mode 100644 html/pages/device/apps/tinydns.inc.php create mode 100644 includes/polling/applications/tinydns.inc.php create mode 100755 scripts/agent-local/tinydns diff --git a/html/includes/graphs/application/tinydns_dnssec.inc.php b/html/includes/graphs/application/tinydns_dnssec.inc.php new file mode 100644 index 0000000000..14b4c8136d --- /dev/null +++ b/html/includes/graphs/application/tinydns_dnssec.inc.php @@ -0,0 +1,49 @@ + + * 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 . */ + +/** + * TinyDNS DNSSec Graph + * @author Daniel Preussker + * @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"); +?> diff --git a/html/includes/graphs/application/tinydns_errors.inc.php b/html/includes/graphs/application/tinydns_errors.inc.php new file mode 100644 index 0000000000..6cec421c91 --- /dev/null +++ b/html/includes/graphs/application/tinydns_errors.inc.php @@ -0,0 +1,48 @@ + + * 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 . */ + +/** + * TinyDNS Error Graph + * @author Daniel Preussker + * @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"); +?> diff --git a/html/includes/graphs/application/tinydns_other.inc.php b/html/includes/graphs/application/tinydns_other.inc.php new file mode 100644 index 0000000000..b7c08f88e3 --- /dev/null +++ b/html/includes/graphs/application/tinydns_other.inc.php @@ -0,0 +1,48 @@ + + * 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 . */ + +/** + * TinyDNS Other Graph + * @author Daniel Preussker + * @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"); +?> diff --git a/html/includes/graphs/application/tinydns_queries.inc.php b/html/includes/graphs/application/tinydns_queries.inc.php new file mode 100644 index 0000000000..2d2b03ebee --- /dev/null +++ b/html/includes/graphs/application/tinydns_queries.inc.php @@ -0,0 +1,51 @@ + + * 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 . */ + +/** + * TinyDNS Query Graph + * @author Daniel Preussker + * @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"); +?> diff --git a/html/pages/device/apps/tinydns.inc.php b/html/pages/device/apps/tinydns.inc.php new file mode 100644 index 0000000000..fcf2a6b641 --- /dev/null +++ b/html/pages/device/apps/tinydns.inc.php @@ -0,0 +1,38 @@ + + * 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 . */ + +/** + * TinyDNS Application + * @author Daniel Preussker + * @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 "

$text

"; + include("includes/print-graphrow.inc.php"); + echo ""; +} +?> diff --git a/includes/polling/applications/tinydns.inc.php b/includes/polling/applications/tinydns.inc.php new file mode 100644 index 0000000000..f676c35b54 --- /dev/null +++ b/includes/polling/applications/tinydns.inc.php @@ -0,0 +1,53 @@ + + * 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 . */ + +/** + * TinyDNS Statistics + * @author Daniel Preussker + * @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']); +} +?> diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index ac4623cb44..12f6a6016e 100755 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -43,6 +43,7 @@ if ($device['os_group'] == "unix") if ($section == "apache") { $sa = "app"; $sb = "apache"; } if ($section == "mysql") { $sa = "app"; $sb = "mysql"; } if ($section == "nginx") { $sa = "app"; $sb = "nginx"; } + if ($section == "tinydns") { $sa = "app"; $sb = "tinydns"; } # if ($section == "drbd") { $sa = "app"; $sb = "drbd"; } if (!empty($sa) && !empty($sb)) diff --git a/scripts/agent-local/tinydns b/scripts/agent-local/tinydns new file mode 100755 index 0000000000..9c980a80cd --- /dev/null +++ b/scripts/agent-local/tinydns @@ -0,0 +1,18 @@ +#!/bin/bash +# (c) 2015, f0o@devilcode.org +# 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 . + +echo "<<>>" +head -n1 /service/dns/log/main/tinystats/tinystats.out + From 2c16454493977c9e20e5b41aa60112e9827f510f Mon Sep 17 00:00:00 2001 From: f0o Date: Sat, 17 Jan 2015 19:32:55 +0000 Subject: [PATCH 2/3] Added default graphs --- html/pages/apps.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/pages/apps.inc.php b/html/pages/apps.inc.php index 751be33e16..41e4357ea6 100644 --- a/html/pages/apps.inc.php +++ b/html/pages/apps.inc.php @@ -5,6 +5,7 @@ $graphs['drbd'] = array('disk_bits', 'network_bits', 'queue', 'unsynced'); $graphs['mysql'] = array('network_traffic', 'connections', 'command_counters', 'select_types'); $graphs['memcached'] = array('bits', 'commands', 'data', 'items'); $graphs['nginx'] = array('connections', 'req'); +$graphs['tinydns'] = array('queries', 'errors', 'dnssec', 'other'); print_optionbar_start(); From 01702590921b5a8f45e217cfdb94ebbd12a50a27 Mon Sep 17 00:00:00 2001 From: f0o Date: Sun, 18 Jan 2015 07:12:48 +0000 Subject: [PATCH 3/3] Added Documentation --- doc/Agent.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/Agent.md b/doc/Agent.md index 4ed0368635..cf8a2508b1 100644 --- a/doc/Agent.md +++ b/doc/Agent.md @@ -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. +