monitors:retmt

Error loading plugin struct
ParseError: syntax error, unexpected 'fn' (T_STRING), expecting :: (T_PAAMAYIM_NEKUDOTAYIM)
More info is available in the error log.

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:retmt [2017/10/18 10:33] – [Installation] wnelismonitors:retmt [2020/01/28 10:22] (current) – [Changelog] wnelis
Line 1: Line 1:
 ====== retmt: RETrieve Machine Temperature ====== ====== retmt: RETrieve Machine Temperature ======
  
-^ Author | [[ wim.nelis@ziggo.nl | Wim Nelis ]] | +^ Author         | [[wim.nelis@ziggo.nl| Wim Nelis ]]  
-^ Compatibility | Xymon 4.2 | +^ Compatibility  | Xymon 4.2                           
-^ Requirements | Perl | +^ Requirements   | Perl                                
-^ Download | None | +^ Download       | None                                
-^ Last Update | 2017-10-18 |+^ Last Update    2020-01-28                          |
  
 ===== Description ===== ===== Description =====
  
-This client-side script retrieves the CPU and GPU temperatures of a Raspberry Pi 3 and reports them to the xymon server. A rather generic way of reporting the values is used, in which the minimum, the maximum and the average temperature are reported. This method is usable for an arbitrary number of temperature sensors. It is used to report the temperature of a switch with 29 temperature sensors.+This client-side script retrieves the CPU and GPU temperatures of a Raspberry Pi 3 and reports them to the xymon server. A rather generic way of reporting the values is used, in which the minimum, the maximum and the average temperature are reported. The graph shows the range of the temperatures (a 100% confidence interval) and the average of the temperatures. (This method is usable for an arbitrary number of temperature sensors. It is also used to report the temperatures of a switch with 29 temperature sensors.)
  
 ===== Installation ===== ===== Installation =====
Line 15: Line 15:
 At the client side the script and the invocation of the script need to be installed. On the server side an extension of the RRD definitions, an extension of the graph definitions and a configuration of this test in xymon server are needed. At the client side the script and the invocation of the script need to be installed. On the server side an extension of the RRD definitions, an extension of the graph definitions and a configuration of this test in xymon server are needed.
  
-=== Client side === 
  
-The script, written in Perl, is installed in ~xymon/client/ext, typically /usr/lib/xymon/client/ext.+==== Client side ====
  
-==== retmt.pl ====+The script, written in Perl, is installed in (copied to) file ~xymon/client/ext/retmt.pl, typically /usr/lib/xymon/client/ext/retmt.pl. 
 + 
 +=== retmt.pl ===
  
 <hidden onHidden="Show Code ⇲" onVisible="Hide Code ⇱"> <hidden onHidden="Show Code ⇲" onVisible="Hide Code ⇱">
Line 30: Line 31:
 # #
 # Written by W.J.M. Nelis, wim.nelis@ziggo.nl, 2017.10 # Written by W.J.M. Nelis, wim.nelis@ziggo.nl, 2017.10
 +#
 +# Modified by W.J.M. Nelis, wim.nelis@ziggo.nl, 2018.07
 +# - Specify the device type in the RRD file name, in this case 'cpu'.
 # #
 use strict ; use strict ;
Line 45: Line 49:
 chomp $HostName ; chomp $HostName ;
 my $TestName= 'env' ; # Test name my $TestName= 'env' ; # Test name
-my $ThresholdYellow= 50 ; # Warning threshold [C] +my $ThresholdYellow= 60 ; # Warning threshold [C] 
-my $ThresholdRed   60 ; # Error threshold [C]+my $ThresholdRed   70 ; # Error threshold [C]
  
 my @ColourOf= ( 'red', 'yellow', 'clear', 'green' ) ; my @ColourOf= ( 'red', 'yellow', 'clear', 'green' ) ;
Line 67: Line 71:
  
 # #
-# Issue a message the the logfile. As this script is run periodically by Xymon,+# Issue a message to the logfile. As this script is run periodically by Xymon,
 # StdOut will be redirected to the logfile. # StdOut will be redirected to the logfile.
 # #
Line 101: Line 105:
   $Result= "\"status $HostName.$TestName $Colour $Now\n" .   $Result= "\"status $HostName.$TestName $Colour $Now\n" .
     "<b>Temperature sensor readings</b>\n\n" .     "<b>Temperature sensor readings</b>\n\n" .
-           "$ErrMsg$Result\"\n"+    "$ErrMsg$Result\"\n"
-  `$XySend $XyDisp $Result` ;           # Inform Xymon+  `$XySend $XyDisp $Result` ; # Inform Xymon
  
-  $Result= ''                        # Reset message parameters+  $Result= '' ; # Reset message parameters
   $Colour=  3 ;   $Colour=  3 ;
   $ErrMsg{$_}= [] foreach ( @ColourOf ) ;   $ErrMsg{$_}= [] foreach ( @ColourOf ) ;
Line 136: Line 140:
   @Lines= `$GpuCmd` ; # Retrieve information   @Lines= `$GpuCmd` ; # Retrieve information
   if ( @Lines == 0 ) {   if ( @Lines == 0 ) {
-    push @{$ErrMsg{clear}}, "Cannot read GPU temperature from $GpuCmd:\n" .+    push @{$ErrMsg{clear}}, "Cannot read GPU temperature from \`$GpuCmd\`:\n" .
      "  no data returned" ;      "  no data returned" ;
   } else {   } else {
     chomp $Lines[0] ;     chomp $Lines[0] ;
     unless ( $Lines[0] =~ m/^temp=([\d\.]+).+C$/ ) {     unless ( $Lines[0] =~ m/^temp=([\d\.]+).+C$/ ) {
-      push @{$ErrMsg{clear}}, "Cannot read GPU temperature from $GpuCmd:\n" .+      push @{$ErrMsg{clear}}, "Cannot read GPU temperature from \`$GpuCmd\`:\n" .
        "  unexpected input : $Lines[0]" ;        "  unexpected input : $Lines[0]" ;
     } else {     } else {
Line 208: Line 212:
   $Result.= "<!--DEVMON RRD: env 0 0\n" ;   $Result.= "<!--DEVMON RRD: env 0 0\n" ;
   $Result.= "DS:Temperature:GAUGE:600:-100:100 DS:MinTemp:GAUGE:600:-100:100 DS:MaxTemp:GAUGE:600:-100:100\n" ;   $Result.= "DS:Temperature:GAUGE:600:-100:100 DS:MinTemp:GAUGE:600:-100:100 DS:MaxTemp:GAUGE:600:-100:100\n" ;
-  $Result.= "temp $TempAvg:$TempMin:$TempMax\n" ;+  $Result.= "temp.cpu $TempAvg:$TempMin:$TempMax\n" ;
   $Result.= "-->" ;   $Result.= "-->" ;
 }  # of BuildMessage }  # of BuildMessage
Line 222: Line 226:
 </hidden> </hidden>
  
-=== Server side === 
  
-===== Source ===== 
-==== myscript.sh ==== 
  
-<hidden onHidden="Show Code ⇲" onVisible="Hide Code ⇱">+Script retmt.pl is invoked once every 5 minutes. This is configured by copying the snippet below to file ~xymon/client/etc/clientlaunch.d/retmt.cfg and restarting the xymon client. 
 <code> <code>
 +#
 +# Test retmt retrieves the temperatures of this machine.
 +#
 +[retmt]
 + ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
 + CMD $XYMONCLIENTHOME/ext/retmt.pl
 + LOGFILE $XYMONCLIENTLOGS/retmt.log
 + INTERVAL 5m
 </code> </code>
-</hidden> 
  
-===== Known  Bugs and Issues ===== 
  
-===== To Do =====+==== Server side ==== 
 + 
 +Before any data is captured in an RRD, the definition of the RRD needed for this monitor needs to be installed. Add the snippet below to file ~xymon/server/etc/rrddefinitions.cfg, somewhere before the default setup. 
 + 
 +<code> 
 +# Definition for the measurement of the environmental temperature(s). 
 +# Besides the average the minimum and the maximum are measured, and 
 +# thus the MIN and MAX consolidation functions are needed too. 
 +[env] 
 + RRA:AVERAGE:0.5:1:576 
 + RRA:AVERAGE:0.5:6:576 
 + RRA:AVERAGE:0.5:24:576 
 + RRA:AVERAGE:0.5:288:576 
 + RRA:MIN:0.5:1:576 
 + RRA:MIN:0.5:6:576 
 + RRA:MIN:0.5:24:576 
 + RRA:MIN:0.5:288:576 
 + RRA:MAX:0.5:1:576 
 + RRA:MAX:0.5:6:576 
 + RRA:MAX:0.5:24:576 
 + RRA:MAX:0.5:288:576 
 +</code> 
 + 
 +Next the graph definition shown below is saved in file ~xymon/server/etc/graphs.d/graphs.retmt.cfg. 
 + 
 +<code> 
 +
 +# Graph definition for test 'env'
 +
 +[env] 
 + FNPATTERN ^env\.temp\.(.+)\.rrd$ 
 + TITLE , Temperature   
 + YAXIS Temperature [C] 
 + DEF:temp@RRDIDX@=@RRDFN@:Temperature:AVERAGE 
 + DEF:tmin@RRDIDX@=@RRDFN@:MinTemp:MIN 
 + DEF:tmax@RRDIDX@=@RRDFN@:MaxTemp:MAX 
 + CDEF:trng@RRDIDX@=tmax@RRDIDX@,tmin@RRDIDX@,
 + LINE1:tmin@RRDIDX@#ffa07a 
 + AREA:trng@RRDIDX@#ffa07a::STACK 
 + LINE1:temp@RRDIDX@#EE0000:@RRDPARAM@ 
 + GPRINT:tmin@RRDIDX@:MIN:Min \: %5.1lf C 
 + GPRINT:tmax@RRDIDX@:MAX:Max \: %5.1lf C 
 + GPRINT:temp@RRDIDX@:AVERAGE:Avg \: %5.1lf C 
 + GPRINT:temp@RRDIDX@:LAST:Cur \: %5.1lf C\n 
 +</code> 
 + 
 +The definition file xymonserver.cfg is extended by copying the snippet below to file ~xymon/server/etc/xymonserver.d/env.cfg. It specifies that the status message for test named 'env' uses the DEVMON format to pass measurements. 
 + 
 +<code> 
 +TEST2RRD+=",env=devmon" 
 +GRAPHS+=",env" 
 +</code>
  
-===== Credits ===== 
  
 ===== Changelog ===== ===== Changelog =====
Line 242: Line 300:
   * **2017-10-18**   * **2017-10-18**
     * Initial release     * Initial release
 +  * **2020-01-28**
 +    * Include 'cpu' in the name of the RRD, change graph definition accordingly.
  
  • monitors/retmt.1508322813.txt.gz
  • Last modified: 2017/10/18 10:33
  • by wnelis