set snmp driver on macsuck phase workers
This commit is contained in:
@@ -25,13 +25,6 @@ register_worker({ primary => true }, sub {
|
|||||||
return Status->defer("macsuck deferred: $host is not macsuckable")
|
return Status->defer("macsuck deferred: $host is not macsuckable")
|
||||||
unless is_macsuckable_now($device);
|
unless is_macsuckable_now($device);
|
||||||
|
|
||||||
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device);
|
|
||||||
return Status->defer("macsuck failed: could not SNMP connect to $host")
|
|
||||||
unless defined $snmp;
|
|
||||||
|
|
||||||
return Status->done("Skipped macsuck for device $host without layer 2 capability")
|
|
||||||
unless $snmp->has_layer(2);
|
|
||||||
|
|
||||||
return Status->done('Macsuck is able to run.');
|
return Status->done('Macsuck is able to run.');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,15 @@ use Dancer::Plugin::DBIC 'schema';
|
|||||||
use Time::HiRes 'gettimeofday';
|
use Time::HiRes 'gettimeofday';
|
||||||
use Scope::Guard 'guard';
|
use Scope::Guard 'guard';
|
||||||
|
|
||||||
register_worker({ primary => true }, sub {
|
register_worker({ primary => true, driver => 'snmp' }, sub {
|
||||||
my ($job, $workerconf) = @_;
|
my ($job, $workerconf) = @_;
|
||||||
|
|
||||||
my $device = $job->device;
|
my $device = $job->device;
|
||||||
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device);
|
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device)
|
||||||
|
or return Status->defer("macsuck failed: could not SNMP connect to $host");
|
||||||
|
|
||||||
|
return Status->defer("Skipped macsuck for device $host without layer 2 capability")
|
||||||
|
unless $snmp->has_layer(2);
|
||||||
|
|
||||||
# would be possible just to use now() on updated records, but by using this
|
# would be possible just to use now() on updated records, but by using this
|
||||||
# same value for them all, we can if we want add a job at the end to
|
# same value for them all, we can if we want add a job at the end to
|
||||||
|
|||||||
@@ -8,15 +8,16 @@ use App::Netdisco::Transport::SNMP ();
|
|||||||
use Dancer::Plugin::DBIC 'schema';
|
use Dancer::Plugin::DBIC 'schema';
|
||||||
use Time::HiRes 'gettimeofday';
|
use Time::HiRes 'gettimeofday';
|
||||||
|
|
||||||
register_worker({ primary => false }, sub {
|
register_worker({ primary => false, driver => 'snmp' }, sub {
|
||||||
my ($job, $workerconf) = @_;
|
my ($job, $workerconf) = @_;
|
||||||
|
|
||||||
my $device = $job->device;
|
my $device = $job->device;
|
||||||
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device);
|
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device)
|
||||||
|
or return Status->defer("macsuck failed: could not SNMP connect to $host");
|
||||||
|
|
||||||
|
return Status->defer("Skipped macsuck for device $host without layer 2 capability")
|
||||||
|
unless $snmp->has_layer(2);
|
||||||
|
|
||||||
# would be possible just to use now() on updated records, but by using this
|
|
||||||
# same value for them all, we can if we want add a job at the end to
|
|
||||||
# select and do something with the updated set (see set archive, below)
|
|
||||||
my $now = 'to_timestamp('. (join '.', gettimeofday) .')';
|
my $now = 'to_timestamp('. (join '.', gettimeofday) .')';
|
||||||
|
|
||||||
my $cd11_txrate = $snmp->cd11_txrate;
|
my $cd11_txrate = $snmp->cd11_txrate;
|
||||||
|
|||||||
Reference in New Issue
Block a user