Package: hobbit-plugins
Version: 20121226+db1
Severity: wishlist
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I found it easier to start from scratch using Hobbit.pm than to port
the old bb-dnsquery.pl to xymon, so here is the result.

Warning, Xymon newb.

Also, I didn't mess with changelog in this patch, since it seemed to
create more complications than it eliminated.



- -- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (900, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-3-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages hobbit-plugins depends on:
ii  dpkg          1.16.9
ii  xymon-client  4.3.7-1

Versions of packages hobbit-plugins recommends:
ii  dctrl-tools             2.22.2
ii  libsysadm-install-perl  0.39-1
ii  lsb-release             4.1+Debian8
ii  lsof                    4.86+dfsg-1
ii  sudo                    1.8.5p2-1

Versions of packages hobbit-plugins suggests:
ii  bzr                        2.6.0~bzr6526-1
ii  debsums                    2.0.52
pn  fping                      <none>
ii  git                        1:1.7.10.4-1+wheezy1
pn  ipmitool                   <none>
pn  libdbd-pg-perl             <none>
ii  libfile-slurp-perl         9999.19-1
ii  libnet-dns-perl            0.66-2+b2
pn  libnet-tftp-perl           <none>
pn  libpoe-component-irc-perl  <none>
ii  mercurial                  2.2.2-1
ii  ntp                        1:4.2.6.p5+dfsg-2
ii  subversion                 1.7.5-1

- -- Configuration Files:
/etc/sudoers.d/hobbit [Errno 13] Permission denied: u'/etc/sudoers.d/hobbit'
/etc/sudoers.d/xymon [Errno 13] Permission denied: u'/etc/sudoers.d/xymon'

- -- no debconf information

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iJwEAQECAAYFAlDfGpgACgkQTiiN/0Um85koMwP/Z+c+q9A8PesJG1W7AIHfG/NU
IX+ETaL7NgINxhJy6xu/jrr+JssvPY1sHFEvTLyKjY6jvGRR6R4b0BAY79gKX7Ah
62mcOR2aD6v4gPPHO/wAvAVxwTR74l90+90XXEsTNa2VxKgQbkmeFjkA880vwcXp
BGb3EU1co5Cw+zSrkWY=
=rWEf
-----END PGP SIGNATURE-----
>From a24833a6179ab835476a19b4694d2a0a7eed1249 Mon Sep 17 00:00:00 2001
From: David Bremner <brem...@debian.org>
Date: Sat, 29 Dec 2012 11:58:49 -0400
Subject: [PATCH] Add new client-side plugin, dnsq

There is an optional config file /etc/xymon/dnsq that is not installed
by the package, since there are defaults.
---
 client-ext/dnsq         |   70 +++++++++++++++++++++++++++++++++++++++++++++++
 clientlaunch.d/dnsq.cfg |    6 ++++
 debian/control          |    2 +-
 3 files changed, 77 insertions(+), 1 deletion(-)
 create mode 100644 client-ext/dnsq
 create mode 100644 clientlaunch.d/dnsq.cfg

diff --git a/client-ext/dnsq b/client-ext/dnsq
new file mode 100644
index 0000000..723366a
--- /dev/null
+++ b/client-ext/dnsq
@@ -0,0 +1,70 @@
+#!/usr/bin/perl -w
+
+# Copyright (C) 2012 David Bremner <brem...@debian.org>
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+# CONFIGURATION: 
+#
+# Optionally, create a file /etc/xymon/dnsq containing names to
+# lookup, one per line
+
+use strict;
+use English;
+use Hobbit;
+use Net::DNS;
+use File::Slurp;
+
+sub fail {
+    my $bb = shift;
+    $bb->color_line('red', $@);
+    exit;
+}
+
+my $config_file = "/etc/xymon/dnsq";
+
+$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin';
+delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
+
+my @queries;
+
+if (-f $config_file) {
+    @queries = read_file($config_file, chomp => 1);
+} else {
+    @queries=qw(www.debian.org kernel.org aws.amazon.com www.google.com);
+}
+
+my $bb = new Hobbit ('dnsq');
+
+my $res = new Net::DNS::Resolver;
+fail ($bb, "No resolver") unless ($res);
+
+foreach my $name (@queries) {
+    my $packet = $res->search($name);
+    if (defined($packet)) {
+	my $out = join(" ", $name, map { $_-> rdatastr; } $packet->answer() );
+	$bb->color_line('green', $out."\n");
+    } else {
+	$bb->color_line('red', "$name failed");
+    }
+}
+
+$bb->add_color ('green');
+$bb->send;
diff --git a/clientlaunch.d/dnsq.cfg b/clientlaunch.d/dnsq.cfg
new file mode 100644
index 0000000..df565a5
--- /dev/null
+++ b/clientlaunch.d/dnsq.cfg
@@ -0,0 +1,6 @@
+[dnsq]
+	#DISABLED
+	ENVFILE /etc/xymon/xymonclient.cfg
+	CMD  $XYMONCLIENTHOME/ext/dnsq
+	LOGFILE /var/log/xymon/xymonclient.log
+	INTERVAL 5m
diff --git a/debian/control b/debian/control
index 85f9bdc..23fdbcb 100644
--- a/debian/control
+++ b/debian/control
@@ -14,7 +14,7 @@ Architecture: all
 Pre-Depends: dpkg (>= 1.15.7.2)
 Depends: xymon-client (>= 4.3.7-1~), ${misc:Depends}
 Recommends: libsysadm-install-perl, lsof, sudo (>= 1.7.2p1-1), dctrl-tools, lsb-release
-Suggests: libdbd-pg-perl, libpoe-component-irc-perl, libnet-tftp-perl, ipmitool, fping, ntp, git, bzr, mercurial, subversion, debsums
+Suggests: libdbd-pg-perl, libpoe-component-irc-perl, libnet-tftp-perl, ipmitool, fping, ntp, git, bzr, mercurial, subversion, debsums, libnet-dns-perl, libfile-slurp-perl
 Enhances: backuppc, mailman, postfix, dphys-config
 Description: plugins for the Xymon network monitor
  This package provides plugins for the Xymon network monitor. (Formerly called
-- 
1.7.10.4

Reply via email to