summaryrefslogtreecommitdiff
path: root/contrib/stat
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/stat')
-rw-r--r--contrib/stat/README59
-rwxr-xr-xcontrib/stat/dns.named18
-rwxr-xr-xcontrib/stat/dns_mrtg5
-rwxr-xr-xcontrib/stat/mrtg.cfg23
-rwxr-xr-xcontrib/stat/stat.pl169
5 files changed, 274 insertions, 0 deletions
diff --git a/contrib/stat/README b/contrib/stat/README
new file mode 100644
index 0000000..f8658cd
--- /dev/null
+++ b/contrib/stat/README
@@ -0,0 +1,59 @@
+# $Id: README,v 1.1.1.1 2002/02/26 10:16:37 oetiker Exp $
+
+stat.pl
+
+ You could use this script to monitor youre DNS activities.
+ Its a very simple perl script and youre free to do any updates on
+ it, but please send a copy to me calle@volvo.se.
+ you have to do some small changes like hostname and path to named.stats.
+ if youre using it please let me know so i could send you updates.
+
+
+INSTALLATION:
+
+ To get it to work do execute the script once before you make mrtg to do
+ it for you. This will make an OLD file with the last requested queries.
+ You might get an error messages , but the next time you execute it the
+ stats will come as you want it.
+
+
+
+USAGE:
+
+ If you run this on a DNS server just add an script that will make a stat
+ file (Bind 4 (kill -ABRT `/var/run/named.pid`)),
+ (Bind 8.1. (kill -ILL `/var/run/named.pid)) and remove the old named.stats.
+ and put this into cron.
+ For Bind 8.2.1 you will need to be using ndc (ndc stats).
+
+ ex. script to run from cron
+
+ #!/bin/sh
+ rm /var/tmp/named.stats
+ kill -ABRT `cat /var/run/named.pid`
+ <PATH to MRTG>/mrtg <PATH to mrtg.cfg>
+
+
+MRTG:
+
+ To set up this in MRTG:
+ Target[dns]: `/<PATH to stat.pl>/stat.pl`
+
+REMOTE:
+ I did a small script called dns.named that will collect named from a
+ remote DNS, but i strongly recomend to rewrite this so instead of using
+ FTP use scp.
+ this script requires expect.
+
+
+UPDATES:
+
+ The new stat.pl you could use 2 diffrent graph in one session , that is lets say you want to
+ logg all Requested queries and maybe count of zone transfers.
+ all you have to do is to specify these in $OUTGOING and $INCOMING in stat.pl.
+ The script also looks how for how long the named have been runing without a reset.
+
+
+
+
+
diff --git a/contrib/stat/dns.named b/contrib/stat/dns.named
new file mode 100755
index 0000000..880032b
--- /dev/null
+++ b/contrib/stat/dns.named
@@ -0,0 +1,18 @@
+#!/usr/bin/expect
+# $Id: dns.named,v 1.1.1.1 2002/02/26 10:16:37 oetiker Exp $
+spawn ftp HOST.YOURE.DOMAIN
+expect "Name"
+send "USER\r"
+expect "^Password:"
+send "PASSWORD\r"
+expect "ftp>"
+send "cd /var/tmp\r"
+expect "ftp>"
+send "ascii\r"
+expect "ftp>"
+send "lcd DIRECTORY/WICH/STAT.pl/WILL/USE/TO/GET/NAMED.STATS\r"
+expect "ftp>"
+send "get named.stats\r"
+expect "ftp>"
+send "quit\r"
+sleep 4
diff --git a/contrib/stat/dns_mrtg b/contrib/stat/dns_mrtg
new file mode 100755
index 0000000..8095811
--- /dev/null
+++ b/contrib/stat/dns_mrtg
@@ -0,0 +1,5 @@
+#!/bin/sh
+# $Id: dns_mrtg,v 1.1.1.1 2002/02/26 10:16:37 oetiker Exp $
+#thnis file should be run by cron
+DIRECTORY/TO/THIS/SCRIPT/dns.named
+/PATH/TO/MRTG/mrtg PATH/TO/MRTG.CFG/mrtg.cfg
diff --git a/contrib/stat/mrtg.cfg b/contrib/stat/mrtg.cfg
new file mode 100755
index 0000000..580b106
--- /dev/null
+++ b/contrib/stat/mrtg.cfg
@@ -0,0 +1,23 @@
+# this is a mrtg test setup
+#im gonna try using some fine examples (hopefully) to make this work.
+# this is gonna be a DNS graph (when if ever im ready).
+# $Id: mrtg.cfg,v 1.1.1.1 2002/02/26 10:16:37 oetiker Exp $
+
+WorkDir: WWW/PATH/TO/SITE/
+## Intervall set to 5 min
+Interval: 10
+# now lets set up a Target to get stats from
+Target[bn]: `PATH/stat.pl`
+MaxBytes[bn]: 32000
+AbsMax[bn]: 64000
+Options[bn]: gauge
+Title[bn]: DNS statististics
+PageTop[bn]: <h2> DNS1 statistic </h2>\n
+XSize[bn]: 500
+Supress[bn]: y
+Ysize[bn]: 200
+YLegend[bn]: No. Questions asked/10 min
+ShortLegend[bn]: q/10 min
+LegendO[bn]: &nbsp; dnsqueries:
+LegendI[bn]:
+WithPeak[bn]: ym
diff --git a/contrib/stat/stat.pl b/contrib/stat/stat.pl
new file mode 100755
index 0000000..454e44a
--- /dev/null
+++ b/contrib/stat/stat.pl
@@ -0,0 +1,169 @@
+#!/usr/bin/perl -w
+# $Id: stat.pl,v 1.1.1.1 2002/02/26 10:16:37 oetiker Exp $
+####################
+# New updates for stat.pl
+####################
+%D_STAT=(
+ RQ => 0,
+ RR => 1,
+ RIQ => 2,
+ RNXD => 3,
+ RFwdQ => 4,
+ RFwdR => 5,
+ RDupQ => 6,
+ RDupR => 7,
+ RFail => 8,
+ RFErr => 9,
+ RErr => 10,
+ RTCP => 11,
+ RAXFR => 12,
+ RLame => 13,
+ ROpts => 14,
+ SSysQ => 15,
+ SAns => 16,
+ SFwdQ => 17,
+ SDupQ => 18,
+ SFail => 19,
+ SFErr => 20,
+ SErr => 21,
+ RNotNsq => 22,
+ SNaAns => 23,
+ SNXD => 24,
+);
+# This file is to feed mrtg with right information.
+# You could do this more fancy with up-time and stuff like that,
+# but that will be maybe in a couple of versions upward.
+# This works and i dont want to be like other big companys that gives out
+# Programs that want work but is all that fancy.
+#
+# Any way please do change this files so the right PATH to youre scripts
+# are there.
+# Requirements:
+# this scripts require MRTG (of course), i wont get in how to configure this,
+# because im not sure how to do it correctly, i manged to get it to work.
+# but i sugest you take a real good look how to configure MRTG.
+# more requirement is , perl version 5.004_05. Look at the documentation
+# on MRTG this one needs you to have some patches for some OS.
+#
+# If you want to use getting iformation from a remote DNS, sure you could use
+# my script dns.named but beware that this is NOT safe maybe you should use
+# If you want to use getting iformation from a remote DNS, sure you could use
+# scp to get youre file, but if not, be sure to set the rights so no non-auth
+# could see what password is.
+# dns.named requires expect version 5.26.0 (i havent tested on other versions)
+#
+# im not the greatest script maker but i managed this to work, but if
+# you have any comments or you have some great changes please be free to send them to calle@volvo.se
+
+# HOSTNAME youre domain this will show up in the web-page
+#
+# OK now to this new version of this program
+# $LOG is where you find youre named.stats *
+# in Bind 8.2.1 the way to get youre named.stats is "ndc stats"
+# in Bind 4.9.3 kill -ABRT `cat /var/run/named.pid`
+# in Bind kill -ILL `cat /var/run/named.pid`
+#
+# $RUN you have to set that to where youre script is set to run ex my $RUN = "/home/myhomeaccount/";
+#
+# now to the real new thing that is you can have 2 graphs in one MRTG session
+# you have to set the $INCOMING and $OUTGOING, $INCOMING = $D_STAT{"RQ"}; <-- this one needs to be set to look
+# for wich Data you want to see on the first Graph (RQ is Requested Queries)
+#
+# now to the other $OUTGOING = $D_STAT{"RFail"}; i set default but can be changed for what you want
+# RFail Requested Failure i done a short list of What some of them means , but if you want to have a complete list
+# you could look into the DNS and Bind book from O'reilly page 166
+#
+# Short list of some of the things you could pull out
+#
+# RQ: Requested Queries.
+# RR: Count of responses recieved from relay.
+# RIQ: Count of reverse queries recieved from relay.
+# RNXD: Count of "no such domain" answeres.
+# RFwdQ: Count of queries received from relay that nedded more processing
+# RFwdR: Count of is the reponses recived from relay that answered the
+# original query and were passed back to application.
+# RDupR: Is the count of duplicat response from relay.
+# RFail: Is the count of SERVFAIL response from relay.
+# RFErr: is the count of FORMERR response from relay.
+# RErr: is the count of errors that werent either SERVFAIL or FORMERR
+# RLame: Count of lame DELEGATIONS.
+# and so on read the book.
+
+my $HOSTNAME = "HOST\.YOURE\.DOMAIN";
+my $LOG = "/home/";
+my $RUN = "/home/";
+
+my $INCOMING = $D_STAT{"RQ"};
+my $OUTGOING = $D_STAT{"RFail"};
+
+
+
+#######################################
+#### Please Dont toch this part
+######################################
+my $QUE_P_MIN =();
+my $QUE_P_OTHER = ();
+my @N_STATS=();
+my @OLD_S=();
+my $UPTIME = ();
+
+
+sub HIST {
+
+ open (STAT , "$LOG") or die "could not find or open file $LOG";
+ @N_STAT = <STAT>;
+ close (STAT);
+
+
+ open (V_OLD , "$RUN/OLD");
+ my @OLD_S = <V_OLD>;
+ close (V_OLD);
+
+
+
+ my $G_FLAG = "no";
+
+
+
+ foreach $line (@N_STAT) {
+
+ if ( $line =~ m/^([0-9]+)\s+\S+\s+\S+\sreset/ ){
+ $UPTIME = $1;
+ }
+
+ if ( $G_FLAG =~ /yes/) {
+
+ my @NUM_QUE=split ' ',$line;
+ open ( LOGGER , "> $RUN/OLD");
+
+ print LOGGER "$NUM_QUE[$INCOMING]\n";
+ print LOGGER "$NUM_QUE[$OUTGOING]\n";
+
+ close ( LOGGER );
+ $QUE_P_MIN = $NUM_QUE[$INCOMING]-$OLD_S[0];
+ $QUE_P_OTHER = $NUM_QUE[$OUTGOING]-$OLD_S[1];
+ $G_FLAG = "no";
+ }
+
+
+
+
+ if ($line =~ /(Global)/) {
+ $G_FLAG = "yes";
+ }
+ }
+
+ print "$QUE_P_MIN\n$QUE_P_OTHER\n$UPTIME\n$HOSTNAME\n";
+}
+
+&HIST();
+
+
+
+
+
+
+
+
+
+