From 3e1156df1f9b6b0cbe66af00993c8df0f838bda7 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 8 Apr 2013 22:09:40 +0100 Subject: [PATCH] alter some log levels and messages --- .../App/Netdisco/Daemon/Worker/Interactive.pm | 7 ++-- .../lib/App/Netdisco/Daemon/Worker/Manager.pm | 6 +-- .../lib/App/Netdisco/Daemon/Worker/Poller.pm | 7 ++-- .../lib/App/Netdisco/Util/DiscoverAndStore.pm | 37 ++++++++++++++----- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/Daemon/Worker/Interactive.pm b/Netdisco/lib/App/Netdisco/Daemon/Worker/Interactive.pm index 9a6a8312..37819c3b 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Worker/Interactive.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Worker/Interactive.pm @@ -35,7 +35,8 @@ sub worker_body { my ($status, $log); try { $job->started(scalar localtime); - info sprintf "int (%s): starting job %s at %s", $wid, $jid, $job->started; + info sprintf "int (%s): starting %s job(%s) at %s", + $wid, $target, $jid, $job->started; ($status, $log) = $self->$target($job); } catch { @@ -55,8 +56,8 @@ sub worker_body { sub close_job { my ($self, $job, $status, $log) = @_; my $now = scalar localtime; - info sprintf "int (%s): wrapping up job %s - status %s at %s", - $self->wid, $job->job, $status, $now; + info sprintf "int (%s): wrapping up set_%s job(%s) - status %s at %s", + $self->wid, $job->action, $job->job, $status, $now; try { schema('netdisco')->resultset('Admin') diff --git a/Netdisco/lib/App/Netdisco/Daemon/Worker/Manager.pm b/Netdisco/lib/App/Netdisco/Daemon/Worker/Manager.pm index 20b8fa58..1216b6ad 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Worker/Manager.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Worker/Manager.pm @@ -43,7 +43,7 @@ sub worker_body { my $self = shift; my $wid = $self->wid; my $num_slots = $self->do('num_workers') - or return warning "mgr ($wid): this node has no workers... quitting manager"; + or return debug "mgr ($wid): this node has no workers... quitting manager"; # get some pending jobs my $rs = schema('netdisco')->resultset('Admin') @@ -59,11 +59,11 @@ sub worker_body { # filter for discover_* next unless is_discoverable($job->device); - info sprintf "mgr (%s): job %s is discoverable", $wid, $jid; + debug sprintf "mgr (%s): job %s is discoverable", $wid, $jid; # check for available local capacity next unless $self->do('capacity_for', $job->action); - info sprintf "mgr (%s): processing node has capacity for job %s (%s)", + debug sprintf "mgr (%s): processing node has capacity for job %s (%s)", $wid, $jid, $job->action; # mark job as running diff --git a/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller.pm b/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller.pm index 250c950a..4eefde88 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller.pm @@ -35,7 +35,8 @@ sub worker_body { my ($status, $log); try { $job->started(scalar localtime); - info sprintf "poll (%s): starting job %s at %s", $wid, $jid, $job->started; + info sprintf "poll (%s): starting %s job(%s) at %s", + $wid, $target, $jid, $job->started; ($status, $log) = $self->$target($job); } catch { @@ -55,8 +56,8 @@ sub worker_body { sub close_job { my ($self, $job, $status, $log) = @_; my $now = scalar localtime; - info sprintf "poll (%s): wrapping up job %s - status %s at %s", - $self->wid, $job->job, $status, $now; + info sprintf "poll (%s): wrapping up %s job(%s) - status %s at %s", + $self->wid, $job->action, $job->job, $status, $now; try { schema('netdisco')->resultset('Admin') diff --git a/Netdisco/lib/App/Netdisco/Util/DiscoverAndStore.pm b/Netdisco/lib/App/Netdisco/Util/DiscoverAndStore.pm index 880999ee..d3c67a55 100644 --- a/Netdisco/lib/App/Netdisco/Util/DiscoverAndStore.pm +++ b/Netdisco/lib/App/Netdisco/Util/DiscoverAndStore.pm @@ -46,8 +46,8 @@ sub store_device { my $interfaces = $snmp->interfaces; my $ip_netmask = $snmp->ip_netmask; - # build device interfaces suitable for DBIC - my @interfaces; + # build device aliases suitable for DBIC + my @aliases; foreach my $entry (keys %$ip_index) { my $ip = NetAddr::IP::Lite->new($entry); my $addr = $ip->addr; @@ -57,12 +57,13 @@ sub store_device { next if setting('ignore_private_nets') and $ip->is_rfc1918; my $iid = $ip_index->{$addr}; - my $port = $interfaces->{$iid}; + my $port = $aliases->{$iid}; my $subnet = $ip_netmask->{$addr} ? NetAddr::IP::Lite->new($addr, $ip_netmask->{$addr})->network->cidr : undef; - push @interfaces, { + debug sprintf ' [%s] store_device - aliased as %s', $device->ip, $addr; + push @aliases, { alias => $addr, port => $port, subnet => $subnet, @@ -99,7 +100,7 @@ sub store_device { schema('netdisco')->txn_do(sub { $device->device_ips->delete; $device->update_or_insert; - $device->device_ips->populate(\@interfaces); + $device->device_ips->populate(\@aliases); }); } @@ -139,6 +140,8 @@ sub store_interfaces { my $dev_uptime = $snmp->uptime; if (scalar grep {$_ > $dev_uptime} values %$i_lastchange) { + info sprintf ' [%s] interfaces - device uptime has wrapped - correcting', + $device->ip; $device->uptime( $dev_uptime + 2**32 ); } @@ -148,12 +151,21 @@ sub store_interfaces { my $port = $interfaces->{$entry}; if (not length $port) { - # TODO log message + debug sprintf ' [%s] interfaces - ignoring %s (no port mapping)', + $device->ip, $port; next; } if (scalar grep {$port =~ m/$_/} @{setting('ignore_interfaces') || []}) { - # TODO log message + debug sprintf + ' [%s] interfaces - ignoring %s (%s) (requested in config)', + $device->ip, $entry, $port; + next; + } + + if (exists $i_ignore->{$entry}) { + debug sprintf ' [%s] interfaces - ignoring %s (%s) (%s)', + $device->ip, $entry, $port, $i_type->{$entry}; next; } @@ -168,8 +180,10 @@ sub store_interfaces { else { # uptime wrap less than 5min ago or lastchange > 5min ago # to be on safe side, assume lastchange after counter wrap + debug sprintf + ' [%s] interfaces - correcting LastChange for %s, assuming sysUptime wrap', + $device->ip, $port; $lc += 2**32; - # TODO log message } } } @@ -186,6 +200,7 @@ sub store_interfaces { duplex => $i_duplex->{$entry}, duplex_admin => $i_duplex_admin->{$entry}, stp => $i_stp_state->{$entry}, + type => $i_type->{$entry}, vlan => $i_vlan->{$entry}, pvid => $i_pvid->{$entry}, lastchange => $lc, @@ -228,7 +243,8 @@ sub store_wireless { my $port = $interfaces->{$entry}; if (not length $port) { - # TODO log message + debug sprintf ' [%s] wireless - ignoring %s (no port mapping)', + $device->ip, $port; next; } @@ -252,7 +268,8 @@ sub store_wireless { my $port = $interfaces->{$entry}; if (not length $port) { - # TODO log message + debug sprintf ' [%s] wireless - ignoring %s (no port mapping)', + $device->ip, $port; next; }