2020-09-18 11:00:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#!rsc by RouterOS
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# RouterOS script: check-health
							 | 
						
					
						
							
								
									
										
										
										
											2022-01-01 21:38:15 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# Copyright (c) 2019-2022 Christian Hesse <mail@eworm.de>
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-19 22:17:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# check for RouterOS health state
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-27 21:41:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-health.md
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-02-22 15:14:10 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:local 0 "check-health";
							 | 
						
					
						
							
								
									
										
										
										
											2021-02-18 14:52:47 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:global GlobalFunctionsReady;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								:global CheckHealthLast;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								:global CheckHealthTemperature;
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-16 22:51:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:global CheckHealthTemperatureDeviation;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								:global CheckHealthTemperatureNotified;
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-13 21:29:33 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:global CheckHealthVoltageLow;
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-14 19:06:21 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:global CheckHealthVoltagePercent;
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								:global Identity;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 14:53:25 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:global IfThenElse;
							 | 
						
					
						
							
								
									
										
										
										
											2021-02-22 15:14:10 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:global LogPrintExit2;
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-27 11:21:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:global ScriptLock;
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 20:42:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:global SendNotification2;
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-17 08:07:12 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:global SymbolForNotification;
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:local TempToNum do={
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :global CharacterReplace;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :local T [ :toarray [ $CharacterReplace $1 "." "," ] ];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :return ($T->0 * 10 + $T->1);
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-10 14:43:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:if ([ :len [ /system/health/find ] ] = 0) do={
							 | 
						
					
						
							
								
									
										
										
										
											2021-02-22 15:14:10 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  $LogPrintExit2 error $0 ("Your device does not provide any health values.") true;
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-16 21:35:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:if ([ :typeof $CheckHealthLast ] != "array") do={
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :set CheckHealthLast [ :toarray "" ];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-16 22:51:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:if ([ :typeof $CheckHealthTemperatureNotified ] != "array") do={
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :set CheckHealthTemperatureNotified [ :toarray "" ];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-27 11:21:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								$ScriptLock $0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-10 14:43:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:foreach Voltage in=[ /system/health/find where type="V" ] do={
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :local Name  [ /system/health/get $Voltage name  ];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :local Value [ /system/health/get $Voltage value ];
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    :local NumCurr [ $TempToNum $Value ];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    :local NumLast [ $TempToNum ($CheckHealthLast->$Name) ];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    :if ($NumLast * (100 + $CheckHealthVoltagePercent) < $NumCurr * 100 || \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         $NumLast * 100 > $NumCurr * (100 + $CheckHealthVoltagePercent)) do={
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 21:43:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      $SendNotification2 ({ origin=$0; \
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($NumLast < \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          $NumCurr) "in" "de" ] . "creasing") ] . "Health warning: " . $Name); \
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 20:42:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        message=("The " . $Name . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          "old value: " . ($CheckHealthLast->$Name) . " V\n" . \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          "new value: " . $Value . " V") });
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-13 21:29:33 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    } else={ 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      :if ($NumCurr <= $CheckHealthVoltageLow && $NumLast > $CheckHealthVoltageLow) do={ 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-13 21:29:33 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        $SendNotification2 ({ origin=$0; \ 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          subject=([ $SymbolForNotification "high-voltage-sign,chart-decreasing" ] . "Health warning: Low " . $Name); \ 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          message=("The " . $Name . " on " . $Identity . " dropped to " . $Value . " V below hard limit.") }); 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-13 21:29:33 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      } 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      :if ($NumCurr > $CheckHealthVoltageLow && $NumLast <= $CheckHealthVoltageLow) do={ 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-13 21:29:33 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        $SendNotification2 ({ origin=$0; \ 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          subject=([ $SymbolForNotification "high-voltage-sign,chart-increasing" ] . "Health recovery: Low " . $Name); \ 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          message=("The " . $Name . " on " . $Identity . " recovered to " . $Value . " V above hard limit.") }); 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-13 21:29:33 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      }
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  :set ($CheckHealthLast->$Name) $Value;
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-10 14:43:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:foreach PSU in=[ /system/health/find where name~"^psu.*-state\$" ] do={
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :local Name  [ /system/health/get $PSU name  ];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :local Value [ /system/health/get $PSU value ];
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-17 23:05:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    :if ($CheckHealthLast->$Name = "ok" && \
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         $Value != "ok") do={
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 21:43:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      $SendNotification2 ({ origin=$0; \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        subject=([ $SymbolForNotification "cross-mark" ] . "Health warning: " . $Name); \
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 20:42:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        message=("The power supply unit '" . $Name . "' on " . $Identity . " failed!") });
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-28 20:48:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-17 23:05:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    :if ($CheckHealthLast->$Name != "ok" && \
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         $Value = "ok") do={
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 21:43:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      $SendNotification2 ({ origin=$0; \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 20:42:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        message=("The power supply unit '" . $Name . "' on " . $Identity . " recovered!") });
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-28 20:48:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 15:20:11 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  :set ($CheckHealthLast->$Name) $Value;
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-10 14:43:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:foreach Temperature in=[ /system/health/find where type="C" ] do={
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :local Name  [ /system/health/get $Temperature name  ];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :local Value [ /system/health/get $Temperature value ];
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  :if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-17 23:05:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    :if ([ :typeof ($CheckHealthTemperature->$Name) ] != "num" ) do={
							 | 
						
					
						
							
								
									
										
										
										
											2021-02-22 15:14:10 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      $LogPrintExit2 info $0 ("No threshold given for " . $Name . ", assuming 50C.") false;
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-17 23:05:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      :set ($CheckHealthTemperature->$Name) 50;
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-10 14:43:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    :local Validate [ /system/health/get [ find where name=$Name ] value ];
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    :while ($Value != $Validate) do={
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      :set Value $Validate;
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-10 14:43:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      :set Validate [ /system/health/get [ find where name=$Name ] value ];
							 | 
						
					
						
							
								
									
										
										
										
											2020-11-19 21:23:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    :if ($Value > $CheckHealthTemperature->$Name && \
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-17 23:05:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         $CheckHealthTemperatureNotified->$Name != true) do={
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 21:43:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      $SendNotification2 ({ origin=$0; \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        subject=([ $SymbolForNotification "fire" ] . "Health warning: " . $Name); \
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 20:42:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        message=("The " . $Name . " on " . $Identity . " is above threshold: " . \
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          $Value . "\C2\B0" . "C") });
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-17 23:05:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      :set ($CheckHealthTemperatureNotified->$Name) true;
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    :if ($Value <= ($CheckHealthTemperature->$Name - $CheckHealthTemperatureDeviation) && \
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-17 23:05:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         $CheckHealthTemperatureNotified->$Name = true) do={
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 21:43:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      $SendNotification2 ({ origin=$0; \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 20:42:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        message=("The " . $Name . " on " . $Identity . " dropped below threshold: " .  \
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          $Value . "\C2\B0" . "C") });
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-17 23:05:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      :set ($CheckHealthTemperatureNotified->$Name) false;
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 15:20:11 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-16 13:49:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  :set ($CheckHealthLast->$Name) $Value;
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-27 10:35:53 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |