-
Notifications
You must be signed in to change notification settings - Fork 2
/
ups-email.rsc
27 lines (20 loc) · 909 Bytes
/
ups-email.rsc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
:local mailto "notify@me";
:local online;
:local sysname [/system identity get name];
:local datetime "$[/system clock get date] $[/system clock get time]";
:local upsname
:set upsname [system ups get value-name=name 0];
:global oldonline;
:if ([:typeof $oldonline]="nothing") do={:set $oldonline true};
:set online true;
:set online [system ups get value-name=on-line 0];
:if ( ( $online = false ) && ( $oldonline = true ) ) do={
:set oldonline false;
/tool e-mail send to=$mailto subject="$upsname power failed!" body="$upsname on $sysname is on battery since $datetime";
:log info "UPS: Power-Failed email sent to $mailto";
}
:if ( ( $online = true ) && ( $oldonline = false ) ) do={
:set oldonline true;
/tool e-mail send to=$mailto subject="$upsname: Power restored!" body="$upsname on $sysname is back online since $datetime";
:log info "UPS: Power-Restored email sent to $mailto";
}