monitors:retds

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
monitors:retds [2015/03/17 10:24] – [retds.pl] wnelismonitors:retds [2015/03/18 20:30] (current) – [Credits] jez
Line 9: Line 9:
 ===== Description ===== ===== Description =====
  
-Script retds.pl retrieves the DNS statistics of both BIND named servers and windows DNS servers. A table within this script specifies which statistics are to be extracted and defines the RRD file name and the DS name of these statistics at the same time. The DNS servers to be monitored by this script are defined in the Xymon hosts.cfg file, using keyword RNAMED.+ 
 +Script retds.pl retrieves the DNS statistics of both BIND named servers (both the old, pre-9.6 style and the new style) and windows DNS servers. A table within this script specifies which statistics are to be extracted and defines the RRD file name and the DS name of these statistics at the same time. The DNS servers to be monitored by this script are defined in the Xymon hosts.cfg file, using keyword RNAMED.
  
 Script retds.pl is a rewrite (in Perl) of script xymon-rnamedstats.sh written by Jerimy Laidman. It is extended to handle Windows DNS servers as well. Script retds.pl is a rewrite (in Perl) of script xymon-rnamedstats.sh written by Jerimy Laidman. It is extended to handle Windows DNS servers as well.
Line 17: Line 18:
  
 Although script retds.pl is a server-side script, there is some work to do at the client-side as well. Although script retds.pl is a server-side script, there is some work to do at the client-side as well.
 +
  
 === Client side on a BIND server === === Client side on a BIND server ===
Line 24: Line 26:
 For example, the statistics could be collected using the following crontab entry of user root: For example, the statistics could be collected using the following crontab entry of user root:
     0-55/5 * * * * /usr/bin/rdnc stats ; mv /var/named/data/named_stats.txt ~AUser/named.stats     0-55/5 * * * * /usr/bin/rdnc stats ; mv /var/named/data/named_stats.txt ~AUser/named.stats
-The associated RNAMED keyword in the Xymon hosts.cfg is: +
-    RNAMED:”cmd(ssh -T AUser@%{H} 2>/dev/null),statsfile(named.stats)”+
  
 === Client side on a Windows DNS server === === Client side on a Windows DNS server ===
Line 39: Line 40:
     copy c:\temp\dnsstat.txt c:\inetpub\wwwroot\dnsstat.txt     copy c:\temp\dnsstat.txt c:\inetpub\wwwroot\dnsstat.txt
  
-This information is retrieved by Xymon using the following RNAMED keyword: 
-    RNAMED:”cmd(wget http://%{H}/dnsstat.txt -o /dev/null -O -),source(dnscmd)” 
  
 === Server side === === Server side ===
 +
 +Script detds.pl will typically be placed in directory $XYMONHOME/ext. It will be run periodically by adding the following snippet to $XYMONHOME/etc/tasks.cfg:
 +
 +    [retds]
 +        ENVFILE $XYMONHOME/etc/xymonserver.cfg
 +        CMD $XYMONHOME/ext/retds.pl
 +        LOGFILE $XYMONSERVERLOGS/retds.log
 +        INTERVAL 5m
 +
 +In file $XYMONHOME/etc/hosts.cfg one needs to identify the hosts for which this script should extract the DNS usage statistics. For a BIND server, two tags need to be added or modified, RNAMED and TRENDS. Matching the example above, the following values could be used:
 +
 +    RNAMED:”cmd(ssh -T AUser@%{H} 2>/dev/null),statsfile(named.stats)”
 +    TRENDS:*,bindstats
 +
 +The same tags need to be specified for a Windows DNS server. Again, matching the example above the following values could be used:
 +
 +    RNAMED:”cmd(wget http://%{H}/dnsstat.txt -o /dev/null -O -),source(dnscmd)”
 +    TRENDS:*,wdnsstats
 +
 +In file $XYMONHOME/etc/xymonserver.cfg the text ",bindstats" needs to be added to the definition of the variables TEST2RRD and GRAPHS if there is at least one BIND server being monitored. The text ",wdnsstats" needs to be added to the same variables in case at least one Windows DNS server is monitored.
  
 ===== Source ===== ===== Source =====
Line 76: Line 95:
 #  title(<testtitle>   : a one-line title of the (non-trends) test #  title(<testtitle>   : a one-line title of the (non-trends) test
 # #
-# In the commandline, a few substitutable variables may be specified. They are+# In the command line, a few substitutable variables may be specified. They are
 # replaced by their current value upon querying the host: # replaced by their current value upon querying the host:
 #  %{H} : Host name as defined in the xymon hosts.cfg file #  %{H} : Host name as defined in the xymon hosts.cfg file
Line 243: Line 262:
  
  # Handle keyword RNAMED: extract all its parameters. Two formats are allowed,  # Handle keyword RNAMED: extract all its parameters. Two formats are allowed,
- # one in which the whole parameterstring is enclosed between double quotes and+ # one in which the whole parameter string is enclosed between double quotes and
  # one in which the part after RNAMED: is enclosed between double quotes.  # one in which the part after RNAMED: is enclosed between double quotes.
     ($RNamed,$Pars)= $AllPars=~ m/\"(RNAMED:(.+?))\"/ ;     ($RNamed,$Pars)= $AllPars=~ m/\"(RNAMED:(.+?))\"/ ;
Line 264: Line 283:
  
 # #
-# Function PolishName returns the inputstring, after replacing all+# Function PolishName returns the input string, after replacing all
 # non-alphanumeric characters by an underscore. # non-alphanumeric characters by an underscore.
 # #
Line 276: Line 295:
  
 # #
-# Function Recent takes a timestamp and returns that value if the timestamp+# Function Recent takes a time stamp and returns that value if the time stamp
 # lies between now and 10 minutes ago. If the clock of the DNS server is up to # lies between now and 10 minutes ago. If the clock of the DNS server is up to
 # 10 seconds ahead wrt the time on the Xymon server, the current time at the # 10 seconds ahead wrt the time on the Xymon server, the current time at the
Line 298: Line 317:
 # #
 # Function QueryServer retrieves the dns statistics from one server. All # Function QueryServer retrieves the dns statistics from one server. All
-# information needed is passed in the worklist entry. The retrieved information+# information needed is passed in the work list entry. The retrieved information
 # is written to global list @Lines. # is written to global list @Lines.
 # #
Line 328: Line 347:
 # #
 # Function ParseBindStatistics takes the raw statistics of a BIND server and # Function ParseBindStatistics takes the raw statistics of a BIND server and
-# stores it in a multi-level datastructure.+# stores it in a multi-level data-structure.
 # #
 sub ParseBindStatistics($) { sub ParseBindStatistics($) {
Line 380: Line 399:
 # DNS service statistics to identify and extract all values. # DNS service statistics to identify and extract all values.
 # #
-# The statistics are divided into sections, each section is devided in one or+# The statistics are divided into sections, each section is divided in one or
 # more views. A view consists of one or more lines containing the name of a # more views. A view consists of one or more lines containing the name of a
 # variable and its value. A section starts with the section name in the leftmost # variable and its value. A section starts with the section name in the leftmost
Line 395: Line 414:
 # Sub-level lines are ignored. # Sub-level lines are ignored.
 # #
-# The statistics are augmented with a timestamp at the start. The first line+# The statistics are augmented with a time stamp at the start. The first line
 # specifies the date, using format dd-mm-yyyy, the second line the time of # specifies the date, using format dd-mm-yyyy, the second line the time of
 # collecting the statistics, using format hh:mm. # collecting the statistics, using format hh:mm.
Line 493: Line 512:
  
 # #
-# Function ParseStatistics invokes the appropiate parser, depending on the+# Function ParseStatistics invokes the appropriate parser, depending on the
 # source of the statistical information. # source of the statistical information.
 # #
 sub ParseStatistics($) { sub ParseStatistics($) {
-  my $W= shift ; # Ref to worklist item+  my $W= shift ; # Ref to work list item
  
   if      ( $$W{source} eq 'bind'   ) {   if      ( $$W{source} eq 'bind'   ) {
Line 626: Line 645:
  
 ==== rrd-status.pl ==== ==== rrd-status.pl ====
 +
 +If the statistics are sent to Xymon using a status message, a script like the one below is needed to parse the NCV data and pass them to an RRD.
  
 <hidden onHidden="Show Code ⇲" onVisible="Hide Code ⇱"> <hidden onHidden="Show Code ⇲" onVisible="Hide Code ⇱">
 <code> <code>
 +#!/usr/bin/perl
 +#
 +# This script handles a list of NCVs, send by a Xymon client, and prepares it to
 +# be stored in an RRA. This script is used in cases in which a fixed-size group
 +# of two or more values should be put together into a single RRA. The algorithm
 +# is specific for each test / client.
 +#
 +# This script is invoked with three parameters: the name of the host, the name
 +# of the test and the name of the file containing the message sent by the
 +# client, containing the NCVs to be handled.
 +#
 +use strict;
  
 +#
 +# Installation constants.
 +# -----------------------
 +#
 +# %Struct defines the datasets of the various tests.
 +#
 +my %Struct= (
 + bindstats => [ # Must be sorted!
 + "DS:RSqryrecursion:DERIVE:600:0:U\n" ,
 + "DS:RSqryreferral:DERIVE:600:0:U\n" ,
 + "DS:RSqrysuccess:DERIVE:600:0:U\n" ,
 + "DS:RSrcodefailure:DERIVE:600:0:U\n" ,
 + "DS:RSrcodenxdomain:DERIVE:600:0:U\n" ,
 + "DS:RSrcodenxrrset:DERIVE:600:0:U\n" ],
 +   ) ;  # of %Struct
 +
 +#
 +# Global variables.
 +# -----------------
 +#
 +my ( $HostName, $TestName, $FileName )= @ARGV ;
 +#
 +my %Var= () ; # Save area measurements
 +my ( $Line, @Line ) ; # List of values of one measurement
 +my $key ; # Loop control variable
 +
 +
 +#
 +# Main program.
 +# -------------
 +#
 +
 +#
 +# An attempt has been undertaken to make this code a little bit more general.
 +# The name of an NCV should consist of two names separated by "/". The first
 +# name becomes (part of) the name of the RRA, the second name becomes the
 +# name of the DS. The DS-ses are written in sorted order.
 +#
 +if ( $TestName eq 'bindstats' ) {
 +  open( FH, "<", $FileName ) or die ;
 +  while ( <FH> ) {
 +    chomp ;
 +    next unless m/^([\w\.\,-]+)\/(\w+)\s+:\s+(U|[\d\.]+)\s*$/ ;
 +    $Var{$1}{$2}= $3 ;
 +  }  # of while
 +  close( FH ) ;
 +
 +  print @{$Struct{$TestName}} ;
 +  foreach $key ( sort keys %Var ) {
 +    @Line= () ;
 +    push @Line, $Var{$key}{$_} foreach ( sort keys %{$Var{$key}} ) ;
 +    if ( $TestName eq $key ) {
 +      print "$TestName.rrd\n" ;
 +    } else {
 +      print "$TestName.$key.rrd\n" ;
 +    }  # of else
 +    print join( ":", @Line ) . "\n" ;
 +  }  # of foreach
 +
 +}  # of if
 +
 +exit 0 ;
 </code> </code>
 </hidden> </hidden>
  
 +==== graphs.cfg, bindstats ====
 +
 +The following snippet defines a graph showing the collected BIND statistics. Add this snippet to $XYMONHOME/etc/graphs.cfg if at least one BIND server is being monitored.
 +
 +<hidden onHidden="Show Code ⇲" onVisible="Hide Code ⇱">
 +<code>
 +[bindstats]
 + TITLE , Bind query rates  
 + YAXIS Rate [q/s]
 + -l 0
 + DEF:success=bindstats.rrd:RSqrysuccess:AVERAGE
 + DEF:referal=bindstats.rrd:RSqryreferral:AVERAGE
 + DEF:recursn=bindstats.rrd:RSqryrecursion:AVERAGE
 + DEF:failure=bindstats.rrd:RSrcodefailure:AVERAGE
 + DEF:nxrrset=bindstats.rrd:RSrcodenxrrset:AVERAGE
 + DEF:nxdomain=bindstats.rrd:RSrcodenxdomain:AVERAGE
 + CDEF:total=success,referal,+,failure,+,nxrrset,+,nxdomain,+
 + AREA:success#348017:success
 + GPRINT:success:MIN:     Min\: %5.1lf %sq/s
 + GPRINT:success:MAX:Max\: %5.1lf %sq/s
 + GPRINT:success:AVERAGE:Avg\: %5.1lf %sq/s
 + GPRINT:success:LAST:Cur\: %5.1lf %sq/s\n
 + AREA:referal#52D017:referral:STACK
 + GPRINT:referal:MIN:    Min\: %5.1lf %sq/s
 + GPRINT:referal:MAX:Max\: %5.1lf %sq/s
 + GPRINT:referal:AVERAGE:Avg\: %5.1lf %sq/s
 + GPRINT:referal:LAST:Cur\: %5.1lf %sq/s\n
 + AREA:failure#F88017:Err-failure:STACK
 + GPRINT:failure:MIN: Min\: %5.1lf %sq/s
 + GPRINT:failure:MAX:Max\: %5.1lf %sq/s
 + GPRINT:failure:AVERAGE:Avg\: %5.1lf %sq/s
 + GPRINT:failure:LAST:Cur\: %5.1lf %sq/s\n
 + AREA:nxrrset#C35817:Err-nxrrset:STACK
 + GPRINT:nxrrset:MIN: Min\: %5.1lf %sq/s
 + GPRINT:nxrrset:MAX:Max\: %5.1lf %sq/s
 + GPRINT:nxrrset:AVERAGE:Avg\: %5.1lf %sq/s
 + GPRINT:nxrrset:LAST:Cur\: %5.1lf %sq/s\n
 + AREA:nxdomain#FF0000:Err-nxdomain:STACK
 + GPRINT:nxdomain:MIN:Min\: %5.1lf %sq/s
 + GPRINT:nxdomain:MAX:Max\: %5.1lf %sq/s
 + GPRINT:nxdomain:AVERAGE:Avg\: %5.1lf %sq/s
 + GPRINT:nxdomain:LAST:Cur\: %5.1lf %sq/s\n
 + LINE1:total#000000:Total
 + GPRINT:total:MIN:       Min\: %5.1lf %sq/s
 + GPRINT:total:MAX:Max\: %5.1lf %sq/s
 + GPRINT:total:AVERAGE:Avg\: %5.1lf %sq/s
 + GPRINT:total:LAST:Cur\: %5.1lf %sq/s\n
 + LINE1:recursn#0000FF:recursion
 + GPRINT:recursn:MIN:   Min\: %5.1lf %sq/s
 + GPRINT:recursn:MAX:Max\: %5.1lf %sq/s
 + GPRINT:recursn:AVERAGE:Avg\: %5.1lf %sq/s
 + GPRINT:recursn:LAST:Cur\: %5.1lf %sq/s\n
 +</code>
 +</hidden>
 +
 +==== graphs.cfg, wdnsstats ====
 +
 +The following snippet defines a graph showing the collected Windows DNS statistics.
 +
 +<hidden onHidden="Show Code ⇲" onVisible="Hide Code ⇱">
 +<code>
 +[wdnsstats]
 +        TITLE , DNS statistics  
 +        YAXIS Rate [/s] 
 +        -l 0 
 +        DEF:qry=wdnsstats.rrd:Query:AVERAGE
 +        DEF:upd=wdnsstats.rrd:DynUpdRcv:AVERAGE
 +        DEF:er0=wdnsstats.rrd:RcrsFail:AVERAGE
 +        DEF:er1=wdnsstats.rrd:DynUpdRej:AVERAGE
 +        DEF:er2=wdnsstats.rrd:ServFail:AVERAGE
 +        DEF:er3=wdnsstats.rrd:NxDomain:AVERAGE
 +        CDEF:err=er0,er1,+,er2,+,er3,+
 +        LINE1:qry#66CC33:Query
 +        GPRINT:qry:MIN: Min\: %5.1lf %s
 +        GPRINT:qry:MAX:Max\: %5.1lf %s
 +        GPRINT:qry:AVERAGE:Avg\: %5.1lf %s
 +        GPRINT:qry:LAST:Cur\: %5.1lf %s\n
 +        LINE1:upd#9933FF:Update
 +        GPRINT:upd:MIN:Min\: %5.1lf %s
 +        GPRINT:upd:MAX:Max\: %5.1lf %s
 +        GPRINT:upd:AVERAGE:Avg\: %5.1lf %s
 +        GPRINT:upd:LAST:Cur\: %5.1lf %s\n
 +        LINE1:err#FF0000:Error
 +        GPRINT:err:MIN: Min\: %5.1lf %s
 +        GPRINT:err:MAX:Max\: %5.1lf %s
 +        GPRINT:err:AVERAGE:Avg\: %5.1lf %s
 +        GPRINT:err:LAST:Cur\: %5.1lf %s\n
 +</code>
 +</hidden>
 ===== Known  Bugs and Issues ===== ===== Known  Bugs and Issues =====
  
 By default, the statistics are presented to Xymon using a so-called 'trends' data-message. These type of messages do not carry a status nor a time stamp. Thus problems in collecting the statistics cannot be passed as a status. The independent polling cycles at client and server introduce variable delays, which cannot be accounted for, although the time of data collection is known at the server-side script. By default, the statistics are presented to Xymon using a so-called 'trends' data-message. These type of messages do not carry a status nor a time stamp. Thus problems in collecting the statistics cannot be passed as a status. The independent polling cycles at client and server introduce variable delays, which cannot be accounted for, although the time of data collection is known at the server-side script.
 +
 +It is assumed that the BIND statistics file contains only one set of statistics. Thus the new statistics overwrite the old statistics, rather than being appended. 
  
 This script is only tested using 'trends'-messages. The function to use a status message to inform Xymon has thus not been tested. This script is only tested using 'trends'-messages. The function to use a status message to inform Xymon has thus not been tested.
Line 642: Line 828:
 ===== Credits ===== ===== Credits =====
  
-Script retds.pl is written using script xymon-rnamedstats.sh written by Jerimy Laidman as the source for inspiration.+Script retds.pl is written using script xymon-rnamedstats.sh written by Jeremy Laidman as the source for inspiration.
 ===== Changelog ===== ===== Changelog =====
  
  • monitors/retds.1426587848.txt.gz
  • Last modified: 2015/03/17 10:24
  • by wnelis