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:48] – [retmt.pl] 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 16: Line 16:
  
  
-=== Client side ===+==== Client side ====
  
-The script, written in Perl, is installed in (copied to) ~xymon/client/ext, typically /usr/lib/xymon/client/ext.+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 === === retmt.pl ===
Line 31: 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 46: 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 68: 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 102: 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 137: 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 209: 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 225: Line 228:
  
  
-Script retmt.pl is invoked once every 5 minutes. This is configured by copying the snippet below to ~xymon/client/etc/clientlaunch.d/retmt.cfg and restarting xymon client.+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>
Line 239: Line 242:
  
  
-=== Server side ===+==== Server side ====
  
-Before ane 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.+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> <code>
Line 266: Line 269:
 <code> <code>
 # #
-# Graph definitions for additional tests in xymon, which are local to this +# Graph definition for test 'env'.
-# installation of xymon.+
 # #
 [env] [env]
- TITLE , temperature  + FNPATTERN ^env\.temp\.(.+)\.rrd$ 
 + TITLE , Temperature  
  YAXIS Temperature [C]  YAXIS Temperature [C]
- -l 0 + DEF:temp@RRDIDX@=@RRDFN@:Temperature:AVERAGE 
- DEF:temp=env.temp.rrd:Temperature:AVERAGE + DEF:tmin@RRDIDX@=@RRDFN@:MinTemp:MIN 
- DEF:tmin=env.temp.rrd:MinTemp:MIN + DEF:tmax@RRDIDX@=@RRDFN@:MaxTemp:MAX 
- DEF:tmax=env.temp.rrd:MaxTemp:MAX + CDEF:trng@RRDIDX@=tmax@RRDIDX@,tmin@RRDIDX@,- 
- CDEF:trng=tmax,tmin,+ LINE1:tmin@RRDIDX@#ffa07a 
- LINE1:tmin#ffa07a + AREA:trng@RRDIDX@#ffa07a::STACK 
- AREA:trng#ffa07a::STACK + LINE1:temp@RRDIDX@#EE0000:@RRDPARAM@ 
- LINE1:temp#EE0000:Average + GPRINT:tmin@RRDIDX@:MIN:Min \: %5.1lf C 
- GPRINT:tmin:MIN:Min \: %5.1lf C + GPRINT:tmax@RRDIDX@:MAX:Max \: %5.1lf C 
- GPRINT:tmax:MAX:Max \: %5.1lf C + GPRINT:temp@RRDIDX@:AVERAGE:Avg \: %5.1lf C 
- GPRINT:temp:AVERAGE:Avg \: %5.1lf C + GPRINT:temp@RRDIDX@:LAST:Cur \: %5.1lf C\n
- GPRINT:temp:LAST:Cur \: %5.1lf C\n+
 </code> </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.
  
-===== Source ===== 
-==== myscript.sh ==== 
- 
-<hidden onHidden="Show Code ⇲" onVisible="Hide Code ⇱"> 
 <code> <code>
 +TEST2RRD+=",env=devmon"
 +GRAPHS+=",env"
 </code> </code>
-</hidden> 
- 
-===== Known  Bugs and Issues ===== 
- 
-===== To Do ===== 
  
-===== Credits ===== 
  
 ===== Changelog ===== ===== Changelog =====
Line 305: 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.1508323716.txt.gz
  • Last modified: 2017/10/18 10:48
  • by wnelis