This repository has been archived by the owner on Mar 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathsendstatus.pl
executable file
·120 lines (96 loc) · 2.74 KB
/
sendstatus.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/perl
# This file is part of IFMI PoolManager.
#
# PoolManager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
use warnings;
#use strict;
sub bcastStatus
{
my $conf = &getConfig;
my %conf = %{$conf};
my $mname = `hostname`;
chomp $mname;
my $ispriv = &CGMinerIsPriv;
if ($ispriv eq "S") {
my $ts = $mname . '|' . ${$conf}{display}{miner_loc};
my $k;
my @gpus = &getFreshGPUData;
for ($k = 0;$k < @gpus;$k++)
{
$ts .= "|$k:" . encode_json $gpus[$k];
}
my $p;
my @pools = &getCGMinerPools;
for ($p = 0;$p < @pools;$p++)
{
$ts .= "|$p pool:" . encode_json $pools[$p];
}
my @summary = &getCGMinerSummary;
$ts .= "|sum:" . encode_json $summary[0];
my @version = &getCGMinerVersion;
$ts .= "|ver:$version[0]|";
my $port = 54545;
if (defined(${$conf}{farmview}{status_port}))
{
$port = ${$conf}{farmview}{status_port};
}
my $socket = IO::Socket::INET->new(Broadcast => 1, Blocking => 1, ReuseAddr => 1, Type => SOCK_DGRAM,
Proto => 'udp', PeerPort => $port, LocalPort => 0, PeerAddr => inet_ntoa(INADDR_BROADCAST));
if ($socket)
{
$socket->send($ts, 0);
close $socket;
&blog("status sent") if (defined(${$conf}{settings}{verbose}));
} else {
&blog("sendstatus failed to get socket") if (defined(${$conf}{settings}{verbose}));
}
}
}
sub directStatus
{
my ($target) = @_;
my $conf = &getConfig;
my %conf = %{$conf};
my $mname = `hostname`;
chomp $mname;
my $ispriv = &CGMinerIsPriv;
if ($ispriv eq "S") {
my $ts = $mname . '|' . ${$conf}{display}{miner_loc};
my @gpus = &getFreshGPUData('false');
my $k;
for ($k = 0;$k < @gpus;$k++)
{
$ts .= "|$k:" . encode_json $gpus[$k];
}
my $p;
my @pools = &getCGMinerPools;
for ($p = 0;$p < @pools;$p++)
{
$ts .= "|$p pool:" . encode_json $pools[$p];
}
my @summary = &getCGMinerSummary;
$ts .= "|sum:" . encode_json $summary[0];
my @version = &getCGMinerVersion;
$ts .= "|ver:$version[0]|";
my $port = 54545;
if (defined(${$conf}{farmview}{status_port}))
{
$port = ${$conf}{farmview}{status_port};
}
my $socket = IO::Socket::INET->new(Blocking => 1, ReuseAddr => 1, Type => SOCK_DGRAM,
Proto => 'udp', PeerPort => $port, LocalPort => 0, PeerAddr => $target);
if ($socket)
{
$socket->send($ts, 0);
close $socket;
&blog("direct status sent") if (defined(${$conf}{settings}{verbose}));
} else {
&blog("sendstatus failed to get socket") if (defined(${$conf}{settings}{verbose}));
}
}
}
1;