complete daemon pstree updates
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
* Attempt to keep PID and logfile as netdisco user even when running as root
|
* Attempt to keep PID and logfile as netdisco user even when running as root
|
||||||
* Show netdisco-do docs on options error
|
* Show netdisco-do docs on options error
|
||||||
* Do not leak SNMP community string into debug output (unless SHOW_COMMUNITY=1)
|
* Do not leak SNMP community string into debug output (unless SHOW_COMMUNITY=1)
|
||||||
|
* Process tree updated to show daemon worker status/activity
|
||||||
|
|
||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,23 @@ __PACKAGE__->set_primary_key("job");
|
|||||||
|
|
||||||
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
||||||
|
|
||||||
|
=head1 METHODS
|
||||||
|
|
||||||
|
=head2 summary
|
||||||
|
|
||||||
|
An attempt to make a meaningful statement about the job.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub summary {
|
||||||
|
my $job = shift;
|
||||||
|
return join ' ',
|
||||||
|
$job->action,
|
||||||
|
($job->device || ''),
|
||||||
|
($job->port || ''),
|
||||||
|
($job->subaction ? (q{'}. $job->subaction .q{'}) : '');
|
||||||
|
}
|
||||||
|
|
||||||
=head1 ADDITIONAL COLUMNS
|
=head1 ADDITIONAL COLUMNS
|
||||||
|
|
||||||
=head2 entererd_stamp
|
=head2 entererd_stamp
|
||||||
|
|||||||
@@ -44,8 +44,44 @@ __PACKAGE__->add_columns(
|
|||||||
|
|
||||||
__PACKAGE__->set_primary_key("job");
|
__PACKAGE__->set_primary_key("job");
|
||||||
|
|
||||||
|
=head1 METHODS
|
||||||
|
|
||||||
|
=head2 summary
|
||||||
|
|
||||||
|
An attempt to make a meaningful statement about the job.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub summary {
|
||||||
|
my $job = shift;
|
||||||
|
return join ' ',
|
||||||
|
$job->action,
|
||||||
|
($job->device || ''),
|
||||||
|
($job->port || ''),
|
||||||
|
($job->subaction ? (q{'}. $job->subaction .q{'}) : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
=head1 ADDITIONAL COLUMNS
|
||||||
|
|
||||||
|
=head2 extra
|
||||||
|
|
||||||
|
Alias for the C<subaction> column.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
sub extra { (shift)->subaction }
|
sub extra { (shift)->subaction }
|
||||||
|
|
||||||
|
=head2 entererd_stamp
|
||||||
|
|
||||||
|
Formatted version of the C<entered> field, accurate to the minute.
|
||||||
|
|
||||||
|
The format is somewhat like ISO 8601 or RFC3339 but without the middle C<T>
|
||||||
|
between the date stamp and time stamp. That is:
|
||||||
|
|
||||||
|
2012-02-06 12:49
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
sub entered_stamp {
|
sub entered_stamp {
|
||||||
(my $stamp = (shift)->entered) =~ s/\.\d+$//;
|
(my $stamp = (shift)->entered) =~ s/\.\d+$//;
|
||||||
return $stamp;
|
return $stamp;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ sub worker_body {
|
|||||||
my $type = $self->worker_type;
|
my $type = $self->worker_type;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
$0 = sprintf 'netdisco-daemon: worker #%s %s: idle', $wid, lc($type);
|
||||||
my $jobs = jq_take($self->wid, $type);
|
my $jobs = jq_take($self->wid, $type);
|
||||||
|
|
||||||
foreach my $job (@$jobs) {
|
foreach my $job (@$jobs) {
|
||||||
@@ -23,6 +24,8 @@ sub worker_body {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$job->started(scalar localtime);
|
$job->started(scalar localtime);
|
||||||
|
$0 = sprintf 'netdisco-daemon: worker #%s %s: working on #%s: %s',
|
||||||
|
$wid, lc($type), $job->id, $job->summary;
|
||||||
info sprintf "$tag (%s): starting %s job(%s) at %s",
|
info sprintf "$tag (%s): starting %s job(%s) at %s",
|
||||||
$wid, $target, $job->id, $job->started;
|
$wid, $target, $job->id, $job->started;
|
||||||
my ($status, $log) = $self->$target($job);
|
my ($status, $log) = $self->$target($job);
|
||||||
@@ -42,9 +45,12 @@ sub worker_body {
|
|||||||
|
|
||||||
sub close_job {
|
sub close_job {
|
||||||
my ($self, $job) = @_;
|
my ($self, $job) = @_;
|
||||||
my $tag = $self->worker_tag;
|
my $tag = $self->worker_tag;
|
||||||
my $now = scalar localtime;
|
my $type = $self->worker_type;
|
||||||
|
my $now = scalar localtime;
|
||||||
|
|
||||||
|
$0 = sprintf 'netdisco-daemon: worker #%s %s: wrapping up %s #%s: %s',
|
||||||
|
$self->wid, lc($type), $job->action, $job->id, $job->status;
|
||||||
info sprintf "$tag (%s): wrapping up %s job(%s) - status %s at %s",
|
info sprintf "$tag (%s): wrapping up %s job(%s) - status %s at %s",
|
||||||
$self->wid, $job->action, $job->id, $job->status, $now;
|
$self->wid, $job->action, $job->id, $job->status, $now;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ sub worker_begin {
|
|||||||
return debug "mgr ($wid): no need for manager... skip begin"
|
return debug "mgr ($wid): no need for manager... skip begin"
|
||||||
if setting('workers')->{'no_manager'};
|
if setting('workers')->{'no_manager'};
|
||||||
|
|
||||||
$0 = sprintf 'netdisco-daemon: worker #%s manager: begin', $wid;
|
|
||||||
debug "entering Manager ($wid) worker_begin()";
|
debug "entering Manager ($wid) worker_begin()";
|
||||||
|
|
||||||
# requeue jobs locally
|
# requeue jobs locally
|
||||||
@@ -23,7 +22,8 @@ sub worker_begin {
|
|||||||
my @jobs = jq_locked;
|
my @jobs = jq_locked;
|
||||||
|
|
||||||
if (scalar @jobs) {
|
if (scalar @jobs) {
|
||||||
info sprintf "mgr (%s): found %s jobs booked to this processing node", $wid, scalar @jobs;
|
info sprintf "mgr (%s): found %s jobs booked to this processing node",
|
||||||
|
$wid, scalar @jobs;
|
||||||
$self->do('add_jobs', @jobs);
|
$self->do('add_jobs', @jobs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,12 +35,12 @@ sub worker_body {
|
|||||||
return debug "mgr ($wid): no need for manager... quitting"
|
return debug "mgr ($wid): no need for manager... quitting"
|
||||||
if setting('workers')->{'no_manager'};
|
if setting('workers')->{'no_manager'};
|
||||||
|
|
||||||
$0 = sprintf 'netdisco-daemon: worker #%s manager: body', $wid;
|
|
||||||
my $num_slots = sum( 0, map { setting('workers')->{$_} }
|
my $num_slots = sum( 0, map { setting('workers')->{$_} }
|
||||||
values %{setting('job_type_keys')} );
|
values %{setting('job_type_keys')} );
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
debug "mgr ($wid): getting potential jobs for $num_slots workers";
|
debug "mgr ($wid): getting potential jobs for $num_slots workers";
|
||||||
|
$0 = sprintf 'netdisco-daemon: worker #%s manager: gathering', $wid;
|
||||||
|
|
||||||
# get some pending jobs
|
# get some pending jobs
|
||||||
# TODO also check for stale jobs in Netdisco DB
|
# TODO also check for stale jobs in Netdisco DB
|
||||||
@@ -50,7 +50,6 @@ sub worker_body {
|
|||||||
my $job_type = setting('job_types')->{$job->action};
|
my $job_type = setting('job_types')->{$job->action};
|
||||||
next unless $job_type and $self->do('capacity_for', $job_type);
|
next unless $job_type and $self->do('capacity_for', $job_type);
|
||||||
|
|
||||||
$0 = sprintf 'netdisco-daemon: worker #%s manager: booking %s', $wid, $job->id;
|
|
||||||
debug sprintf "mgr (%s): processing node has capacity for job %s (%s)",
|
debug sprintf "mgr (%s): processing node has capacity for job %s (%s)",
|
||||||
$wid, $job->id, $job->action;
|
$wid, $job->id, $job->action;
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,12 @@ sub worker_body {
|
|||||||
while (1) {
|
while (1) {
|
||||||
# sleep until some point in the next minute
|
# sleep until some point in the next minute
|
||||||
my $naptime = 60 - (time % 60) + int(rand(45));
|
my $naptime = 60 - (time % 60) + int(rand(45));
|
||||||
|
|
||||||
|
$0 = sprintf 'netdisco-daemon: worker #%s scheduler: idle', $wid;
|
||||||
debug "sched ($wid): sleeping for $naptime seconds";
|
debug "sched ($wid): sleeping for $naptime seconds";
|
||||||
|
|
||||||
sleep $naptime;
|
sleep $naptime;
|
||||||
|
$0 = sprintf 'netdisco-daemon: worker #%s scheduler: queueing', $wid;
|
||||||
|
|
||||||
# NB next_time() returns the next *after* win_start
|
# NB next_time() returns the next *after* win_start
|
||||||
my $win_start = time - (time % 60) - 1;
|
my $win_start = time - (time % 60) - 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user