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
/
run-poolmanager.pl
executable file
·96 lines (79 loc) · 2.3 KB
/
run-poolmanager.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
#!/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;
require '/opt/ifmi/pm-common.pl';
require '/opt/ifmi/sendstatus.pl';
require '/opt/ifmi/pmnotify.pl';
my $conf = &getConfig;
my %conf = %{$conf};
use Proc::Daemon;
use Proc::PID::File;
Proc::Daemon::Init;
if (Proc::PID::File->running()) {
exit(0);
}
my $continue = 1;
$SIG{TERM} = sub { $continue = 0 };
while ($continue) {
# Start profile on boot
if ($conf{settings}{do_boot} == 1) {
my $uptime = `cat /proc/uptime`;
$uptime =~ /^(\d+)\.\d+\s+\d+\.\d+/;
my $rigup = $1;
if (!-f "/nomine") {
if ($rigup < 300) {
my $filecheck = 0; $filecheck = 1 if (-e "/opt/ifmi/nomine");
my $xcheck1 = `ps -eo command | grep -cE ^/usr/bin/X`;
my $xcheck2 = `ps -eo command | grep -cE ^X`;
my $mcheck = `ps -eo command | grep -cE [P]M-miner`;
if (($xcheck1 == 1 || $xcheck2 == 1) && $mcheck == 0 && $filecheck == 0) {
&startCGMiner;
sleep 15;
&resetPoolSuperPri;
}
}
}
}
# broadcast node status
if ($conf{farmview}{do_bcast_status} == 1) {
&bcastStatus;
}
# send status direct
if ($conf{farmview}{do_direct_status} =~ m/\d+\.\d+\.\d+\.\d+/) {
&directStatus($conf{farmview}{do_direct_status});
}
# Email
if ($conf{monitoring}{do_email} == 1) {
if (-f "/tmp/pmnotify.lastsent") {
if (time - (stat ('/tmp/pmnotify.lastsent'))[9] > ($conf{email}{smtp_min_wait} -10)) {
&doEmail;
}
} else { &doEmail; }
}
# Graphs should be no older than 5 minutes
my $graph = "/var/www/IFMI/graphs/msummary.png";
if (-f $graph) {
if (time - (stat ($graph))[9] > 290) {
exec('/opt/ifmi/pmgraph.pl');
}
} else {
exec('/opt/ifmi/pmgraph.pl');
}
#Pimp specific
if (-f "/etc/version") {
my $pimpcheck = `grep -c pimp /etc/version `;
&doGpustats if ($pimpcheck > 0);
&doSysstats if ($pimpcheck > 0);
}
# Get the ad
`cd /tmp ; wget --quiet -N http://ads.miner.farm/pm.html ; cp pm.html adata`;
sleep 60;
}
1;