* initial work * initial work * initial work * some fixes for time and Layer3 weird spec * store again the snapshot after update for specific * resolve the enums * monkeypatch SNMP::translateObj to avoid hardware exception on macOS * only save cache to db in the late phase worker * no need to check for cache on transport, can just go ahead and try * use database only for oidmap instead of netdisco-mibs * rewrite device snapshot to gather loaded mib leafs only * remove old walker code from snapshot worker * allow snmp browser to work without snapshot * only store snapshot leafs which the device responded on * refactor to separate snapshot work from snmp transport work * refactor to separate snapshot work from snmp transport work * allow typeahead on MIB qualified leafs * fixes for snmpwalk input after previous refactor * add the extra stuff SNMP::Info device class uses into snapshot * better width for snmp search box * fix css for snmp options * add spinner while snmp loading * add spinner while snmp loading * add spinner while snmp loading * support SNMP::Info device class or named MIBs as extra on snapshot * add final tidy and bug fix
		
			
				
	
	
		
			35 lines
		
	
	
		
			979 B
		
	
	
	
		
			Perl
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			979 B
		
	
	
	
		
			Perl
		
	
	
	
	
	
package App::Netdisco::Worker::Plugin::Discover::Snapshot;
 | 
						|
 | 
						|
use Dancer ':syntax';
 | 
						|
use Dancer::Plugin::DBIC 'schema';
 | 
						|
 | 
						|
use App::Netdisco::Worker::Plugin;
 | 
						|
use App::Netdisco::Transport::SNMP ();
 | 
						|
use App::Netdisco::Util::Snapshot 'dump_cache_to_browserdata';
 | 
						|
 | 
						|
use Storable 'nfreeze';
 | 
						|
use MIME::Base64 'encode_base64';
 | 
						|
 | 
						|
use aliased 'App::Netdisco::Worker::Status';
 | 
						|
 | 
						|
register_worker({ phase => 'late' }, sub {
 | 
						|
  my ($job, $workerconf) = @_;
 | 
						|
  my $device = $job->device;
 | 
						|
 | 
						|
  my $snmp = App::Netdisco::Transport::SNMP->reader_for($device)
 | 
						|
    or return Status->defer("discover failed: could not SNMP connect to $device");
 | 
						|
 | 
						|
  return unless $device->in_storage
 | 
						|
    and not $device->oids->count and $snmp->offline;
 | 
						|
 | 
						|
  dump_cache_to_browserdata( $device, $snmp );
 | 
						|
 | 
						|
  my $frozen = encode_base64( nfreeze( $snmp->cache ) );
 | 
						|
  $device->update_or_create_related('snapshot', { cache => $frozen });
 | 
						|
 | 
						|
  return Status
 | 
						|
    ->info(sprintf ' [%s] discover - oids and cache stored', $device);
 | 
						|
});
 | 
						|
 | 
						|
true;
 |