diff --git a/Netdisco/bin/netdisco-daemon-fg b/Netdisco/bin/netdisco-daemon-fg index 8b13e5a7..6bcfb713 100755 --- a/Netdisco/bin/netdisco-daemon-fg +++ b/Netdisco/bin/netdisco-daemon-fg @@ -47,9 +47,13 @@ prctl 'netdisco-daemon: master'; # shared local job queue my $queue = MCE::Queue->new; +# support a scheduler-only node +setting('workers')->{'no_manager'} = 1 + if setting('workers')->{tasks} eq '0'; + mce_flow { task_name => [qw/ scheduler manager poller /], - max_workers => [ 1, 1, setting('workers')->{pollers} ], + max_workers => [ 1, 1, setting('workers')->{tasks} ], tmp_dir => $tmp_dir, on_post_exit => sub { MCE->restart_worker }, }, _mk_wkr('Scheduler'), _mk_wkr('Manager'), _mk_wkr('Poller'); diff --git a/Netdisco/lib/App/Netdisco/Configuration.pm b/Netdisco/lib/App/Netdisco/Configuration.pm index 8e22995e..264b79b7 100644 --- a/Netdisco/lib/App/Netdisco/Configuration.pm +++ b/Netdisco/lib/App/Netdisco/Configuration.pm @@ -51,11 +51,11 @@ setting('workers')->{queue} ||= 'PostgreSQL'; if (exists setting('workers')->{interactives} or exists setting('workers')->{pollers}) { - setting('workers')->{pollers} = ( + setting('workers')->{tasks} = (setting('workers')->{pollers} || 0) - .' + '. (setting('workers')->{interactives} || 0) - ) if setting('workers')->{interactives}; + + (setting('workers')->{interactives} || 0); + delete setting('workers')->{pollers}; delete setting('workers')->{interactives}; } diff --git a/Netdisco/lib/App/Netdisco/Daemon/Worker/Manager.pm b/Netdisco/lib/App/Netdisco/Daemon/Worker/Manager.pm index 602f8a94..18ae8421 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Worker/Manager.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Worker/Manager.pm @@ -39,7 +39,7 @@ sub worker_body { if setting('workers')->{'no_manager'}; my $num_slots = - MCE::Util::_parse_max_workers( setting('workers')->{pollers} ) + MCE::Util::_parse_max_workers( setting('workers')->{tasks} ) - $self->{queue}->pending(); while (1) { diff --git a/Netdisco/lib/App/Netdisco/Daemon/Worker/Scheduler.pm b/Netdisco/lib/App/Netdisco/Daemon/Worker/Scheduler.pm index bf1c0795..a2a3213b 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Worker/Scheduler.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Worker/Scheduler.pm @@ -15,7 +15,7 @@ sub worker_begin { my $wid = $self->wid; return debug "mgr ($wid): no need for scheduler... skip begin" - unless setting('scheduler'); + unless setting('schedule'); debug "entering Scheduler ($wid) worker_begin()"; @@ -39,7 +39,7 @@ sub worker_body { my $wid = $self->wid; return debug "mgr ($wid): no need for scheduler... quitting" - unless setting('scheduler'); + unless setting('schedule'); while (1) { # sleep until some point in the next minute diff --git a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod index 135996ca..e82228ec 100644 --- a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod +++ b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod @@ -879,14 +879,17 @@ or remove any entries. Value: Settings Tree. Default: workers: - pollers: 'AUTO * 2' + tasks: 'AUTO * 2' sleep_time: 1 Control the activity of the backend daemon with this configuration setting. -C sets how many workers are started for interactive jobs (port +C sets how many worker processes are started for interactive jobs (port control) and polling jobs (discover, macsuck, arpnip) on this node. Other -nodes can have different settings. "C" is the number of CPU cores. +nodes can have different settings. + +"C" is the number of CPU cores. Set C to "C<0>" to disable all +workers (which allows you to have a scheduler-only node). C is the number of seconds between polling the database to find new jobs. This is a balance between responsiveness and database load. @@ -918,9 +921,9 @@ If set, then this node's backend daemon will schedule polling jobs (discover, macsuck, arpnip, etc) in the central database. It's fine to have multiple nodes scheduling work for redundancy (but make sure they all have good NTP). -Note that this is independent of the Pollers configured in C. It's +Note that this is independent of the Tasks configured in C. It's okay to have this node schedule schedule but not do any of the polling -itself (C). +itself (C). Work can be scheduled using C style notation, or a simple weekday and hour fields (which accept same types as C notation). For example: diff --git a/Netdisco/lib/App/Netdisco/Manual/ReleaseNotes.pod b/Netdisco/lib/App/Netdisco/Manual/ReleaseNotes.pod index 1eff7b67..a0b46ca1 100644 --- a/Netdisco/lib/App/Netdisco/Manual/ReleaseNotes.pod +++ b/Netdisco/lib/App/Netdisco/Manual/ReleaseNotes.pod @@ -48,6 +48,15 @@ web interface. We advise that you back up the database prior to upgrade: =head2 General Notices +The backend polling daemon has been rewritten and as a result your +configuration can be simplified. Some keys have also been renamed. Our advice +is to remove (or comment out) the complete C configuration which +enables auto-tuning. If you do wish to control the number of worker +processes, follow this pattern: + + workers: + tasks: 'AUTO * 2' # this is the default, twice the number of CPUs + The configuration item C is now a list (used to be a dictionary). Each item in the list must have a C entry which was previously the dictionary key. For example, now use: diff --git a/Netdisco/share/config.yml b/Netdisco/share/config.yml index 2f5ee55c..49f7be11 100644 --- a/Netdisco/share/config.yml +++ b/Netdisco/share/config.yml @@ -170,7 +170,7 @@ port_control_reasons: # -------------- workers: - pollers: 'AUTO * 2' + tasks: 'AUTO * 2' sleep_time: 1 queue: PostgreSQL diff --git a/Netdisco/share/environments/deployment.yml b/Netdisco/share/environments/deployment.yml index 98cab306..b85fba49 100644 --- a/Netdisco/share/environments/deployment.yml +++ b/Netdisco/share/environments/deployment.yml @@ -64,11 +64,11 @@ discover_no_type: - '(?i)phone' - '(?i)(?:wap|wireless)' -# number of SNMP pollers to run in parallel (in netdisco-daemon). +# number of SNMP workers to run in parallel (in netdisco-daemon). # the default is twice the number of CPU cores # ``````````````````````````````````````````````````````````````` #workers: -# pollers: 'AUTO * 2' +# tasks: 'AUTO * 2' # amount parallel DNS resolution for node names # `````````````````````````````````````````````