monitors:diskstat.pl

Differences

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

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
monitors:diskstat.pl [2012/04/12 07:16] – external edit 127.0.0.1monitors:diskstat.pl [2019/02/12 16:43] – [To do] wnelis
Line 5: Line 5:
 ^ Requirements | Perl, Linux | ^ Requirements | Perl, Linux |
 ^ Download | None | ^ Download | None |
-^ Last Update | 2012-04-02 |+^ Last Update | 2019-02-12 |
  
 ===== Description ===== ===== Description =====
 Script diskstat.pl is a client-side script for servers running Linux, which extracts disk I/O performance parameters from pseudo-file /proc/diskstats and reports those parameters to Xymon. It results in four graphs per monitored disk, showing the I/O request rate, the I/O throughput, the time needed per request and I/O queue length. Script diskstat.pl is a client-side script for servers running Linux, which extracts disk I/O performance parameters from pseudo-file /proc/diskstats and reports those parameters to Xymon. It results in four graphs per monitored disk, showing the I/O request rate, the I/O throughput, the time needed per request and I/O queue length.
  
-As most of the parameters in /proc/diskstats are ever-increasing counters, the reported values are effectivly the average value since the previous invocation of this script. Typically, this script will be invoked once every 5 minutes, thus most results will be 5-minute averages. In other words, the results cover the complete time the script is running, and do not deliver a periodic, statistical sample.+As most of the parameters in /proc/diskstats are ever-increasing counters, the reported values are effectively the average value since the previous invocation of this script. Typically, this script will be invoked once every 5 minutes, thus most results will be 5-minute averages. In other words, the results of this script cover the complete time the script is running. The results are thus //not// a periodic, statistical sample, each sample covering only a fraction of the time since the previous sample.
  
-Script diskstat.pl is installed together with perl module diskstat.pm on the Xymon client. Script diskstat.pl sends all performance data of the selected disks and partitions to Xymon. The selection is defined in module diskstat.pm in hash %Disks. I did not find a way to map the name of the disk or partition onto it's mountpoint. Therefore the name of the mountpoint also needs to be specified. The data is sent to Xymon in NCV format. The name used has a special format, namely <Mountpoint>/<Variable>. In the name of the mountpoint, any forward slash is replaced by a comma. At the Xymon server, a script is invoked to handle the status message from script diskstat.pl and save the data in a RRD, one RRD per monitored disk. It uses <Mountpoint> to construct the name of the RRD, while <Variable> becomes the name of the dataset. At the generation of a graph, a custom script is invoked to extract <Mountpoint> from the name of the RRD and rebuild the original name.+Script diskstat.pl is installed together with perl module diskstat.pm on the Xymon client. Script diskstat.pl sends all performance data of the selected disks and partitions to Xymon. The selection is defined in module diskstat.pm in hash %Disks. This list is also used to map the disk or partition name onto another name, typically the mount point. The data is sent to Xymon in Devmon format, which requires less configuration compared with the NCV format. At the generation of a graph, a custom script is invoked to extract mountpoint from the name of the RRD and rebuild the original name.
  
 ===== Installation ===== ===== Installation =====
Line 20: Line 20:
 === Client side === === Client side ===
  
-Copy script diskstat.pl and module diskstat.pm to the server to be monitored, typically to subdirectory ~xymon/client/ext. Enter the name of the directory in the 'use lib' directive in script diskstat.pl, at line 17. Define in table %Disks in module diskstat.pm the disks and partitions to monitor, and the name of the mountpoint of each.+Copy script diskstat.pl and module diskstat.pm to the server to be monitored, typically to subdirectory ~xymon/client/ext or /usr/lib/xymn/client/ext. Make sure that script diskstat.pl can be executed by user xymon. Enter the name of the directory in the 'use lib' directive in script diskstat.pl, at line 17. Define in table %Disks in module diskstat.pm the disks and partitions to monitor, and the name of the mount-point of each.
  
-Edit the following section to reflect your environment and add it to the ~xymon/client/etc/tasks.cfg:+Edit the following section to reflect your environment and add it to ~xymon/client/etc/tasks.cfg or put it as a separate file named diskstat.cfg in subdirectory /usr/lib/xymon/client/etc/clientlaunch.d:
 <code> <code>
 [diskstat] [diskstat]
Line 33: Line 33:
 === Server side === === Server side ===
  
-At the Xymon server, the status message from script diskstat.pl is to be handled by script rrd_status.pl. This is accomplished by merging the following configuration into file ~xymon/server/etc/tasks.cfg:+At the Xymon server, it must be configured that this test uses the Devmon formatTherefore add the following two lines to ~xymon/server/etc/xymonserver.cfg or write them in a file named ~xymon/server/etc/xymonserver.d/diskstat.cfg:
  
 <code> <code>
-[rrdstatus] +TEST2RRD+=",diskstat=devmon" 
-  ENVFILE /path/to/xymon/server/etc/xymonserver.cfg +GRAPHS+=",diskstat::1,diskstat0::1,diskstat1::1,diskstat2::1"
-  NEEDS xymond +
-  CMD xymond_channel --channel=status --log=$XYMONSERVERLOGS/rrd-status.log xymond_rrd --extra-tests=diskstat --extra-script=/path/to/xymon/server/ext/rrd_status.pl --rrddir=$XYMONVAR/rrd+
 </code> </code>
- 
-Install the following script, named rrd_status.pl, in directory ~xymon/server/ext. However, it could be that there is already a script with a similar purpose for other tests: in that case you should merge it with the script below. 
- 
-<hidden onHidden="Show rrd_status.pl ⇲" onVisible="Hide rrd_status.pl ⇱"> 
-<code perl> 
-#!/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= ( 
-        diskstat => [           # Must be sorted! 
-                "DS:IoQueue:GAUGE:600:0:U\n"  , 
-                "DS:IoTime:DERIVE:600:0:U\n"  , 
-                "DS:IoWTime:DERIVE:600:0:U\n" , 
-                "DS:RdAmount:DERIVE:600:0:U\n", 
-                "DS:RdMerge:DERIVE:600:0:U\n"   , 
-                "DS:RdRequest:DERIVE:600:0:U\n"   , 
-                "DS:RdTime:DERIVE:600:0:U\n"  , 
-                "DS:WrAmount:DERIVE:600:0:U\n", 
-                "DS:WrMerge:DERIVE:600:0:U\n"   , 
-                "DS:WrRequest:DERIVE:600:0:U\n"   , 
-                "DS:WrTime: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. 
-# ------------- 
-# 
- 
-# 
-# Handle test "diskstat". 
-# 
-# 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 "diskstat" ) { 
-  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}} ) ; 
-    print "$TestName.$key.rrd\n" ; 
-    print join( ":", @Line ) . "\n" ; 
-  }  # of foreach 
-}  # of if 
- 
-exit 0 ; 
-</code> 
-</hidden> 
  
 The results are displayed in 4 graphs, named [diskstat], [diskstat0], [diskstat1] and [diskstat2]. These graphs are multi-graphs and use script genlgt.pl to generate the graph title. The results are displayed in 4 graphs, named [diskstat], [diskstat0], [diskstat1] and [diskstat2]. These graphs are multi-graphs and use script genlgt.pl to generate the graph title.
Line 240: Line 154:
 </code> </code>
  
-Define the diskstat graphs to be multi-graphs, which should show only one disk per graph, with the following modification in ~xymon/server/etc/cgioptions.cfg+Define the diskstat graphs to be multi-graphs with the following modification in ~xymon/server/etc/cgioptions.cfg:
 <code> <code>
 CGI_SVC_OPTS="... --multigraphs=diskstat,diskstat0,diskstat1,diskstat2" CGI_SVC_OPTS="... --multigraphs=diskstat,diskstat0,diskstat1,diskstat2"
-</code> 
-and the following modifications in ~xymon/server/etc/xymonserver.cfg: 
-<code> 
-TEST2RRD="...,diskstat" 
-GRAPHS="...,diskstat::1,diskstat0::1,diskstat1::1,diskstat2::1" 
 </code> </code>
  
Line 447: Line 356:
  
 ===== To do ===== ===== To do =====
-An option is to rework this script to send a trends-message to Xymon in stead of a status message. An advantage is that there is no need any more for script rrd_status.pl, a disadvantage might be the lack of a column named 'diskstat'.+An option is to rework this script to send a trends-message to Xymon in stead of a status message. The lack of a column named 'diskstat' might be an advantage for some.
  
 ===== Changelog ===== ===== Changelog =====
Line 453: Line 362:
   * **2012-04-02**   * **2012-04-02**
     * Initial release     * Initial release
 +  * **2019-02-12**
 +    * Use Devmon format to pass the statistics to xymon / RRD in stead of the NCV format.
  
  • monitors/diskstat.pl.txt
  • Last modified: 2019/02/16 17:53
  • by wnelis