Forum Discussion
kykong_107132
Nimbostratus
Dec 11, 2005script to monitor DNs
Hi All,
I would like to create a script to monitor DNS Server. The script will simulate a DNS query. I have a sample which work fine in V4.5 but not in V9. I believe it miss out some perl module bcos when i try to run that script i get an error message look like this,
=======================================================
Can't locate Net/DNS.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux- thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thre ad-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/ vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/ lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl 5/5.8.0 .) at ./dns_mon line 5.
BEGIN failed--compilation aborted at ./dns_mon line 5.
==============================================================
below is my sample script, pls give some advise if you think out something to make this work in V9.
===============================================================
!/usr/local/bin/perl
use strict;
use Net::DNS;
require 5.005;
my ($node, $port, @domain) = @ARGV;
Derive and untaint programname.
my $programname = '/' . $0;
$programname =~ m/^.*\/([^\/]+)$/;
$programname = $1;
$node =~ m/^(\d+\.\d+\.\d+\.\d+)$/;
$node = $1;
$port =~ m/^(\d+)$/;
$port = $1;
Process ID and file where it's to be stored. The format
is significant.
my $pidfile = "/var/run/$programname.$node..$port.pid";
my $pid = "$$";
Maintenence. Clean up any existing EAV.
if (-f $pidfile ) {
open(PID, "<$pidfile");
my $pid = ;
close(PID);
if ( $pid ) {
chomp $pid; $pid =~ m/^(\d+)$/; $pid = $1;
if ( $pid ) {
kill 9, $pid;
}
}
unlink($pidfile);
}
Create a new maintenence file.
open(PID, ">$pidfile");
print PID $pid, "\n";
close(PID);
Connect to the DNS server.
Perform A record lookup
my $res = Net::DNS::Resolver->new;
$res->nameservers($node);
my $ipquery = $res->search("@domain");
if (!($ipquery))
{
print STDERR "Failed to connect, ", $res->errorstring, "\n";
unlink($pidfile);
exit 1;
}
print "up\n";
Clean up.
unlink($pidfile);
exit 0;
- This is really a question for F5 Product Support. DevCentral is here to assist with iControl (device management) application development and writing iRules (real-time traffic inspection).
- kykong_107132
Nimbostratus
Hi Joe,
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects