-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIGOR.pl
69 lines (68 loc) · 1.89 KB
/
IGOR.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
#!/usr/local/bin/perl
use strict; use warnings;
use Proc::Daemon;
use File::Find::Rule;
################ SUMMONS #
# IGOR - minion taskmaster
# ($.$) ---skrp of MKRX
# start - stop - pause - ping_pid
my @cmds = qw(pause stat errchk dive countoff);
# SETUP ###############################
my $work = 'MINION/';
my $limbo = 'limbo'; my $dump = 'dump';
my $state = 'STATE'; my $debug = 'DEBUG';
my $log = 'LOG'; my $pid = 'PID';
my $que = 'QUE'; my $clean = 'CLEAN'
my $pause = 'PAUSE'; my $shutdown = 'SHUT';
# DAEMONIZE ##########################
my $daemon = Proc::Daemon->new(
work_dir => $work,
child_STDOUT => $log,
child_STDERR => +>>$debug,
pid_file => $pid,
);
$daemon->Init();
# SUB ####################
sub ping_pid {
my $target = '/MINION/';
my @workn;
my @minions = File::Find::Rule->new
->directory($target)
->in($root)
->maxdepth(1)
foreach $minion (@minions) {
if (-e $target$minion/$minion'_DOWN')
{ next; }
else
{ push @workn $minion; }
return @workn;
}
sub pause {
my ($minion) = @_;
my ($duration) = @_; # HOURS
my $minion_path = "/MINION/$minion/$minion'_PAUSE'";
open(my $mfh, '>', $minion_path) or print "cant open $minion_path\n";
$duration = $duartion*3600;
print $mfh "$duration";
close $mfh;
print "$minion_path PAUSED\n";
}
sub shutdwn {
my ($minion) = @_;
my $minion_path = "/MINION/$minion/$minion'_SHUTDOWN'";
open(my $mfh, '>', $minion_path) or print "cant open $minion_path\n";
close $mfh;
print "$minion_path SHUTDOWN\n";
}
sub dive {
my ($m_target) = @_;
my $target = "/MINION/$m_target/$m_target'_pool'";
my $count = 0;
my $rule = File::Find::Rule->file()->start($target);
while (defined(my $file = $rule->match))
{ $count++; }
return $count;
}
# if (ps $pid > 0) { foreach (@log_line) { print "$_\n"; } }
# main addr string in green. iteration in yellow. err in red.
# MINION_MASTER