Skip to content
Snippets Groups Projects
Commit 54301a40 authored by Sergey Joseph Ivanov's avatar Sergey Joseph Ivanov
Browse files

Fixes and improvements

1. Tail --follow file in case Poller did not finish yet.
2. Do not tail --follow if Poller crashed.
3. Expose Poller run time and number of hosts and RRDs processed.
parent 81617163
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@ how many of them failed during last cacti run.
my $DEBUG=0;
my $SLEEP=5;
sub handler {
my $self = shift;
......@@ -57,27 +58,54 @@ sub handler {
while (<$log>) {
last if($_ =~ m<^$START>);
}
my ($errors,$datasets) = (0,0);
while (<$log>) {
my ($errors,$items,$hosts,$rrds,$datasets,$complete,$time,$error) = (0,0,0,0,0,0,0.0,'');
until ($complete) {
while (<$log>) {
=pod example of errors reported:
2018/11/02 17:00:05 - SPINE: Poller[1] WARNING: Invalid Response(s), Errors[1] Device[9] Thread[1] DS[903]
=cut
if(/SPINE:\s+Poller\[\d+\]\s+WARNING:.*Errors\[(\d+)\]\s+Device\[(\d+)\].*\s+DS\[([ 0-9,]+)\]/) {
print STDERR "errors: num=$1, Device\[$2], DSes=$3\n" if $DEBUG;
$errors += $1;
}
if(/SPINE:\s+Poller\[\d+\]\s+WARNING:.*Errors\[(\d+)\]\s+Device\[(\d+)\].*\s+DS\[([ 0-9,]+)\]/) {
print STDERR "errors: num=$1, Device\[$2], DSes=$3\n" if $DEBUG;
$errors += $1;
}
=pod example of DSes reported:
2018/11/05 15:00:05 - SPINE: Poller[1] Device[32] TH[1] NOTE: There are '398' Polling Items for this Device
=cut
elsif(/SPINE:\s+Poller\[\d+\]\s+Device\[(\d+)\]\s+TH\[\d+\]\s+NOTE: There are '(\d+)' Polling Items for this Device/) {
$datasets += $2;
print STDERR "There are $2 datasets for Device\[$1\]\n" if $DEBUG;
}
elsif(/SPINE:\s+Poller\[\d+\]\s+Device\[(\d+)\]\s+TH\[\d+\]\s+NOTE: There are '(\d+)' Polling Items for this Device/) {
$hosts += 1;
$items += $2;
print STDERR "There are $2 items for Device\[$1\]\n" if $DEBUG;
}
=pod example of the line to be expected at the end:
2018/11/07 00:00:06 - SYSTEM STATS: Time:5.4350 Method:spine Processes:2 Threads:2 Hosts:56 HostsPerProcess:28 DataSources:9131 RRDsProcessed:3323
=cut
elsif(/\s+SYSTEM STATS:\s+Time:([\d.]*)\s+.*Hosts:(\d+)\s+.*DataSources:(\d+)\s+.*RRDsProcessed:(\d+)/) {
($time,$hosts,$datasets,$rrds,$complete) = ($1,$2,$3,$4,1);
print STDERR "SYSTEM STATS: time=$time, hosts=$hosts, datasources=$datasets, rrds=$rrds\n" if $DEBUG;
}
=pod example of the failure line to be expected at the end:
2018/11/07 12:30:07 - PHPSVR ERROR: Input Expected, Script Server Terminating
=cut
elsif(/\s+PHPSVR ERROR:.*Script Server Terminating/) {
chomp;
($time,$complete,$error) = ($SPAN,1,$_);
print STDERR "ERROR: $_" if $DEBUG;
}
}
if (not $complete) {
sleep $SLEEP;
$log->clearerr();
}
}
close $log;
return {
"datasets" => [$datasets,"i"],
"errors" => [$errors, "i"],
"time" => [$time, "n"],
"hosts" => [$hosts, "i"],
"rrds" => [$rrds, "i"],
"items" => [$items, "i"],
"datasets" => [$datasets,"i"],
"errors" => [$errors, "i"],
"error" => [$error, "s"],
};
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment