From 62a562b39a6717d31222dcd58e9ad211618e7f02 Mon Sep 17 00:00:00 2001 From: VVelox Date: Wed, 3 May 2017 09:23:33 -0500 Subject: [PATCH] feature: Updated BIND application (#6218) * add BIND named poller * add BIND named graphs * add BIND stuff * add the color pallete used by this * add app support * white space cleanup * document the bind stuff * expand the linux package stuff a bit * note the agent and zero_stats value * now include the $mib stuff * white space cleanup * whoops, add the update app bit * correct a error added when merging * readd copyright info * note myself in the copyright info --- doc/Extensions/Applications.md | 65 +- .../graphs/application/bind_adb_in.inc.php | 29 + .../graphs/application/bind_adb_size.inc.php | 29 + .../application/bind_cache_deleted.inc.php | 29 + .../application/bind_cache_heap.inc.php | 34 + .../graphs/application/bind_cache_hm.inc.php | 39 + .../application/bind_cache_tree.inc.php | 34 + .../graphs/application/bind_incoming.inc.php | 108 +++ .../graphs/application/bind_outgoing.inc.php | 71 ++ .../application/bind_resolver_failure.inc.php | 65 ++ .../application/bind_resolver_naf.inc.php | 40 + .../application/bind_resolver_qrs.inc.php | 40 + .../application/bind_rr_negative.inc.php | 72 ++ .../application/bind_rr_positive.inc.php | 72 ++ .../graphs/application/bind_rtt.inc.php | 50 ++ .../application/bind_server_issues.inc.php | 44 ++ .../application/bind_server_received.inc.php | 59 ++ .../application/bind_server_results.inc.php | 59 ++ .../application/bind_sockets_accepted.inc.php | 29 + .../application/bind_sockets_active.inc.php | 45 ++ .../application/bind_sockets_bf.inc.php | 39 + .../application/bind_sockets_cf.inc.php | 39 + .../application/bind_sockets_closed.inc.php | 39 + .../application/bind_sockets_errors.inc.php | 59 ++ .../bind_sockets_established.inc.php | 39 + .../application/bind_sockets_opened.inc.php | 44 ++ html/pages/apps.inc.php | 18 + html/pages/device/apps/bind.inc.php | 42 +- includes/defaults.inc.php | 1 - includes/polling/applications/bind.inc.php | 748 +++++++++++++++--- 30 files changed, 1973 insertions(+), 108 deletions(-) create mode 100644 html/includes/graphs/application/bind_adb_in.inc.php create mode 100644 html/includes/graphs/application/bind_adb_size.inc.php create mode 100644 html/includes/graphs/application/bind_cache_deleted.inc.php create mode 100644 html/includes/graphs/application/bind_cache_heap.inc.php create mode 100644 html/includes/graphs/application/bind_cache_hm.inc.php create mode 100644 html/includes/graphs/application/bind_cache_tree.inc.php create mode 100644 html/includes/graphs/application/bind_incoming.inc.php create mode 100644 html/includes/graphs/application/bind_outgoing.inc.php create mode 100644 html/includes/graphs/application/bind_resolver_failure.inc.php create mode 100644 html/includes/graphs/application/bind_resolver_naf.inc.php create mode 100644 html/includes/graphs/application/bind_resolver_qrs.inc.php create mode 100644 html/includes/graphs/application/bind_rr_negative.inc.php create mode 100644 html/includes/graphs/application/bind_rr_positive.inc.php create mode 100644 html/includes/graphs/application/bind_rtt.inc.php create mode 100644 html/includes/graphs/application/bind_server_issues.inc.php create mode 100644 html/includes/graphs/application/bind_server_received.inc.php create mode 100644 html/includes/graphs/application/bind_server_results.inc.php create mode 100644 html/includes/graphs/application/bind_sockets_accepted.inc.php create mode 100644 html/includes/graphs/application/bind_sockets_active.inc.php create mode 100644 html/includes/graphs/application/bind_sockets_bf.inc.php create mode 100644 html/includes/graphs/application/bind_sockets_cf.inc.php create mode 100644 html/includes/graphs/application/bind_sockets_closed.inc.php create mode 100644 html/includes/graphs/application/bind_sockets_errors.inc.php create mode 100644 html/includes/graphs/application/bind_sockets_established.inc.php create mode 100644 html/includes/graphs/application/bind_sockets_opened.inc.php diff --git a/doc/Extensions/Applications.md b/doc/Extensions/Applications.md index 9dee458866..f0aa117256 100644 --- a/doc/Extensions/Applications.md +++ b/doc/Extensions/Applications.md @@ -6,7 +6,7 @@ You can use Application support to graph performance statistics from many applic Different applications support a variety of ways collect data: by direct connection to the application, snmpd extend, or [the agent](Agent-Setup.md). 1. [Apache](#apache) - SNMP extend, Agent -1. [BIND9/named](#bind9-aka-named) - Agent +1. [BIND9/named](#bind9-aka-named) - SNMP extend, Agent 1. [DHCP Stats](#dhcp-stats) - SNMP extend 1. [EXIM Stats](#exim-stats) - SNMP extend 1. [Fail2ban](#fail2ban) - SNMP extend @@ -67,31 +67,72 @@ extend apache /etc/snmp/apache-stats.py 2. On the device page in Librenms, edit your host and check the `Apache` under the Applications tab. ### BIND9 aka named -##### Agent -[Install the agent](Agent-Setup.md) on this device if it isn't already and copy the `bind` script to `/usr/lib/check_mk_agent/local/` -Create stats file with appropriate permissions: +1: Create stats file with appropriate permissions: ```shell -~$ touch /etc/bind/named.stats -~$ chown bind:bind /etc/bind/named.stats +~$ touch /var/run/named/stats +~$ chown bind:bind /var/run/named/stats ``` Change `user:group` to the user and group that's running bind/named. -Bind/named configuration: +2: Bind/named configuration: ```text options { ... - statistics-file "/etc/bind/named.stats"; + statistics-file "/var/run/named/stats"; zone-statistics yes; ... }; ``` -Restart your bind9/named after changing the configuration. -Verify that everything works by executing `rndc stats && cat /etc/bind/named.stats`. -In case you get a `Permission Denied` error, make sure you chown'ed correctly. +3: Restart your bind9/named after changing the configuration. -Note: if you change the path you will need to change the path in `scripts/agent-local/bind`. +4: Verify that everything works by executing `rndc stats && cat /var/run/named/stats`. In case you get a `Permission Denied` error, make sure you chown'ed correctly. + +5: Also be aware that this file is appended to each time `rndc stats` is called. Given this it is suggested you setup file rotation for it. Alternatively you can also set zero_stats to 1 in the config. + +6: The script for this also requires the Perl module File::ReadBackwards. On FreeBSD this is available as p5-File-ReadBackwards and on linux as perl-File-ReadBackwards in CentOS/Redhat and libfile-readbackwards-perl Debian/Ubuntu. If it is not available, it can be installed by `cpan -i File::ReadBackwards`. + +7: You may possible need to configure the agent/extend script as well. + +The config file's path defaults to the same path as the script, but with .config appended. So if the script is located at `/etc/snmp/bind`, the config file will be `/etc/snmp/bind.config`. Alternatively you can also specific a config via `-c $file`. + +Anything starting with a # is comment. The format for variables is $variable=$value. Empty lines are ignored. Spaces and tabes at either the start or end of a line are ignored. + +The variables are as below. +``` +rndc = The path to rndc. Default: /usr/bin/env rndc +call_rndc = A 0/1 boolean on weather to call rndc stats. Suggest to set to 0 if using netdata. Default: 1 +stats_file = The path to the named stats file. Default: /var/run/named/stats +agent = A 0/1 boolean for if this is being used as a LibreNMS agent or not. Default: 0 +zero_stats = A 0/1 boolean for if the stats file should be zeroed first. Default: 0 (1 if guessed) +``` + +If you want to guess at the configuration, call it with -g and it will print out what it thinks +it should be. + +8: On the device page in Librenms, edit your host and check `BIND` under the Applications tab. + +##### SNMP Extend + +1: Copy the shell script, postgres, to the desired host (the host must be added to LibreNMS devices) (wget https://github.com/librenms/librenms-agent/raw/master/snmp/bind -O /etc/snmp/bind) + +2: Make the script executable (chmod +x /etc/snmp/bind) + +3: Edit your snmpd.conf file and add: +``` +extend bind /etc/snmp/bind +``` + +4: Restart snmpd on the host in question. + +##### Agent + +1: [Install the agent](Agent-Setup.md) on this device if it isn't already and copy the script to `/usr/lib/check_mk_agent/local/bind` via `wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/bind -O /usr/lib/check_mk_agent/local/bind` + +2: Run `chmod +x /usr/lib/check_mk_agent/local/bind` + +3: Set the variable 'agent' to '1' in the config. ### DHCP Stats diff --git a/html/includes/graphs/application/bind_adb_in.inc.php b/html/includes/graphs/application/bind_adb_in.inc.php new file mode 100644 index 0000000000..11801811e5 --- /dev/null +++ b/html/includes/graphs/application/bind_adb_in.inc.php @@ -0,0 +1,29 @@ + $rrd_filename, + 'descr' => 'Addresses', + 'ds' => 'aiht', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Names', + 'ds' => 'niht', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_adb_size.inc.php b/html/includes/graphs/application/bind_adb_size.inc.php new file mode 100644 index 0000000000..ce36f11c51 --- /dev/null +++ b/html/includes/graphs/application/bind_adb_size.inc.php @@ -0,0 +1,29 @@ + $rrd_filename, + 'descr' => 'Address', + 'ds' => 'ahts', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Name', + 'ds' => 'nhts', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_cache_deleted.inc.php b/html/includes/graphs/application/bind_cache_deleted.inc.php new file mode 100644 index 0000000000..8167172dfa --- /dev/null +++ b/html/includes/graphs/application/bind_cache_deleted.inc.php @@ -0,0 +1,29 @@ + $rrd_filename, + 'descr' => 'Mem Exhaustion', + 'ds' => 'crddtme', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TTL Expiration', + 'ds' => 'crddtte', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_cache_heap.inc.php b/html/includes/graphs/application/bind_cache_heap.inc.php new file mode 100644 index 0000000000..48f1f5728e --- /dev/null +++ b/html/includes/graphs/application/bind_cache_heap.inc.php @@ -0,0 +1,34 @@ + $rrd_filename, + 'descr' => 'Total', + 'ds' => 'chmt', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'In Use', + 'ds' => 'chmiu', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Highest In Use', + 'ds' => 'chhmiu', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_cache_hm.inc.php b/html/includes/graphs/application/bind_cache_hm.inc.php new file mode 100644 index 0000000000..942f5b2450 --- /dev/null +++ b/html/includes/graphs/application/bind_cache_hm.inc.php @@ -0,0 +1,39 @@ + $rrd_filename, + 'descr' => 'Hits', + 'ds' => 'ch', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Misses', + 'ds' => 'cm', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Hits Frm Qry', + 'ds' => 'chfq', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Misses Frm Qry', + 'ds' => 'cmfq', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_cache_tree.inc.php b/html/includes/graphs/application/bind_cache_tree.inc.php new file mode 100644 index 0000000000..ef9d23d5eb --- /dev/null +++ b/html/includes/graphs/application/bind_cache_tree.inc.php @@ -0,0 +1,34 @@ + $rrd_filename, + 'descr' => 'Total', + 'ds' => 'ctmt', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'In Use', + 'ds' => 'ctmiu', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Highest In Use', + 'ds' => 'cthmiu', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_incoming.inc.php b/html/includes/graphs/application/bind_incoming.inc.php new file mode 100644 index 0000000000..0f8408a2d8 --- /dev/null +++ b/html/includes/graphs/application/bind_incoming.inc.php @@ -0,0 +1,108 @@ + + * 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 + */ + +$unitlen = 10; +$bigdescrlen = 9; +$smalldescrlen = 9; +$dostack = 0; +$printtotal = 0; +$unit_text = 'query/sec'; +$colours = 'psychedelic'; +$rrd_list = array(); + +$rrd_filename = rrd_name($device['hostname'], array('app', 'bind', $app['app_id'])); +$array = array( + 'any', + 'a', + 'aaaa', + 'cname', + 'mx', + 'ns', + 'ptr', + 'soa', + 'srv', + 'spf', +); +if (rrdtool_check_rrd_exists($rrd_filename)) { + foreach ($array as $ds) { + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => strtoupper($ds), + 'ds' => $ds, + ); + } +} else { + echo "file missing: $file"; +} + +$rrd_filename = rrd_name($device['hostname'], array('app', 'bind', $app['app_id'], 'incoming')); +$array = array( + 'afsdb', + 'apl', + 'caa', + 'cdnskey', + 'cds', + 'cert', + 'dhcid', + 'dlv', + 'dnskey', + 'ds', + 'ipseckey', + 'key', + 'kx', + 'loc', + 'naptr', + 'nsec', + 'nsec3', + 'nsec3param', + 'rrsig', + 'rp', + 'sig', + 'sshfp', + 'ta', + 'tkey', + 'tlsa', + 'tsig', + 'txt', + 'uri', + 'dname', + 'axfr', + 'ixfr', + 'opt', +); +if (rrdtool_check_rrd_exists($rrd_filename)) { + foreach ($array as $ds) { + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => strtoupper($ds), + 'ds' => $ds, + ); + } +} else { + echo "file missing: $file"; +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_outgoing.inc.php b/html/includes/graphs/application/bind_outgoing.inc.php new file mode 100644 index 0000000000..19e458004e --- /dev/null +++ b/html/includes/graphs/application/bind_outgoing.inc.php @@ -0,0 +1,71 @@ + $rrd_filename, + 'descr' => strtoupper($ds), + 'ds' => $ds, + ); + } +} else { + echo "file missing: $file"; +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_resolver_failure.inc.php b/html/includes/graphs/application/bind_resolver_failure.inc.php new file mode 100644 index 0000000000..6e46fc499f --- /dev/null +++ b/html/includes/graphs/application/bind_resolver_failure.inc.php @@ -0,0 +1,65 @@ + $rrd_filename, + 'descr' => 'NXDOMAIN', + 'ds' => 'nr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'SERVFAIL', + 'ds' => 'sr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'FORMERR', + 'ds' => 'fr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'REFUSED', + 'ds' => 'rr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'EDNS(0) qry fl', + 'ds' => 'eqf', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Trnctd Rcvd', + 'ds' => 'trr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Retry', + 'ds' => 'qr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Timeout', + 'ds' => 'qt', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Lame Dele.', + 'ds' => 'ldr', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_resolver_naf.inc.php b/html/includes/graphs/application/bind_resolver_naf.inc.php new file mode 100644 index 0000000000..a4b5fcbad7 --- /dev/null +++ b/html/includes/graphs/application/bind_resolver_naf.inc.php @@ -0,0 +1,40 @@ + $rrd_filename, + 'descr' => 'IPv4 NS Ftchd', + 'ds' => 'i4naf', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'IPv6 NS Ftchd', + 'ds' => 'i6naf', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'IPv4 Failed', + 'ds' => 'i4naff', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'IPv6 Failed', + 'ds' => 'i6naff', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_resolver_qrs.inc.php b/html/includes/graphs/application/bind_resolver_qrs.inc.php new file mode 100644 index 0000000000..c3790adcbc --- /dev/null +++ b/html/includes/graphs/application/bind_resolver_qrs.inc.php @@ -0,0 +1,40 @@ + $rrd_filename, + 'descr' => 'IPv4 Sent', + 'ds' => 'i4qs', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'IPv6 Sent', + 'ds' => 'i6qs', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'IPv4 Rcvd', + 'ds' => 'i4rr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'IPv6 Rcvd', + 'ds' => 'i6rr', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_rr_negative.inc.php b/html/includes/graphs/application/bind_rr_negative.inc.php new file mode 100644 index 0000000000..a93eb6c5b4 --- /dev/null +++ b/html/includes/graphs/application/bind_rr_negative.inc.php @@ -0,0 +1,72 @@ + $rrd_filename, + 'descr' => '!'.strtoupper($ds), + 'ds' => $ds, + ); + } +} else { + echo "file missing: $file"; +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_rr_positive.inc.php b/html/includes/graphs/application/bind_rr_positive.inc.php new file mode 100644 index 0000000000..3267fa0750 --- /dev/null +++ b/html/includes/graphs/application/bind_rr_positive.inc.php @@ -0,0 +1,72 @@ + $rrd_filename, + 'descr' => strtoupper($ds), + 'ds' => $ds, + ); + } +} else { + echo "file missing: $file"; +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_rtt.inc.php b/html/includes/graphs/application/bind_rtt.inc.php new file mode 100644 index 0000000000..24d5e662e9 --- /dev/null +++ b/html/includes/graphs/application/bind_rtt.inc.php @@ -0,0 +1,50 @@ + $rrd_filename, + 'descr' => '<10', + 'ds' => 'rttl10', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => '10-100', + 'ds' => 'rtt10t100', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => '100-500', + 'ds' => 'rtt100t500', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => '500-800', + 'ds' => 'rtt500t800', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => '800-1600', + 'ds' => 'rtt800t1600', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => '>1600', + 'ds' => 'rttg1600', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_server_issues.inc.php b/html/includes/graphs/application/bind_server_issues.inc.php new file mode 100644 index 0000000000..21863d7e83 --- /dev/null +++ b/html/includes/graphs/application/bind_server_issues.inc.php @@ -0,0 +1,44 @@ + $rrd_filename, + 'descr' => 'Auth Qry Rej', + 'ds' => 'aqr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Rec Qry Rej', + 'ds' => 'rqr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Trnctd Rsp Snt', + 'ds' => 'trs', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Oth Qry Fail', + 'ds' => 'oqf', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Qry Dropped', + 'ds' => 'qd', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_server_received.inc.php b/html/includes/graphs/application/bind_server_received.inc.php new file mode 100644 index 0000000000..b4825e2606 --- /dev/null +++ b/html/includes/graphs/application/bind_server_received.inc.php @@ -0,0 +1,59 @@ + $rrd_filename, + 'descr' => 'IPv4 Req', + 'ds' => 'i4rr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'IPv6 Req', + 'ds' => 'i6rr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP Req', + 'ds' => 'trr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP Qry', + 'ds' => 'tqr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'UDP Qry', + 'ds' => 'uqr', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'With EDNS(0)', + 'ds' => 'rwer', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Other EDNS', + 'ds' => 'oeor', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Dup. Qry', + 'ds' => 'dqr', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_server_results.inc.php b/html/includes/graphs/application/bind_server_results.inc.php new file mode 100644 index 0000000000..233da5664d --- /dev/null +++ b/html/includes/graphs/application/bind_server_results.inc.php @@ -0,0 +1,59 @@ + $rrd_filename, + 'descr' => 'Successful', + 'ds' => 'qrisa', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Authoritative', + 'ds' => 'qriaa', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Non Authoritative', + 'ds' => 'qrinaa', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'NX RR Set', + 'ds' => 'qrin', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'SERVFAIL', + 'ds' => 'qris', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'NXDOMAIN', + 'ds' => 'qrind', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'With EDNS(0)', + 'ds' => 'rwes', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Caused Rec', + 'ds' => 'qcr', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_sockets_accepted.inc.php b/html/includes/graphs/application/bind_sockets_accepted.inc.php new file mode 100644 index 0000000000..efe1ad8c9b --- /dev/null +++ b/html/includes/graphs/application/bind_sockets_accepted.inc.php @@ -0,0 +1,29 @@ + $rrd_filename, + 'descr' => 'TCP/IPv4', + 'ds' => 'ti4ca', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv6', + 'ds' => 'ti6ca', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_sockets_active.inc.php b/html/includes/graphs/application/bind_sockets_active.inc.php new file mode 100644 index 0000000000..83a913c52e --- /dev/null +++ b/html/includes/graphs/application/bind_sockets_active.inc.php @@ -0,0 +1,45 @@ + $rrd_filename, + 'descr' => 'UDP/IPv4', + 'ds' => 'ui4sa', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'UDP/IPv6', + 'ds' => 'ui6sa', + ); +# This appears to be buggy on various versions of BIND named and acts as a counter instead. +# $rrd_list[]=array( +# 'filename' => $rrd_filename, +# 'descr' => 'TCP/IPv4', +# 'ds' => 'ti4sa', +# ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv6', + 'ds' => 'ti6sa', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Raw', + 'ds' => 'rsa', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_sockets_bf.inc.php b/html/includes/graphs/application/bind_sockets_bf.inc.php new file mode 100644 index 0000000000..89bfbcb3c6 --- /dev/null +++ b/html/includes/graphs/application/bind_sockets_bf.inc.php @@ -0,0 +1,39 @@ + $rrd_filename, + 'descr' => 'UDP/IPv4', + 'ds' => 'ui4sbf', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'UDP/IPv6', + 'ds' => 'ui6sbf', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv4', + 'ds' => 'ti4sbf', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv6', + 'ds' => 'ti6sbf', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_sockets_cf.inc.php b/html/includes/graphs/application/bind_sockets_cf.inc.php new file mode 100644 index 0000000000..aed62b7325 --- /dev/null +++ b/html/includes/graphs/application/bind_sockets_cf.inc.php @@ -0,0 +1,39 @@ + $rrd_filename, + 'descr' => 'UDP/IPv4', + 'ds' => 'ui4scf', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'UDP/IPv6', + 'ds' => 'ui6scf', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv4', + 'ds' => 'ti4scf', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv6', + 'ds' => 'ti6scf', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_sockets_closed.inc.php b/html/includes/graphs/application/bind_sockets_closed.inc.php new file mode 100644 index 0000000000..4bd9a4cb24 --- /dev/null +++ b/html/includes/graphs/application/bind_sockets_closed.inc.php @@ -0,0 +1,39 @@ + $rrd_filename, + 'descr' => 'UDP/IPv4', + 'ds' => 'ui4sc', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'UDP/IPv6', + 'ds' => 'ui6sc', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv4', + 'ds' => 'ti4sc', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv6', + 'ds' => 'ti6sc', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_sockets_errors.inc.php b/html/includes/graphs/application/bind_sockets_errors.inc.php new file mode 100644 index 0000000000..fedbcfa90a --- /dev/null +++ b/html/includes/graphs/application/bind_sockets_errors.inc.php @@ -0,0 +1,59 @@ + $rrd_filename, + 'descr' => 'UDP/IPv4 send', + 'ds' => 'ui4se', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'UDP/IPv6 send', + 'ds' => 'ui6se', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv4 send', + 'ds' => 'ti4se', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv6 send', + 'ds' => 'ti6se', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'UDP/IPv4 recv', + 'ds' => 'ui4re', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'UDP/IPv6 recv', + 'ds' => 'ui6re', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv4 recv', + 'ds' => 'ti4re', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv6 recv', + 'ds' => 'ti6re', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_sockets_established.inc.php b/html/includes/graphs/application/bind_sockets_established.inc.php new file mode 100644 index 0000000000..cf34b95eed --- /dev/null +++ b/html/includes/graphs/application/bind_sockets_established.inc.php @@ -0,0 +1,39 @@ + $rrd_filename, + 'descr' => 'UDP/IPv4', + 'ds' => 'ui4ce', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'UDP/IPv6', + 'ds' => 'ui6ce', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv4', + 'ds' => 'ti4ce', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv6', + 'ds' => 'ti6ce', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/bind_sockets_opened.inc.php b/html/includes/graphs/application/bind_sockets_opened.inc.php new file mode 100644 index 0000000000..e2f7b58485 --- /dev/null +++ b/html/includes/graphs/application/bind_sockets_opened.inc.php @@ -0,0 +1,44 @@ + $rrd_filename, + 'descr' => 'UDP/IPv4', + 'ds' => 'ui4so', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'UDP/IPv6', + 'ds' => 'ui6so', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv4', + 'ds' => 'ti4so', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'TCP/IPv6', + 'ds' => 'ti6so', + ); + $rrd_list[]=array( + 'filename' => $rrd_filename, + 'descr' => 'Raw', + 'ds' => 'rso', + ); +} else { + d_echo('RRD "'.$rrd_filename.'" not found'); +} + +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/pages/apps.inc.php b/html/pages/apps.inc.php index 4891869684..21f4ecc2f1 100644 --- a/html/pages/apps.inc.php +++ b/html/pages/apps.inc.php @@ -228,6 +228,24 @@ $graphs['unbound'] = array( 'queries', ); +$graphs['bind'] = array( + 'incoming', + 'outgoing', + 'rr_positive', + 'rr_negative', + 'rtt', + 'resolver_failure', + 'resolver_qrs', + 'resolver_naf', + 'server_received', + 'server_results', + 'server_issues', + 'cache_hm', + 'adb_in', + 'sockets_active', + 'sockets_errors', +); + $graphs['smart'] = array( 'id5', 'id10', diff --git a/html/pages/device/apps/bind.inc.php b/html/pages/device/apps/bind.inc.php index ee1860af26..80cd4ed619 100644 --- a/html/pages/device/apps/bind.inc.php +++ b/html/pages/device/apps/bind.inc.php @@ -22,10 +22,38 @@ * @license GPL * @package LibreNMS * @subpackage Apps + * @updated in 2017 by Zane C. Bowers-Hadley */ global $config; -$graphs = array('bind_queries' => 'Queries'); + +$graphs = array( + 'bind_incoming' => 'Incoming', + 'bind_outgoing' => 'Outgoing', + 'bind_rr_positive' => 'RR Sets Positive', + 'bind_rr_negative' => 'RR Sets Negative', + 'bind_rtt' => 'Resolver RTT', + 'bind_resolver_failure' => 'Resolver Failures', + 'bind_resolver_qrs' => 'Resolver Quiries Sent/Received', + 'bind_resolver_naf' => 'NS Query Status', + 'bind_server_received' => 'Server Queries/Requests Received', + 'bind_server_results' => 'Server Results', + 'bind_server_issues' => 'Server Issues', + 'bind_cache_hm' => 'Cache Hits & Misses', + 'bind_cache_tree' => 'Cache Tree Memory', + 'bind_cache_heap' => 'Cache Heap Memory', + 'bind_cache_deleted' => 'Cache Record Deletion', + 'bind_adb_size' => 'Address & Name Hash Table Size', + 'bind_adb_in' => 'Address & Name In Hash Table', + 'bind_sockets_active' => 'Active Sockets', + 'bind_sockets_errors' => 'Socket Errors Per Second', + 'bind_sockets_opened' => 'Opened Sockets Per Second', + 'bind_sockets_closed' => 'Closed Sockets Per Second', + 'bind_sockets_bf' => 'Socket Bind Failures Per Second', + 'bind_sockets_cf' => 'Socket Connect Failures Per Second', + 'bind_sockets_established' => 'Connections Established Per Second', +); + foreach ($graphs as $key => $text) { $graph_type = $key; $graph_array['height'] = '100'; @@ -33,7 +61,15 @@ foreach ($graphs as $key => $text) { $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $app['app_id']; $graph_array['type'] = 'application_'.$key; - echo "

$text

"; + + echo '
+
+

'.$text.'

+
+
+
'; include 'includes/print-graphrow.inc.php'; - echo ''; + echo '
'; + echo '
'; + echo '
'; } diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index b23709cfff..316b5a25d3 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -338,7 +338,6 @@ $config['graph_colours']['mega']=array_merge( $config['graph_colours']['mixed'] ); - // Map colors $config['network_map_legend'] = array( '0' => '#aeaeae', diff --git a/includes/polling/applications/bind.inc.php b/includes/polling/applications/bind.inc.php index d0b3d0e35f..7c23f37c8d 100644 --- a/includes/polling/applications/bind.inc.php +++ b/includes/polling/applications/bind.inc.php @@ -1,102 +1,666 @@ - * 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 - */ use LibreNMS\RRD\RrdDefinition; -$name = 'bind'; -$app_id = $app['app_id']; -if (!empty($agent_data['app'][$name]) && $app_id > 0) { - echo ' bind '; - $bind = $agent_data['app'][$name]; - $bind_parsed = array(); - $prefix = ''; - update_application($app, $bind); - foreach (explode("\n", $bind) as $line) { - $pattern = '/^\+\+ ([^+]+) \+\+$/'; - preg_match($pattern, $line, $matches); - if (!empty($matches)) { - $prefix = str_replace(' ', '_', strtolower($matches[1])); - $view = $item = $cnt = ''; - } +echo ' bind '; - $pattern = '/^\[View: (\w+)(| .*)\]/'; - preg_match($pattern, $line, $matches); - if (!empty($matches)) { - if ($matches[1] == 'default') { - continue; - } else { - $view = $matches[1]; - } - } +if (!empty($agent_data['app'][$name])) { + $bind = $agent_data['app'][$name]; +} else { + $name = 'bind'; + $app_id = $app['app_id']; + $options = '-O qv'; + $mib = 'NET-SNMP-EXTEND-MIB'; + $oid = 'nsExtendOutputFull.4.98.105.110.100'; + $bind = snmp_get($device, $oid, $options, $mib); +} +update_application($app, $bind); - $pattern = '/^\[(.*)\]$/'; - preg_match($pattern, $line, $matches); - if (!empty($matches)) { - $prefix = $matches[1]; - } +list ($incoming, $outgoing, $server, $resolver, $cache, $rrsets, $adb, $sockets) = explode("\n", $bind); - $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; - } - } - }//end foreach +// +// INCOMING PROCESSING +// +list ($a, $aaaa, $afsdb, $apl, $caa, $cdnskey, $cds, $cert, $cname, $dhcid, $dlv, $dnskey, $ds, $ipseckey, $key, $kx, + $loc, $mx, $naptr, $ns, $nsec, $nsec3, $nsec3param, $ptr, $rrsig, $rp, $sig, $soa, $srv, $sshfp, $ta, $tkey, $tlsa, + $tsig, $txt, $uri, $dname, $any, $axfr, $ixfr, $opt, $spf) = explode(',', $incoming); - $rrd_name = array('app', $name, $app_id); - $rrd_def = RrdDefinition::make() - ->addDataset('any', 'COUNTER', 0, 125000000000) - ->addDataset('a', 'COUNTER', 0, 125000000000) - ->addDataset('aaaa', 'COUNTER', 0, 125000000000) - ->addDataset('cname', 'COUNTER', 0, 125000000000) - ->addDataset('mx', 'COUNTER', 0, 125000000000) - ->addDataset('ns', 'COUNTER', 0, 125000000000) - ->addDataset('ptr', 'COUNTER', 0, 125000000000) - ->addDataset('soa', 'COUNTER', 0, 125000000000) - ->addDataset('srv', 'COUNTER', 0, 125000000000) - ->addDataset('spf', 'COUNTER', 0, 125000000000); +$rrd_name = array('app', $name, $app_id); +$rrd_def = RrdDefinition::make() + ->addDataset('any', 'DERIVE', 0) + ->addDataset('a', 'DERIVE', 0) + ->addDataset('aaaa', 'DERIVE', 0) + ->addDataset('cname', 'DERIVE', 0) + ->addDataset('mx', 'DERIVE', 0) + ->addDataset('ns', 'DERIVE', 0) + ->addDataset('ptr', 'DERIVE', 0) + ->addDataset('soa', 'DERIVE', 0) + ->addDataset('srv', 'DERIVE', 0) + ->addDataset('spf', 'DERIVE', 0); - $fields = array( - 'any' => ((int)$bind_parsed['incoming_queries']['any']), - 'a' => ((int)$bind_parsed['incoming_queries']['a']), - 'aaaa' => ((int)$bind_parsed['incoming_queries']['aaaa']), - 'cname' => ((int)$bind_parsed['incoming_queries']['cname']), - 'mx' => ((int)$bind_parsed['incoming_queries']['mx']), - 'ns' => ((int)$bind_parsed['incoming_queries']['ns']), - 'ptr' => ((int)$bind_parsed['incoming_queries']['ptr']), - 'soa' => ((int)$bind_parsed['incoming_queries']['soa']), - 'srv' => ((int)$bind_parsed['incoming_queries']['srv']), - 'spf' => ((int)$bind_parsed['incoming_queries']['spf']), - ); +$fields = array( + 'any' => $any, + 'a' => $a, + 'aaaa' => $aaaa, + 'cname' => $cname, + 'mx' => $mx, + 'ns' => $ns, + 'ptr' => $ptr, + 'soa' => $soa, + 'srv' => $srv, + 'spf' => $spf, +); - $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); - data_update($device, 'app', $tags, $fields); -}//end if +$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +data_update($device, 'app', $tags, $fields); + +$rrd_name = array('app', $name, $app_id, 'incoming'); +$rrd_def = RrdDefinition::make() + ->addDataset('afsdb', 'DERIVE', 0) + ->addDataset('apl', 'DERIVE', 0) + ->addDataset('caa', 'DERIVE', 0) + ->addDataset('cdnskey', 'DERIVE', 0) + ->addDataset('cds', 'DERIVE', 0) + ->addDataset('cert', 'DERIVE', 0) + ->addDataset('dhcid', 'DERIVE', 0) + ->addDataset('dlv', 'DERIVE', 0) + ->addDataset('dnskey', 'DERIVE', 0) + ->addDataset('ds', 'DERIVE', 0) + ->addDataset('ipseckey', 'DERIVE', 0) + ->addDataset('key', 'DERIVE', 0) + ->addDataset('kx', 'DERIVE', 0) + ->addDataset('loc', 'DERIVE', 0) + ->addDataset('naptr', 'DERIVE', 0) + ->addDataset('nsec', 'DERIVE', 0) + ->addDataset('nsec3', 'DERIVE', 0) + ->addDataset('nsec3param', 'DERIVE', 0) + ->addDataset('rrsig', 'DERIVE', 0) + ->addDataset('rp', 'DERIVE', 0) + ->addDataset('sig', 'DERIVE', 0) + ->addDataset('sshfp', 'DERIVE', 0) + ->addDataset('ta', 'DERIVE', 0) + ->addDataset('tkey', 'DERIVE', 0) + ->addDataset('tlsa', 'DERIVE', 0) + ->addDataset('tsig', 'DERIVE', 0) + ->addDataset('txt', 'DERIVE', 0) + ->addDataset('uri', 'DERIVE', 0) + ->addDataset('dname', 'DERIVE', 0) + ->addDataset('axfr', 'DERIVE', 0) + ->addDataset('ixfr', 'DERIVE', 0) + ->addDataset('opt', 'DERIVE', 0); + +$fields = array( + 'afsdb' => $afsdb, + 'apl' => $apl, + 'caa' => $caa, + 'cdnskey' => $cdnskey, + 'cds' => $cds, + 'cert' => $cert, + 'dhcid' => $dhcid, + 'dlv' => $dlv, + 'dnskey' => $dnskey, + 'ds' => $ds, + 'ipseckey' => $ipseckey, + 'key' => $key, + 'kx' => $kx, + 'loc' => $loc, + 'naptr' => $naptr, + 'nsec' => $nsec, + 'nsec3' => $nsec3, + 'nsec3param' => $nsec3param, + 'rrsig' => $rrsig, + 'rp' => $rp, + 'sig' => $sig, + 'sshfp' => $sshfp, + 'ta' => $ta, + 'tkey' => $tkey, + 'tlsa' => $tlsa, + 'tsig' => $tsig, + 'txt' => $txt, + 'uri' => $uri, + 'dname' => $dname, + 'axfr' => $axfr, + 'ixfr' => $ixfr, + 'opt' => $opt, +); + +$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +data_update($device, 'app', $tags, $fields); + +// +// OUTGOING PROCESSING +// +list ($a, $aaaa, $afsdb, $apl, $caa, $cdnskey, $cds, $cert, $cname, $dhcid, $dlv, $dnskey, $ds, $ipseckey, $key, $kx, + $loc, $mx, $naptr, $ns, $nsec, $nsec3, $nsec3param, $ptr, $rrsig, $rp, $sig, $soa, $srv, $sshfp, $ta, $tkey, $tlsa, + $tsig, $txt, $uri, $dname, $any, $axfr, $ixfr, $opt, $spf) = explode(',', $outgoing); + +$rrd_name = array('app', $name, $app_id, 'outgoing'); +$rrd_def = RrdDefinition::make() + ->addDataset('any', 'DERIVE', 0) + ->addDataset('a', 'DERIVE', 0) + ->addDataset('aaaa', 'DERIVE', 0) + ->addDataset('cname', 'DERIVE', 0) + ->addDataset('mx', 'DERIVE', 0) + ->addDataset('ns', 'DERIVE', 0) + ->addDataset('ptr', 'DERIVE', 0) + ->addDataset('soa', 'DERIVE', 0) + ->addDataset('srv', 'DERIVE', 0) + ->addDataset('spf', 'DERIVE', 0) + ->addDataset('afsdb', 'DERIVE', 0) + ->addDataset('apl', 'DERIVE', 0) + ->addDataset('caa', 'DERIVE', 0) + ->addDataset('cdnskey', 'DERIVE', 0) + ->addDataset('cds', 'DERIVE', 0) + ->addDataset('cert', 'DERIVE', 0) + ->addDataset('dhcid', 'DERIVE', 0) + ->addDataset('dlv', 'DERIVE', 0) + ->addDataset('dnskey', 'DERIVE', 0) + ->addDataset('ds', 'DERIVE', 0) + ->addDataset('ipseckey', 'DERIVE', 0) + ->addDataset('key', 'DERIVE', 0) + ->addDataset('kx', 'DERIVE', 0) + ->addDataset('loc', 'DERIVE', 0) + ->addDataset('naptr', 'DERIVE', 0) + ->addDataset('nsec', 'DERIVE', 0) + ->addDataset('nsec3', 'DERIVE', 0) + ->addDataset('nsec3param', 'DERIVE', 0) + ->addDataset('rrsig', 'DERIVE', 0) + ->addDataset('rp', 'DERIVE', 0) + ->addDataset('sig', 'DERIVE', 0) + ->addDataset('sshfp', 'DERIVE', 0) + ->addDataset('ta', 'DERIVE', 0) + ->addDataset('tkey', 'DERIVE', 0) + ->addDataset('tlsa', 'DERIVE', 0) + ->addDataset('tsig', 'DERIVE', 0) + ->addDataset('txt', 'DERIVE', 0) + ->addDataset('uri', 'DERIVE', 0) + ->addDataset('dname', 'DERIVE', 0) + ->addDataset('axfr', 'DERIVE', 0) + ->addDataset('ixfr', 'DERIVE', 0) + ->addDataset('opt', 'DERIVE', 0); + +$fields = array( + 'any' => $any, + 'a' => $a, + 'aaaa' => $aaaa, + 'cname' => $cname, + 'mx' => $mx, + 'ns' => $ns, + 'ptr' => $ptr, + 'soa' => $soa, + 'srv' => $srv, + 'spf' => $spf, + 'afsdb' => $afsdb, + 'apl' => $apl, + 'caa' => $caa, + 'cdnskey' => $cdnskey, + 'cds' => $cds, + 'cert' => $cert, + 'dhcid' => $dhcid, + 'dlv' => $dlv, + 'dnskey' => $dnskey, + 'ds' => $ds, + 'ipseckey' => $ipseckey, + 'key' => $key, + 'kx' => $kx, + 'loc' => $loc, + 'naptr' => $naptr, + 'nsec' => $nsec, + 'nsec3' => $nsec3, + 'nsec3param' => $nsec3param, + 'rrsig' => $rrsig, + 'rp' => $rp, + 'sig' => $sig, + 'sshfp' => $sshfp, + 'ta' => $ta, + 'tkey' => $tkey, + 'tlsa' => $tlsa, + 'tsig' => $tsig, + 'txt' => $txt, + 'uri' => $uri, + 'dname' => $dname, + 'axfr' => $axfr, + 'ixfr' => $ixfr, + 'opt' => $opt, +); + +$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +data_update($device, 'app', $tags, $fields); + +// +// SERVER PROCESSING +// +list ($i4rr, $i6rr, $rwer, $trr, $aqr, $rqr, $rs, $trs, $rwes, $qrisa, $qriaa, $qrinaa, $qrin, $qris, $qrind, + $qcr, $dqr, $oqf, $uqr, $tqr, $oeor, $qd) = explode(',', $server); + +$rrd_name = array('app', $name, $app_id, 'server'); +$rrd_def = RrdDefinition::make() + ->addDataset('i4rr', 'DERIVE', 0) + ->addDataset('i6rr', 'DERIVE', 0) + ->addDataset('rwer', 'DERIVE', 0) + ->addDataset('trr', 'DERIVE', 0) + ->addDataset('aqr', 'DERIVE', 0) + ->addDataset('rqr', 'DERIVE', 0) + ->addDataset('rs', 'DERIVE', 0) + ->addDataset('trs', 'DERIVE', 0) + ->addDataset('rwes', 'DERIVE', 0) + ->addDataset('qrisa', 'DERIVE', 0) + ->addDataset('qriaa', 'DERIVE', 0) + ->addDataset('qrinaa', 'DERIVE', 0) + ->addDataset('qrin', 'DERIVE', 0) + ->addDataset('qris', 'DERIVE', 0) + ->addDataset('qrind', 'DERIVE', 0) + ->addDataset('qcr', 'DERIVE', 0) + ->addDataset('dqr', 'DERIVE', 0) + ->addDataset('oqf', 'DERIVE', 0) + ->addDataset('uqr', 'DERIVE', 0) + ->addDataset('tqr', 'DERIVE', 0) + ->addDataset('oeor', 'DERIVE', 0) + ->addDataset('qd', 'DERIVE', 0); + +$fields = array( + 'i4rr' => $i4rr, + 'i6rr' => $i6rr, + 'rwer' => $rwer, + 'trr' => $trr, + 'aqr' => $aqr, + 'rqr' => $rqr, + 'rs' => $rs, + 'trs' => $trs, + 'rwes' => $rwes, + 'qrisa' => $qrisa, + 'qriaa' => $qriaa, + 'qrinaa' => $qrinaa, + 'qrin' => $qrin, + 'qris' => $qris, + 'qrind' => $qrind, + 'qcr' => $qcr, + 'dqr' => $dqr, + 'oqf' => $oqf, + 'uqr' => $uqr, + 'tqr' => $tqr, + 'oeor' => $oeor, + 'qd' => $qd, +); + +$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +data_update($device, 'app', $tags, $fields); + +// +// RESOLVER PROCESSING +// +list ($i4qs, $i6qs, $i4rr, $i6rr, $nr, $sr, $fr, $eqf, $trr, $ldr, $qr, $qt, $i4naf, $i6naf, + $i4naff, $i6naff, $rttl10, $rtt10t100, $rtt100t500, $rtt500t800, $rtt800t1600, $rttg1600, + $bs, $rr) = explode(',', $resolver); + +$rrd_name = array('app', $name, $app_id, 'resolver'); +$rrd_def = RrdDefinition::make() + ->addDataset('i4qs', 'DERIVE', 0) + ->addDataset('i6qs', 'DERIVE', 0) + ->addDataset('i4rr', 'DERIVE', 0) + ->addDataset('i6rr', 'DERIVE', 0) + ->addDataset('nr', 'DERIVE', 0) + ->addDataset('sr', 'DERIVE', 0) + ->addDataset('fr', 'DERIVE', 0) + ->addDataset('eqf', 'DERIVE', 0) + ->addDataset('trr', 'DERIVE', 0) + ->addDataset('ldr', 'DERIVE', 0) + ->addDataset('qr', 'DERIVE', 0) + ->addDataset('qt', 'DERIVE', 0) + ->addDataset('i4naf', 'DERIVE', 0) + ->addDataset('i6naf', 'DERIVE', 0) + ->addDataset('i4naff', 'DERIVE', 0) + ->addDataset('i6naff', 'DERIVE', 0) + ->addDataset('rttl10', 'DERIVE', 0) + ->addDataset('rtt10t100', 'DERIVE', 0) + ->addDataset('rtt100t500', 'DERIVE', 0) + ->addDataset('rtt500t800', 'DERIVE', 0) + ->addDataset('rtt800t1600', 'DERIVE', 0) + ->addDataset('rttg1600', 'DERIVE', 0) + ->addDataset('bs', 'GAUGE', 0) + ->addDataset('rr', 'DERIVE', 0); + + +$fields = array( + 'i4qs' => $i4qs, + 'i6qs' => $i6qs, + 'i4rr' => $i4rr, + 'i6rr' => $i6rr, + 'nr' => $nr, + 'sr' => $sr, + 'fr' => $fr, + 'eqf' => $eqf, + 'trr' => $trr, + 'ldr' => $ldr, + 'qr' => $qr, + 'qt' => $qt, + 'i4naf' => $i4naf, + 'i6naf' => $i6naf, + 'i4naff' => $i4naff, + 'i6naff' => $i6naff, + 'rttl10' => $rttl10, + 'rtt10t100' => $rtt10t100, + 'rtt100t500' => $rtt100t500, + 'rtt500t800' => $rtt500t800, + 'rtt800t1600' => $rtt800t1600, + 'rttg1600' => $rttg1600, + 'bs' => $bs, + 'rr' => $rr, +); + +$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +data_update($device, 'app', $tags, $fields); + +// +// CACHE PROCESSING +// +list ($ch, $cm, $chfq, $cmfq, $crddtme, $crddtte, $cdn, $cdhb, $ctmt, $ctmiu, $cthmiu, + $chmt, $chmiu, $chhmiu) = explode(',', $cache); + +$rrd_name = array('app', $name, $app_id, 'cache'); +$rrd_def = RrdDefinition::make() + ->addDataset('ch', 'DERIVE', 0) + ->addDataset('cm', 'DERIVE', 0) + ->addDataset('chfq', 'DERIVE', 0) + ->addDataset('cmfq', 'DERIVE', 0) + ->addDataset('crddtme', 'DERIVE', 0) + ->addDataset('crddtte', 'DERIVE', 0) + ->addDataset('cdn', 'GAUGE', 0) + ->addDataset('cdhb', 'GAUGE', 0) + ->addDataset('ctmt', 'GAUGE', 0) + ->addDataset('ctmiu', 'GAUGE', 0) + ->addDataset('cthmiu', 'GAUGE', 0) + ->addDataset('chmt', 'GAUGE', 0) + ->addDataset('chmiu', 'GAUGE', 0) + ->addDataset('chhmiu', 'GAUGE', 0); + +$fields = array( + 'ch' => $ch, + 'cm' => $cm, + 'chfq' => $chfq, + 'cmfq' => $cmfq, + 'crddtme' => $crddtme, + 'crddtte' => $crddtte, + 'cdn' => $cdn, + 'cdhb' => $cdhb, + 'ctmt' => $ctmt, + 'ctmiu' => $ctmiu, + 'cthmiu' => $cthmiu, + 'chmt' => $chmt, + 'chmiu' => $chmiu, + 'chhmiu' => $chhmiu, +); + +$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); + +// +// ADB PROCESSING +// +list ($ahts, $aiht, $nhts, $niht) = explode(',', $adb); + +$rrd_name = array('app', $name, $app_id, 'adb'); +$rrd_def = RrdDefinition::make() + ->addDataset('ahts', 'GAUGE', 0) + ->addDataset('aiht', 'GAUGE', 0) + ->addDataset('nhts', 'GAUGE', 0) + ->addDataset('niht', 'GAUGE', 0); + +$fields = array( + 'ahts' => $ahts, + 'aiht' => $aiht, + 'nhts' => $nhts, + 'niht' => $niht +); + +$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +data_update($device, 'app', $tags, $fields); + +// +// SOCKETS PROCESSING +// +list ($ui4so, $ui6so, $ti4so, $ti6so, $rso, $ui4sc, $ui6sc, $ti4sc, $ti6sc, $ui4sbf, $ti4sbf, $ui6sbf, $ti6sbf, + $ui4scf, $ti4scf, $ui6scf, $ti6scf, $ui4ce, $ti4ce, $ui6ce, $ti6ce, $ti4ca, $ti6ca, $ui4se, $ti4se, $ui6se, + $ti6se, $ui4re, $ti4re, $ui6re, $ti6re, $ui4sa, $ui6sa, $ti4sa, $ti6sa, $rsa) = explode(',', $sockets); + +$rrd_name = array('app', $name, $app_id, 'sockets'); +$rrd_def = RrdDefinition::make() + ->addDataset('ui4so', 'DERIVE', 0) + ->addDataset('ui6so', 'DERIVE', 0) + ->addDataset('ti4so', 'DERIVE', 0) + ->addDataset('ti6so', 'DERIVE', 0) + ->addDataset('rso', 'DERIVE', 0) + ->addDataset('ui4sc', 'DERIVE', 0) + ->addDataset('ui6sc', 'DERIVE', 0) + ->addDataset('ti4sc', 'DERIVE', 0) + ->addDataset('ti6sc', 'DERIVE', 0) + ->addDataset('ui4sbf', 'DERIVE', 0) + ->addDataset('ti4sbf', 'DERIVE', 0) + ->addDataset('ui6sbf', 'DERIVE', 0) + ->addDataset('ti6sbf', 'DERIVE', 0) + ->addDataset('ui4scf', 'DERIVE', 0) + ->addDataset('ti4scf', 'DERIVE', 0) + ->addDataset('ui6scf', 'DERIVE', 0) + ->addDataset('ti6scf', 'DERIVE', 0) + ->addDataset('ui4ce', 'DERIVE', 0) + ->addDataset('ti4ce', 'DERIVE', 0) + ->addDataset('ui6ce', 'DERIVE', 0) + ->addDataset('ti6ce', 'DERIVE', 0) + ->addDataset('ti4ca', 'DERIVE', 0) + ->addDataset('ti6ca', 'DERIVE', 0) + ->addDataset('ui4se', 'DERIVE', 0) + ->addDataset('ti4se', 'DERIVE', 0) + ->addDataset('ui6se', 'DERIVE', 0) + ->addDataset('ti6se', 'DERIVE', 0) + ->addDataset('ui4re', 'DERIVE', 0) + ->addDataset('ti4re', 'DERIVE', 0) + ->addDataset('ui6re', 'DERIVE', 0) + ->addDataset('ti6re', 'DERIVE', 0) + ->addDataset('ui4sa', 'GAUGE', 0) + ->addDataset('ui6sa', 'GAUGE', 0) + ->addDataset('ti4sa', 'GAUGE', 0) + ->addDataset('ti6sa', 'GAUGE', 0) + ->addDataset('rsa', 'GAUGE', 0); + + +$fields = array( + 'ui4so' => $ui4so, + 'ui6so' => $ui6so, + 'ti4so' => $ti4so, + 'ti6so' => $ti6so, + 'rso' => $rso, + 'ui4sc' => $ui4sc, + 'ui6sc' => $ui6sc, + 'ti4sc' => $ti4sc, + 'ti6sc' => $ti6sc, + 'ui4sbf' => $ui4sbf, + 'ti4sbf' => $ti4sbf, + 'ui6sbf' => $ui6sbf, + 'ti6sbf' => $ti6sbf, + 'ui4scf' => $ui4scf, + 'ti4scf' => $ti4scf, + 'ui6scf' => $ui6scf, + 'ti6scf' => $ti6scf, + 'ui4ce' => $ui4ce, + 'ti4ce' => $ti4ce, + 'ui6ce' => $ui6ce, + 'ti6ce' => $ti6ce, + 'ti4ca' => $ti4ca, + 'ti6ca' => $ti6ca, + 'ui4se' => $ui4se, + 'ti4se' => $ti4se, + 'ui6se' => $ui6se, + 'ti6se' => $ti6se, + 'ui4re' => $ui4re, + 'ti4re' => $ti4re, + 'ui6re' => $ui6re, + 'ti6re' => $ti6re, + 'ui4sa' => $ui4sa, + 'ui6sa' => $ui6sa, + 'ti4sa' => $ti4sa, + 'ti6sa' => $ti6sa, + 'rsa' => $ti6sa, +); + +$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +data_update($device, 'app', $tags, $fields); + +// +// RR SETS PROCESSING +// +list ($a, $aaaa, $afsdb, $apl, $caa, $cdnskey, $cds, $cert, $cname, $dhcid, $dlv, $dnskey, $ds, $ipseckey, $key, $kx, + $loc, $mx, $naptr, $ns, $nsec, $nsec3, $nsec3param, $ptr, $rrsig, $rp, $sig, $soa, $srv, $sshfp, $ta, $tkey, $tlsa, + $tsig, $txt, $uri, $dname, $nxdomain, $any, $axfr, $ixfr, $opt, $spf, $nota, $notaaaa, $notafsdb, $notapl, $notcaa, $notcdnskey, + $notcds, $notcert, $notcname, $notdhcid, $notdlv, $notdnskey, $notds, $notipseckey, $notkey, $notkx, $notloc, $notmx, + $notnaptr, $notns, $notnsec, $notnsec3, $notnsec3param, $notptr, $notrrsig, $notrp, $notsig, $notsoa, $notsrv, + $notsshfp, $notta, $nottkey, $nottlsa, $nottsig, $nottxt, $noturi, $notdname, $notnxdomain, $notany, $notaxfr, $notixfr, $notopt, + $notspf) = explode(',', $rrsets); + +$rrd_def = RrdDefinition::make() + ->addDataset('any', 'GAUGE', 0) + ->addDataset('a', 'GAUGE', 0) + ->addDataset('aaaa', 'GAUGE', 0) + ->addDataset('cname', 'GAUGE', 0) + ->addDataset('mx', 'GAUGE', 0) + ->addDataset('ns', 'GAUGE', 0) + ->addDataset('ptr', 'GAUGE', 0) + ->addDataset('soa', 'GAUGE', 0) + ->addDataset('srv', 'GAUGE', 0) + ->addDataset('spf', 'GAUGE', 0) + ->addDataset('afsdb', 'GAUGE', 0) + ->addDataset('apl', 'GAUGE', 0) + ->addDataset('caa', 'GAUGE', 0) + ->addDataset('cdnskey', 'GAUGE', 0) + ->addDataset('cds', 'GAUGE', 0) + ->addDataset('cert', 'GAUGE', 0) + ->addDataset('dhcid', 'GAUGE', 0) + ->addDataset('dlv', 'GAUGE', 0) + ->addDataset('dnskey', 'GAUGE', 0) + ->addDataset('ds', 'GAUGE', 0) + ->addDataset('ipseckey', 'GAUGE', 0) + ->addDataset('key', 'GAUGE', 0) + ->addDataset('kx', 'GAUGE', 0) + ->addDataset('loc', 'GAUGE', 0) + ->addDataset('naptr', 'GAUGE', 0) + ->addDataset('nsec', 'GAUGE', 0) + ->addDataset('nsec3', 'GAUGE', 0) + ->addDataset('nsec3param', 'GAUGE', 0) + ->addDataset('rrsig', 'GAUGE', 0) + ->addDataset('rp', 'GAUGE', 0) + ->addDataset('sig', 'GAUGE', 0) + ->addDataset('sshfp', 'GAUGE', 0) + ->addDataset('ta', 'GAUGE', 0) + ->addDataset('tkey', 'GAUGE', 0) + ->addDataset('tlsa', 'GAUGE', 0) + ->addDataset('tsig', 'GAUGE', 0) + ->addDataset('txt', 'GAUGE', 0) + ->addDataset('uri', 'GAUGE', 0) + ->addDataset('dname', 'GAUGE', 0) + ->addDataset('nxdomain', 'GAUGE', 0) + ->addDataset('axfr', 'GAUGE', 0) + ->addDataset('ixfr', 'GAUGE', 0) + ->addDataset('opt', 'GAUGE', 0); + +//first handle the positive +$rrd_name = array('app', $name, $app_id, 'rrpositive'); + +$fields = array( + 'any' => $any, + 'a' => $a, + 'aaaa' => $aaaa, + 'cname' => $cname, + 'mx' => $mx, + 'ns' => $ns, + 'ptr' => $ptr, + 'soa' => $soa, + 'srv' => $srv, + 'spf' => $spf, + 'afsdb' => $afsdb, + 'apl' => $apl, + 'caa' => $caa, + 'cdnskey' => $cdnskey, + 'cds' => $cds, + 'cert' => $cert, + 'dhcid' => $dhcid, + 'dlv' => $dlv, + 'dnskey' => $dnskey, + 'ds' => $ds, + 'ipseckey' => $ipseckey, + 'key' => $key, + 'kx' => $kx, + 'loc' => $loc, + 'naptr' => $naptr, + 'nsec' => $nsec, + 'nsec3' => $nsec3, + 'nsec3param' => $nsec3param, + 'rrsig' => $rrsig, + 'rp' => $rp, + 'sig' => $sig, + 'sshfp' => $sshfp, + 'ta' => $ta, + 'tkey' => $tkey, + 'tlsa' => $tlsa, + 'tsig' => $tsig, + 'txt' => $txt, + 'uri' => $uri, + 'dname' => $dname, + 'nxdomain' => $nxdomain, + 'axfr' => $axfr, + 'ixfr' => $ixfr, + 'opt' => $opt, +); + +$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +data_update($device, 'app', $tags, $fields); + +// now handle the negative +$rrd_name = array('app', $name, $app_id, 'rrnegative'); + +$fields = array( + 'any' => $notany, + 'a' => $nota, + 'aaaa' => $notaaaa, + 'cname' => $notcname, + 'mx' => $notmx, + 'ns' => $notns, + 'ptr' => $notptr, + 'soa' => $notsoa, + 'srv' => $notsrv, + 'spf' => $notspf, + 'afsdb' => $notafsdb, + 'apl' => $notapl, + 'caa' => $notcaa, + 'cdnskey' => $notcdnskey, + 'cds' => $notcds, + 'cert' => $notcert, + 'dhcid' => $notdhcid, + 'dlv' => $notdlv, + 'dnskey' => $notdnskey, + 'ds' => $notds, + 'ipseckey' => $notipseckey, + 'key' => $notkey, + 'kx' => $notkx, + 'loc' => $notloc, + 'naptr' => $notnaptr, + 'nsec' => $notnsec, + 'nsec3' => $notnsec3, + 'nsec3param' => $notnsec3param, + 'rrsig' => $notrrsig, + 'rp' => $notrp, + 'sig' => $notsig, + 'sshfp' => $notsshfp, + 'ta' => $notta, + 'tkey' => $nottkey, + 'tlsa' => $nottlsa, + 'tsig' => $nottsig, + 'txt' => $nottxt, + 'uri' => $noturi, + 'dname' => $notdname, + 'nxdomin'=> $notnxdomain, + 'axfr' => $notaxfr, + 'ixfr' => $notixfr, + 'opt' => $notopt, +); + +$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +data_update($device, 'app', $tags, $fields);