Cc: nathans@xxxxxxxxxx
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@xxxxxxxxxxxxxx>
---
src/pmdas/GNUmakefile | 2 +-
src/pmdas/pdns/GNUmakefile | 53 +++++++++++++
src/pmdas/pdns/Install | 31 +++++++
src/pmdas/pdns/Remove | 29 +++++++
src/pmdas/pdns/pmdapdns.pl | 186 ++++++++++++++++++++++++++++++++++++++++++++
src/pmns/stdpmid.pcp | 1 +
6 files changed, 301 insertions(+), 1 deletions(-)
create mode 100644 src/pmdas/pdns/GNUmakefile
create mode 100755 src/pmdas/pdns/Install
create mode 100755 src/pmdas/pdns/Remove
create mode 100644 src/pmdas/pdns/pmdapdns.pl
diff --git a/src/pmdas/GNUmakefile b/src/pmdas/GNUmakefile
index f1b9fef..8230be9 100644
--- a/src/pmdas/GNUmakefile
+++ b/src/pmdas/GNUmakefile
@@ -22,7 +22,7 @@ SUBDIRS = pmcd linux solaris aix darwin windows \
lmsensors process roomtemp summary hotproc jstat \
dbping memcache systemtap mysql vmware kvm ib \
bonding cluster lustrecomm mmv netfilter zimbra \
- named
+ named pdns
LDIRT = pmcd.conf
diff --git a/src/pmdas/pdns/GNUmakefile b/src/pmdas/pdns/GNUmakefile
new file mode 100644
index 0000000..eb85470
--- /dev/null
+++ b/src/pmdas/pdns/GNUmakefile
@@ -0,0 +1,53 @@
+#!gmake
+#
+# Copyright (c) 2009 Josef 'Jeff' Sipek <jeffpc@xxxxxxxxxxxxxx>
+#
+# 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 2 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, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+TOPDIR = ../../..
+include $(TOPDIR)/src/include/builddefs
+
+IAM = pdns
+PMDADIR = $(PCP_PMDAS_DIR)/$(IAM)
+LSRCFILES = Install Remove pmda$(IAM).pl
+LDIRT = domain.h root pmns *.log $(MAN_PAGES)
+
+ifneq ($(POD2MAN),)
+MAN_SECTION = 1
+MAN_PAGES = pmda$(IAM).$(MAN_SECTION)
+MAN_DEST = $(PCP_MAN_DIR)/man$(MAN_SECTION)
+endif
+
+default: $(MAN_PAGES)
+
+pmda$(IAM).1: pmda$(IAM).pl
+ $(POD_MAKERULE)
+
+include $(BUILDRULES)
+
+ifeq "$(TARGET_OS)" "linux"
+install: default
+ $(INSTALL) -m 755 -d $(PMDADIR)
+ $(INSTALL) -m 755 Install Remove $(PMDADIR)
+ $(INSTALL) -m 644 pmda$(IAM).pl $(PMDADIR)/pmda$(IAM).pl
+ @$(INSTALL_MAN)
+else
+install:
+endif
+
+default_pcp : default
+
+install_pcp : install
diff --git a/src/pmdas/pdns/Install b/src/pmdas/pdns/Install
new file mode 100755
index 0000000..e569c19
--- /dev/null
+++ b/src/pmdas/pdns/Install
@@ -0,0 +1,31 @@
+#! /bin/sh
+#
+# Copyright (c) 2009 Josef 'Jeff' Sipek <jeffpc@xxxxxxxxxxxxxx>
+#
+# 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 2 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, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Install the pdns PMDA
+#
+
+. $PCP_DIR/etc/pcp.env
+. $PCP_SHARE_DIR/lib/pmdaproc.sh
+
+iam=pdns
+perl_opt=true
+daemon_opt=false
+
+pmdaSetup
+pmdaInstall
+exit 0
diff --git a/src/pmdas/pdns/Remove b/src/pmdas/pdns/Remove
new file mode 100755
index 0000000..ea99655
--- /dev/null
+++ b/src/pmdas/pdns/Remove
@@ -0,0 +1,29 @@
+#! /bin/sh
+#
+# Copyright (c) 2009 Josef 'Jeff' Sipek <jeffpc@xxxxxxxxxxxxxx>
+#
+# 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 2 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, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Remove the pdns PMDA
+#
+
+. $PCP_DIR/etc/pcp.env
+. $PCP_SHARE_DIR/lib/pmdaproc.sh
+
+iam=pdns
+
+pmdaSetup
+pmdaRemove
+exit 0
diff --git a/src/pmdas/pdns/pmdapdns.pl b/src/pmdas/pdns/pmdapdns.pl
new file mode 100644
index 0000000..7b69d3b
--- /dev/null
+++ b/src/pmdas/pdns/pmdapdns.pl
@@ -0,0 +1,186 @@
+#
+# Copyright (c) 2009 Josef 'Jeff' Sipek <jeffpc@xxxxxxxxxxxxxx>
+#
+# 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 2 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.
+#
+
+use strict;
+use warnings;
+use PCP::PMDA;
+use Time::HiRes qw ( time );
+
+use vars qw( $pmda );
+my $pdns_control = '/usr/bin/pdns_control';
+
+my $cached = 0;
+my %vals = ();
+
+sub pdns_fetch_callback
+{
+ my ($cluster, $item, $inst) = @_;
+ my $metric_name = pmda_pmid_name($cluster, $item);
+ my ($path, $value, $fh);
+
+ my $now = time;
+
+ # $pmda->log("pdns_fetch_callback $metric_name $cluster:$item ($inst)\n");
+
+ if ($inst != PM_IN_NULL) { return (PM_ERR_INST, 0); }
+ if (!defined($metric_name)) { return (PM_ERR_PMID, 0); }
+
+ $metric_name =~ s/^pdns\.//;
+
+ if ($now - $cached > 1.0) {
+ # $pmda->log("pdns_fetch_callback update now:$now cached:$cached\n");
+
+ open(PIPE, "$pdns_control list |") || return (PM_ERR_APPVERSION, 0);
+ $_ = <PIPE>;
+ close PIPE;
+
+ $_ =~ s/-/_/g;
+ $_ =~ s/,$//;
+ for my $kv (split(/,/, $_)) {
+ if ("$kv" eq "") {
+ last;
+ }
+
+ my ($k, $v) = split(/=/, $kv);
+ $vals{$k} = $v;
+ }
+
+ $cached = $now;
+ }
+
+ if (!defined($vals{$metric_name})) { return (PM_ERR_APPVERSION, 0); }
+ return ($vals{$metric_name}, 1);
+}
+
+$pmda = PCP::PMDA->new('pdns', 101);
+
+$pmda->add_metric(pmda_pmid(0,0), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.corrupt_packets", '', '');
+$pmda->add_metric(pmda_pmid(0,1), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.deferred_cache_inserts", '', '');
+$pmda->add_metric(pmda_pmid(0,2), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.deferred_cache_lookup", '', '');
+$pmda->add_metric(pmda_pmid(0,3), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmda_units(0,1,0,0,PM_TIME_USEC,0),
+ "pdns.latency", '', '');
+$pmda->add_metric(pmda_pmid(0,4), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.packetcache_hit", '', '');
+$pmda->add_metric(pmda_pmid(0,5), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.packetcache_miss", '', '');
+$pmda->add_metric(pmda_pmid(0,6), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.packetcache_size", '', '');
+$pmda->add_metric(pmda_pmid(0,7), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.qsize_q", '', '');
+$pmda->add_metric(pmda_pmid(0,8), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.query_cache_hit", '', '');
+$pmda->add_metric(pmda_pmid(0,9), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.query_cache_miss", '', '');
+$pmda->add_metric(pmda_pmid(0,10), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.recursing_answers", '', '');
+$pmda->add_metric(pmda_pmid(0,11), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.recursing_questions", '', '');
+$pmda->add_metric(pmda_pmid(0,12), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.servfail_packets", '', '');
+$pmda->add_metric(pmda_pmid(0,13), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.tcp_answers", '', '');
+$pmda->add_metric(pmda_pmid(0,14), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.tcp_queries", '', '');
+$pmda->add_metric(pmda_pmid(0,15), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.timedout_packets", '', '');
+$pmda->add_metric(pmda_pmid(0,16), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.udp_answers", '', '');
+$pmda->add_metric(pmda_pmid(0,17), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.udp_queries", '', '');
+$pmda->add_metric(pmda_pmid(0,18), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.udp4_answers", '', '');
+$pmda->add_metric(pmda_pmid(0,19), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.udp4_queries", '', '');
+$pmda->add_metric(pmda_pmid(0,20), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.udp6_answers", '', '');
+$pmda->add_metric(pmda_pmid(0,21), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+ pmda_units(0,0,1,0,0,PM_COUNT_ONE),
+ "pdns.udp6_queries", '', '');
+
+$pmda->set_fetch_callback(\&pdns_fetch_callback);
+$pmda->run;
+
+=pod
+
+=head1 NAME
+
+pmdapdns - PowerDNS performance metrics domain agent (PMDA)
+
+=head1 DESCRIPTION
+
+B<pmdapdns> is a Performance Metrics Domain Agent (PMDA) which exports
+metric values from the PowerDNS daemon.
+
+=head1 INSTALLATION
+
+If you want access to the names and values for the PowerDNS performance
+metrics, do the following as root:
+
+ # cd $PCP_PMDAS_DIR/pdns
+ # ./Install
+
+If you want to undo the installation, do the following as root:
+
+ # cd $PCP_PMDAS_DIR/pdns
+ # ./Remove
+
+B<pmdapdns> is launched by pmcd(1) and should never be executed
+directly. The Install and Remove scripts notify pmcd(1) when
+the agent is installed or removed.
+
+=head1 FILES
+
+=over
+
+=item $PCP_PMDAS_DIR/pdns/Install
+
+installation script for the B<pmdapdns> agent
+
+=item $PCP_PMDAS_DIR/pdns/Remove
+
+undo installation script for the B<pmdapdns> agent
+
+=item $PCP_LOG_DIR/pmcd/pdns.log
+
+default log file for error messages from B<pmdapdns>
+
+=back
+
+=head1 SEE ALSO
+
+pmcd(1) and pdns_control(8).
diff --git a/src/pmns/stdpmid.pcp b/src/pmns/stdpmid.pcp
index c50b86a..6f9a493 100644
--- a/src/pmns/stdpmid.pcp
+++ b/src/pmns/stdpmid.pcp
@@ -77,6 +77,7 @@ NETFILTER 97
ZIMBRA 98
UV 99
NAMED 100
+PDNS 101
### NEXT FREE SLOT ###
DBPING 244
COUNTD 245
--
1.6.2.4
|