alter some log levels and messages

This commit is contained in:
Oliver Gorwits
2013-04-08 22:09:40 +01:00
parent e7ea92920f
commit 3e1156df1f
4 changed files with 38 additions and 19 deletions

View File

@@ -35,7 +35,8 @@ sub worker_body {
my ($status, $log); my ($status, $log);
try { try {
$job->started(scalar localtime); $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); ($status, $log) = $self->$target($job);
} }
catch { catch {
@@ -55,8 +56,8 @@ sub worker_body {
sub close_job { sub close_job {
my ($self, $job, $status, $log) = @_; my ($self, $job, $status, $log) = @_;
my $now = scalar localtime; my $now = scalar localtime;
info sprintf "int (%s): wrapping up job %s - status %s at %s", info sprintf "int (%s): wrapping up set_%s job(%s) - status %s at %s",
$self->wid, $job->job, $status, $now; $self->wid, $job->action, $job->job, $status, $now;
try { try {
schema('netdisco')->resultset('Admin') schema('netdisco')->resultset('Admin')

View File

@@ -43,7 +43,7 @@ sub worker_body {
my $self = shift; my $self = shift;
my $wid = $self->wid; my $wid = $self->wid;
my $num_slots = $self->do('num_workers') 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 # get some pending jobs
my $rs = schema('netdisco')->resultset('Admin') my $rs = schema('netdisco')->resultset('Admin')
@@ -59,11 +59,11 @@ sub worker_body {
# filter for discover_* # filter for discover_*
next unless is_discoverable($job->device); 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 # check for available local capacity
next unless $self->do('capacity_for', $job->action); 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; $wid, $jid, $job->action;
# mark job as running # mark job as running

View File

@@ -35,7 +35,8 @@ sub worker_body {
my ($status, $log); my ($status, $log);
try { try {
$job->started(scalar localtime); $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); ($status, $log) = $self->$target($job);
} }
catch { catch {
@@ -55,8 +56,8 @@ sub worker_body {
sub close_job { sub close_job {
my ($self, $job, $status, $log) = @_; my ($self, $job, $status, $log) = @_;
my $now = scalar localtime; my $now = scalar localtime;
info sprintf "poll (%s): wrapping up job %s - status %s at %s", info sprintf "poll (%s): wrapping up %s job(%s) - status %s at %s",
$self->wid, $job->job, $status, $now; $self->wid, $job->action, $job->job, $status, $now;
try { try {
schema('netdisco')->resultset('Admin') schema('netdisco')->resultset('Admin')

View File

@@ -46,8 +46,8 @@ sub store_device {
my $interfaces = $snmp->interfaces; my $interfaces = $snmp->interfaces;
my $ip_netmask = $snmp->ip_netmask; my $ip_netmask = $snmp->ip_netmask;
# build device interfaces suitable for DBIC # build device aliases suitable for DBIC
my @interfaces; my @aliases;
foreach my $entry (keys %$ip_index) { foreach my $entry (keys %$ip_index) {
my $ip = NetAddr::IP::Lite->new($entry); my $ip = NetAddr::IP::Lite->new($entry);
my $addr = $ip->addr; my $addr = $ip->addr;
@@ -57,12 +57,13 @@ sub store_device {
next if setting('ignore_private_nets') and $ip->is_rfc1918; next if setting('ignore_private_nets') and $ip->is_rfc1918;
my $iid = $ip_index->{$addr}; my $iid = $ip_index->{$addr};
my $port = $interfaces->{$iid}; my $port = $aliases->{$iid};
my $subnet = $ip_netmask->{$addr} my $subnet = $ip_netmask->{$addr}
? NetAddr::IP::Lite->new($addr, $ip_netmask->{$addr})->network->cidr ? NetAddr::IP::Lite->new($addr, $ip_netmask->{$addr})->network->cidr
: undef; : undef;
push @interfaces, { debug sprintf ' [%s] store_device - aliased as %s', $device->ip, $addr;
push @aliases, {
alias => $addr, alias => $addr,
port => $port, port => $port,
subnet => $subnet, subnet => $subnet,
@@ -99,7 +100,7 @@ sub store_device {
schema('netdisco')->txn_do(sub { schema('netdisco')->txn_do(sub {
$device->device_ips->delete; $device->device_ips->delete;
$device->update_or_insert; $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; my $dev_uptime = $snmp->uptime;
if (scalar grep {$_ > $dev_uptime} values %$i_lastchange) { 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 ); $device->uptime( $dev_uptime + 2**32 );
} }
@@ -148,12 +151,21 @@ sub store_interfaces {
my $port = $interfaces->{$entry}; my $port = $interfaces->{$entry};
if (not length $port) { if (not length $port) {
# TODO log message debug sprintf ' [%s] interfaces - ignoring %s (no port mapping)',
$device->ip, $port;
next; next;
} }
if (scalar grep {$port =~ m/$_/} @{setting('ignore_interfaces') || []}) { 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; next;
} }
@@ -168,8 +180,10 @@ sub store_interfaces {
else { else {
# uptime wrap less than 5min ago or lastchange > 5min ago # uptime wrap less than 5min ago or lastchange > 5min ago
# to be on safe side, assume lastchange after counter wrap # 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; $lc += 2**32;
# TODO log message
} }
} }
} }
@@ -186,6 +200,7 @@ sub store_interfaces {
duplex => $i_duplex->{$entry}, duplex => $i_duplex->{$entry},
duplex_admin => $i_duplex_admin->{$entry}, duplex_admin => $i_duplex_admin->{$entry},
stp => $i_stp_state->{$entry}, stp => $i_stp_state->{$entry},
type => $i_type->{$entry},
vlan => $i_vlan->{$entry}, vlan => $i_vlan->{$entry},
pvid => $i_pvid->{$entry}, pvid => $i_pvid->{$entry},
lastchange => $lc, lastchange => $lc,
@@ -228,7 +243,8 @@ sub store_wireless {
my $port = $interfaces->{$entry}; my $port = $interfaces->{$entry};
if (not length $port) { if (not length $port) {
# TODO log message debug sprintf ' [%s] wireless - ignoring %s (no port mapping)',
$device->ip, $port;
next; next;
} }
@@ -252,7 +268,8 @@ sub store_wireless {
my $port = $interfaces->{$entry}; my $port = $interfaces->{$entry};
if (not length $port) { if (not length $port) {
# TODO log message debug sprintf ' [%s] wireless - ignoring %s (no port mapping)',
$device->ip, $port;
next; next;
} }