-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcheck_position.pl
48 lines (39 loc) · 1.13 KB
/
check_position.pl
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use strict;
use Net::SMS::TextmagicRest;
# Author: Eugene Luzgin @ EOS Tribe
# Install TextMagic:
# https://www.textmagic.com/docs/api/perl/
# Crete account, get API key at https://www.textmagic.com/
# Change values:
my $node_dir = "/home/eostribe/Mainnet/producer-node";
my $producer = "eostribeprod";
my @PHONES = ("CELL-PHONE");
my $tm = Net::SMS::TextmagicRest->new(
username => "USERNAME",
token => "TOKEN",
);
open LOG, "<$node_dir/bp_position.last";
my $last_position = <LOG>;
chomp $last_position;
close LOG;
my @REGDATA = `$node_dir/cleos.sh system listproducers`;
my $bp_position = "50+";
my $counter = 0;
foreach my $regbp (@REGDATA) {
if($regbp=~m/^(\w+)\s+(EOS\w+)\s/) {
$counter++;
if($1 eq $producer) { $bp_position = $counter };
}
}
if($bp_position!=$last_position) {
my $message = "$producer moved #".$last_position." -> #".$bp_position;
open LOG, ">$node_dir/bp_position.last";
print LOG $bp_position;
close LOG;
# Send SMS Alert if message set:
my $result = $tm->send(
text => $message,
phones => \@PHONES,
);
print "Sent $message SMS[$result->{id}]\n";
}