diff --git a/doc/Agent.md b/doc/Agent.md index 31c99de26..4ed036863 100644 --- a/doc/Agent.md +++ b/doc/Agent.md @@ -34,5 +34,30 @@ mkdir -p /usr/lib/check_mk_agent/plugins /usr/lib/check_mk_agent/local * Login to the LibreNMS web interface and edit the device you want to monitor. Under the modules section, ensure that unix-agent is enabled. * Then under Applications, enable the apps that you plan to monitor. * Wait, in around 10 minutes you should start seeing data in your graphs under Apps for the device. -* +## Application Specific Configuration + +### BIND9/named + +Create stats file with appropriate permissions: +```shell +~$ touch /etc/bind/named.stats +~$ chown bind:bind /etc/bind/named.stats +``` +Change `user:group` to the user and group that's running bind/named. + +Bind/named configuration: +```text +options { + ... + statistics-file "/etc/bind/named.stats"; + zone-statistics yes; + ... +}; +``` +Restart your bind9/named after changing the configuration. + +Verify that everything works by executing `rdnc stats && cat /etc/bind/named.stats`. +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`. diff --git a/html/includes/graphs/application/bind_queries.inc.php b/html/includes/graphs/application/bind_queries.inc.php new file mode 100644 index 000000000..985e720e7 --- /dev/null +++ b/html/includes/graphs/application/bind_queries.inc.php @@ -0,0 +1,50 @@ + + * 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 . */ + +/** + * Bind9 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-bind-".$app['app_id'].".rrd"; +$array = array( 'any', 'a', 'aaaa', 'cname', 'mx', 'ns', 'ptr', 'soa', 'srv', 'spf' ); +$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/apps.inc.php b/html/pages/apps.inc.php index 751be33e1..50d18eee5 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['bind'] = array('queries'); print_optionbar_start(); diff --git a/html/pages/device/apps/bind.inc.php b/html/pages/device/apps/bind.inc.php new file mode 100644 index 000000000..18b7447d0 --- /dev/null +++ b/html/pages/device/apps/bind.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 . */ + +/** + * Bind9 Application + * @author Daniel Preussker + * @copyright 2015 f0o, LibreNMS + * @license GPL + * @package LibreNMS + * @subpackage Apps + */ + +global $config; +$graphs = array('bind_queries' => '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 "

$text

"; + include("includes/print-graphrow.inc.php"); + echo ""; +} +?> diff --git a/includes/polling/applications/bind.inc.php b/includes/polling/applications/bind.inc.php new file mode 100644 index 000000000..299fdbc6b --- /dev/null +++ b/includes/polling/applications/bind.inc.php @@ -0,0 +1,79 @@ + + * 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 . */ + +/** + * Bind9 Statistics + * @author Daniel Preussker + * @copyright 2015 f0o, LibreNMS + * @license GPL + * @package LibreNMS + * @subpackage Polling + */ + +if( !empty($agent_data['app']['bind']) && $app['app_id'] > 0 ) { + echo " bind "; + $bind = $agent_data['app']['bind']; + $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-bind-".$app['app_id'].".rrd"; + $bind_parsed = array(); + $prefix = ""; + foreach( explode("\n",$bind) as $line ) { + $pattern = '/^\+\+ ([^+]+) \+\+$/'; + preg_match($pattern, $line, $matches); + if( !empty($matches) ) { + $prefix = str_replace(" ","_",strtolower($matches[1])); + $view = $item = $cnt = ""; + } + $pattern = '/^\[View: (\w+)(| .*)\]/'; + preg_match($pattern, $line, $matches); + if( !empty($matches) ) { + if( $matches[1] == "default" ) { + continue; + } else { + $view = $matches[1]; + } + } + $pattern = '/^\[(.*)\]$/'; + preg_match($pattern, $line, $matches); + if( !empty($matches) ) { + $prefix = $matches[1]; + } + $pattern = '/^\s+(\d+) ([^\n]+)/'; + preg_match($pattern, $line, $matches); + if( !empty($matches) ) { + $cnt = str_replace(" ","_",strtolower($matches[1])); + $item = str_replace(" ","_",strtolower($matches[2])); + if( !empty($view) ) { + $bind_parsed[$prefix][$view][$item] = $cnt; + } else { + $bind_parsed[$prefix][$item] = $cnt; + } + } + } + if( !is_file($rrd_filename) ) { + rrdtool_create($rrd_filename, "--step 300 \ + DS:any:COUNTER:600:0:125000000000 \ + DS:a:COUNTER:600:0:125000000000 \ + DS:aaaa:COUNTER:600:0:125000000000 \ + DS:cname:COUNTER:600:0:125000000000 \ + DS:mx:COUNTER:600:0:125000000000 \ + DS:ns:COUNTER:600:0:125000000000 \ + DS:ptr:COUNTER:600:0:125000000000 \ + DS:soa:COUNTER:600:0:125000000000 \ + DS:srv:COUNTER:600:0:125000000000 \ + DS:spf:COUNTER:600:0:125000000000 ".$config['rrd_rra']); + } + rrdtool_update($rrd_filename, "N:".((int) $bind_parsed['incoming_queries']['any']).":".((int) $bind_parsed['incoming_queries']['a']).":".((int) $bind_parsed['incoming_queries']['aaaa']).":".((int) $bind_parsed['incoming_queries']['cname']).":".((int) $bind_parsed['incoming_queries']['mx']).":".((int) $bind_parsed['incoming_queries']['ns']).":".((int) $bind_parsed['incoming_queries']['ptr']).":".((int) $bind_parsed['incoming_queries']['soa']).":".((int) $bind_parsed['incoming_queries']['srv']).":".((int) $bind_parsed['incoming_queries']['spf'])); +} +?> diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index ac4623cb4..2a40061e8 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 == "bind") { $sa = "app"; $sb = "bind"; } # if ($section == "drbd") { $sa = "app"; $sb = "drbd"; } if (!empty($sa) && !empty($sb)) diff --git a/scripts/agent-local/bind b/scripts/agent-local/bind new file mode 100755 index 000000000..75110d982 --- /dev/null +++ b/scripts/agent-local/bind @@ -0,0 +1,21 @@ +#!/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 . + +stats="/etc/bind/named.stats" + +echo "<<>>" +> $stats +rndc stats && cat $stats +