From 864cbe9a1a1a22d58877bb1f9ea7b4098804d095 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Fri, 2 Jan 2015 23:15:35 +0000 Subject: [PATCH 01/13] Added option to disable footer in web interface --- html/index.php | 5 +++++ includes/defaults.inc.php | 2 ++ 2 files changed, 7 insertions(+) diff --git a/html/index.php b/html/index.php index 4268fe230..65d3d912f 100755 --- a/html/index.php +++ b/html/index.php @@ -291,6 +291,10 @@ if (is_array($pagetitle)) echo(""); } ?> + + diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 433e34b34..5fbc91e39 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -585,4 +585,6 @@ $config['dateformat']['time'] = "H:i:s"; $config['enable_clear_discovery'] = 1;// Set this to 0 if you want to disable the web option to rediscover devices +$config['enable_footer'] = 1;// Set this to 0 if you want to disable the footer copyright in the web interface + ?> From f8bb38e5539522455481e36669a3e33f98cc70b9 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Fri, 9 Jan 2015 08:02:15 +0000 Subject: [PATCH 02/13] Updated footer message --- html/index.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/html/index.php b/html/index.php index 65d3d912f..b6b952586 100755 --- a/html/index.php +++ b/html/index.php @@ -300,11 +300,7 @@ if($config['enable_footer'] == 1) {

' . (isset($config['footer']) ? $config['footer'] : '')); -echo('
Powered by ' . $config['project_name_version'].'.
'); -echo( $config['project_name'].' is Free Software, released under the GNU GPLv3.
'); -echo(' Copyright © 2013-'.date("Y").' by the '.$config['project_name'].' Contributors.
'); -echo(' Copyright © 2006-2012 by Adam Armstrong.'); +echo(' Powered by ' . $config['project_name'].'.
'); ?>
From b1176fd0a8e839bebf9520842b383c7e84755400 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Fri, 9 Jan 2015 08:06:54 +0000 Subject: [PATCH 03/13] Updated link to /about/ --- html/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.php b/html/index.php index b6b952586..46ceedac6 100755 --- a/html/index.php +++ b/html/index.php @@ -300,7 +300,7 @@ if($config['enable_footer'] == 1) {
Powered by ' . $config['project_name'].'.
'); +echo(' Powered by ' . $config['project_name'].'.
'); ?>
From 42de11884e2d6cdc71c0ac6550874a7dd5e7c301 Mon Sep 17 00:00:00 2001 From: f0o Date: Thu, 15 Jan 2015 07:18:10 +0000 Subject: [PATCH 04/13] Added: 039.sql: create a new table processes processes.inc.php: show all processes from given device including sort-options Changed: unix-agent.inc.php: insert all processes reported by check_mk_agent device.inc.php: added tab with link to process-list --- html/pages/device.inc.php | 9 +++ html/pages/device/processes.inc.php | 98 +++++++++++++++++++++++++++++ includes/polling/unix-agent.inc.php | 10 +-- sql-schema/039.sql | 1 + 4 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 html/pages/device/processes.inc.php create mode 100644 sql-schema/039.sql diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index b1a825f02..3ab398d49 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -82,6 +82,15 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) '); } + if (@dbFetchCell("SELECT 1 FROM processes WHERE device_id = '" . $device['device_id'] . "'") > '0') + { + echo('
  • + + Processes + +
  • '); + } + if (isset($config['collectd_dir']) && is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) { echo('
  • diff --git a/html/pages/device/processes.inc.php b/html/pages/device/processes.inc.php new file mode 100644 index 000000000..63944e82e --- /dev/null +++ b/html/pages/device/processes.inc.php @@ -0,0 +1,98 @@ + + * 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 . */ + +/** + * Alerts Tracking + * @author Daniel Preussker + * @copyright 2015 f0o, LibreNMS + * @license GPL + * @package LibreNMS + * @subpackage Pages + */ + +switch( $vars['order'] ) { + case "vsz": + $order = "`vsz`"; + break; + case "rss": + $order = "`rss`"; + break; + case "cputime": + $order = "`cputime`"; + break; + case "user": + $order = "`user`"; + break; + case "command": + $order = "`command`"; + break; + default: + $order = "`pid`"; + break; +} +if( $vars['by'] == "desc" ) { + $by = "desc"; +} else { + $by = "asc"; +} + +$heads = array( + 'PID' => '', + 'VSZ' => 'Virtual Memory', + 'RSS' => 'Resident Memory', + 'cputime' => '', + 'user' => '', + 'command' => '' +); + +echo "
    "; +foreach( $heads as $head=>$extra ) { + unset($lhead, $bhead); + $lhead = strtolower($head); + $bhead = 'asc'; + $icon = ""; + if( '`'.$lhead.'`' == $order ) { + $icon = " class='glyphicon glyphicon-chevron-"; + if( $by == 'asc' ) { + $bhead = 'desc'; + $icon .= 'up'; + } else { + $icon .= 'down'; + } + $icon .= "'"; + } + echo ''; +} +echo ""; + +foreach (dbFetchRows("SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY ".$order." ".$by, array($device['device_id'])) as $entry) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +} +echo"
     '; + if( !empty($extra) ) { + echo "$head"; + } else { + echo $head; + } + echo '
    '.$entry['pid'].''.format_si($entry['vsz']*1024).''.format_si($entry['rss']*1024).''.$entry['cputime'].''.$entry['user'].''.$entry['command'].'
    "; + +?> diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index b413501d8..ac4623cb4 100755 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -82,13 +82,15 @@ if ($device['os_group'] == "unix") if (!empty($agent_data['ps'])) { echo("Processes: "); + dbDelete('processes', 'device_id = ?', array($device['device_id'])); foreach (explode("\n", $agent_data['ps']) as $process) { - $process = preg_replace("/\((.*),([0-9]*),([0-9]*),([0-9\.]*)\)\ (.*)/", "\\1|\\2|\\3|\\4|\\5", $process); - list($user, $vsz, $rss, $pcpu, $command) = explode("|", $process, 5); - $processlist[] = array('user' => $user, 'vsz' => $vsz, 'rss' => $rss, 'pcpu' => $pcpu, 'command' => $command); + $process = preg_replace("/\((.*),([0-9]*),([0-9]*),([0-9\:]*),([0-9]*)\)\ (.*)/", "\\1|\\2|\\3|\\4|\\5|\\6", $process); + list($user, $vsz, $rss, $cputime, $pid, $command) = explode("|", $process, 6); + if( !empty($command) ) { + dbInsert(array('device_id' => $device['device_id'], 'pid' => $pid, 'user' => $user, 'vsz' => $vsz, 'rss' => $rss, 'cputime' => $cputime, 'command' => $command), 'processes'); + } } - #print_r($processlist); echo("\n"); } diff --git a/sql-schema/039.sql b/sql-schema/039.sql new file mode 100644 index 000000000..c9f2c7a8f --- /dev/null +++ b/sql-schema/039.sql @@ -0,0 +1 @@ +CREATE TABLE IF NOT EXISTS `processes` ( `device_id` int(11) NOT NULL, `pid` int(255) NOT NULL, `vsz` int(255) NOT NULL, `rss` int(255) NOT NULL, `cputime` varchar(12) NOT NULL, `user` varchar(50) NOT NULL, `command` varchar(255) NOT NULL, KEY `device_id` (`device_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; From f56c809f1ac71c00d6d70ba5bdff3444ee88261a Mon Sep 17 00:00:00 2001 From: f0o Date: Fri, 16 Jan 2015 08:51:26 +0000 Subject: [PATCH 05/13] Fix copyright issue --- html/pages/device/processes.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/pages/device/processes.inc.php b/html/pages/device/processes.inc.php index 63944e82e..41fda9288 100644 --- a/html/pages/device/processes.inc.php +++ b/html/pages/device/processes.inc.php @@ -14,7 +14,7 @@ * along with this program. If not, see . */ /** - * Alerts Tracking + * Process Listing * @author Daniel Preussker * @copyright 2015 f0o, LibreNMS * @license GPL From e4a1ff5b7c9b7e7f44ee17f3c066a1a8aeecb2d3 Mon Sep 17 00:00:00 2001 From: f0o Date: Fri, 16 Jan 2015 18:30:53 +0000 Subject: [PATCH 06/13] Added named/bind9 Application, Graphs, Check_MK-script --- .../graphs/application/bind_queries.inc.php | 49 ++++++++++++ html/pages/apps.inc.php | 1 + html/pages/device/apps/bind.inc.php | 38 +++++++++ includes/polling/applications/bind.inc.php | 78 +++++++++++++++++++ includes/polling/unix-agent.inc.php | 1 + scripts/agent-local/bind | 19 +++++ 6 files changed, 186 insertions(+) create mode 100644 html/includes/graphs/application/bind_queries.inc.php create mode 100644 html/pages/device/apps/bind.inc.php create mode 100644 includes/polling/applications/bind.inc.php create mode 100755 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..2cee28764 --- /dev/null +++ b/html/includes/graphs/application/bind_queries.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 . */ + +/** + * 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"; + +$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..b9f949ecb --- /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' => 'bind - 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..6fecbb854 --- /dev/null +++ b/includes/polling/applications/bind.inc.php @@ -0,0 +1,78 @@ + + * 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"; + unset($bind_parsed); + 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 b413501d8..36c23ef48 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..7e8ba8b0b --- /dev/null +++ b/scripts/agent-local/bind @@ -0,0 +1,19 @@ +#!/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 "<<>>" +> /etc/bind/named.stats +rndc stats && cat /etc/bind/named.stats + From b551a1141b6bab2df8128ff449bc381cca6ff3a4 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Sat, 17 Jan 2015 11:01:53 +0000 Subject: [PATCH 07/13] Updated about page to tidy up --- html/pages/about.inc.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/html/pages/about.inc.php b/html/pages/about.inc.php index 4b795cc45..13d7efae7 100644 --- a/html/pages/about.inc.php +++ b/html/pages/about.inc.php @@ -19,7 +19,6 @@ $git_log = `git log -10`;
    -

    License

     Copyright (C) 2006-2012 Adam Armstrong
    @@ -37,11 +36,9 @@ 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/.
    -   -

    Statistics

    @@ -71,10 +68,11 @@ $stat_vrf = dbFetchCell("SELECT COUNT(vrf_id) FROM `vrfs`"); $stat_vlans = dbFetchCell("SELECT COUNT(vlan_id) FROM `vlans`"); echo(" - +
    +
    - - + + @@ -109,9 +107,10 @@ echo("
    Devices$stat_devices Ports$stat_ports Devices$stat_devices Ports$stat_ports
    IPv4 Addresses$stat_ipv4_addy Toner$stat_toner
    +
    "); -print_optionbar_end(); ?> +?>
    @@ -129,10 +128,9 @@ $rrdtool_version = implode(" ",array_slice(explode(" ",shell_exec($config['rrdto $schema_version = dbFetchCell("SELECT version FROM dbSchema"); $git_log = `git log -10`; -print_optionbar_start(NULL); echo(" - +
    @@ -142,14 +140,14 @@ echo("
    $project_name$project_version
    DB Schema#$schema_version
    Apache$apache_version
    "); -print_optionbar_end(); ?>
    LibreNMS is a community-based project. Please feel free to join us and contribute code, documentation, and bug reports:

    - Web site | + Web site | + GitHub | Bug tracker | Mailing list | Twitter | @@ -160,12 +158,12 @@ print_optionbar_end();

    -

    The Team

    +

    The Team

    Paul Gear Project Founder
    Tyler Christiansen Developer
    -

    Acknowledgements

    +

    Acknowledgements

    Observium Codebase for fork.
    Mark James Silk Iconset.
    From 21f2a13166934ef5434184f02b7a3cd9225a80d0 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Sat, 17 Jan 2015 11:03:52 +0000 Subject: [PATCH 08/13] Add responsive table div --- html/pages/about.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/html/pages/about.inc.php b/html/pages/about.inc.php index 13d7efae7..c7ca46195 100644 --- a/html/pages/about.inc.php +++ b/html/pages/about.inc.php @@ -130,6 +130,7 @@ $git_log = `git log -10`; echo(" +
    @@ -138,6 +139,7 @@ echo("
    $project_name$project_version
    DB Schema#$schema_version
    MySQL$mysql_version
    RRDtool$rrdtool_version
    +
    "); From c9dcc966495ad1d0c36e337e3e60821712e2237e Mon Sep 17 00:00:00 2001 From: f0o Date: Sat, 17 Jan 2015 14:09:59 +0000 Subject: [PATCH 09/13] Added Documentation, Scrut-fixes --- doc/Agent.md | 27 ++++++++++++++++++- .../graphs/application/bind_queries.inc.php | 1 + html/pages/device/apps/bind.inc.php | 2 +- includes/polling/applications/bind.inc.php | 3 ++- scripts/agent-local/bind | 6 +++-- 5 files changed, 34 insertions(+), 5 deletions(-) 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 index 2cee28764..985e720e7 100644 --- a/html/includes/graphs/application/bind_queries.inc.php +++ b/html/includes/graphs/application/bind_queries.inc.php @@ -31,6 +31,7 @@ $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']); diff --git a/html/pages/device/apps/bind.inc.php b/html/pages/device/apps/bind.inc.php index b9f949ecb..18b7447d0 100644 --- a/html/pages/device/apps/bind.inc.php +++ b/html/pages/device/apps/bind.inc.php @@ -23,7 +23,7 @@ */ global $config; -$graphs = array('bind_queries' => 'bind - Queries'); +$graphs = array('bind_queries' => 'Queries'); foreach( $graphs as $key => $text ) { $graph_type = $key; $graph_array['height'] = "100"; diff --git a/includes/polling/applications/bind.inc.php b/includes/polling/applications/bind.inc.php index 6fecbb854..299fdbc6b 100644 --- a/includes/polling/applications/bind.inc.php +++ b/includes/polling/applications/bind.inc.php @@ -26,7 +26,8 @@ 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"; - unset($bind_parsed); + $bind_parsed = array(); + $prefix = ""; foreach( explode("\n",$bind) as $line ) { $pattern = '/^\+\+ ([^+]+) \+\+$/'; preg_match($pattern, $line, $matches); diff --git a/scripts/agent-local/bind b/scripts/agent-local/bind index 7e8ba8b0b..75110d982 100755 --- a/scripts/agent-local/bind +++ b/scripts/agent-local/bind @@ -13,7 +13,9 @@ # 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 "<<>>" -> /etc/bind/named.stats -rndc stats && cat /etc/bind/named.stats +> $stats +rndc stats && cat $stats From dd6f1f63fff89538222e04d20f6090a1d517a92a Mon Sep 17 00:00:00 2001 From: f0o Date: Sat, 17 Jan 2015 19:27:44 +0000 Subject: [PATCH 10/13] 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 000000000..14b4c8136 --- /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 000000000..6cec421c9 --- /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 000000000..b7c08f88e --- /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 000000000..2d2b03ebe --- /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 000000000..fcf2a6b64 --- /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 000000000..f676c35b5 --- /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 ac4623cb4..12f6a6016 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 000000000..9c980a80c --- /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 11/13] 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 751be33e1..41e4357ea 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 12/13] Added Documentation --- doc/Agent.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/Agent.md b/doc/Agent.md index 4ed036863..cf8a2508b 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. + From f674cd48bd482e86133c8dca83ad197ccbe4eb54 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Wed, 21 Jan 2015 19:00:57 +0000 Subject: [PATCH 13/13] Added version number for the branch --- html/pages/about.inc.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/html/pages/about.inc.php b/html/pages/about.inc.php index c7ca46195..f8b0f99f4 100644 --- a/html/pages/about.inc.php +++ b/html/pages/about.inc.php @@ -126,18 +126,18 @@ $mysql_version = dbFetchCell("SELECT version()"); $netsnmp_version = shell_exec($config['snmpget'] . " --version 2>&1"); $rrdtool_version = implode(" ",array_slice(explode(" ",shell_exec($config['rrdtool'] . " --version |head -n1")),1,1)); $schema_version = dbFetchCell("SELECT version FROM dbSchema"); -$git_log = `git log -10`; +$version = `git rev-parse --short HEAD`; echo("
    - - - - - - + + + + + +
    $project_name$project_version
    DB Schema#$schema_version
    Apache$apache_version
    PHP$php_version
    MySQL$mysql_version
    RRDtool$rrdtool_version
    Version$version
    DB Schema#$schema_version
    Apache$apache_version
    PHP$php_version
    MySQL$mysql_version
    RRDtool$rrdtool_version
    ");