Skip to content

Commit

Permalink
Merge pull request #64 from XavierBerger/hotfix
Browse files Browse the repository at this point in the history
Fix issue #63 - multipages issue.
  • Loading branch information
XavierBerger committed Oct 18, 2014
2 parents ec83554 + 4eb5e9d commit 935faa3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.9
2.9.1
24 changes: 15 additions & 9 deletions rpimonitor/rpimonitord
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ sub new
$this->Debug(3,"");
$this->{'rrd'}=();
$this->{'daemon'}->{'confFiles'} = [];
$this->{'counter'}->{'static'} = 0;
$this->{'counter'}->{'dynamic'} = 0;
$this->{'counter'}->{'status'} = 0;
$this->{'counter'}->{'statistics'} = 0;
#$this->{'counter'}->{'static'} = 0;
#$this->{'counter'}->{'dynamic'} = 0;
#$this->{'counter'}->{'status'} = 0;
#$this->{'counter'}->{'statistics'} = 0;
return $this;
}

Expand Down Expand Up @@ -145,7 +145,7 @@ sub LoadFile
{
my $this = shift;
my $confFile = shift;
my $dict;
my @dict;
$this->Debug(2,"Loading file: $confFile");

open ( FILE, $confFile)
Expand All @@ -161,6 +161,7 @@ sub LoadFile
my $current;
my $next;
my $root;
my $page = 0; # page = 0 for static and dynamic
while (scalar(@leaves) > 0) { # While @leaves contains data
$current ||= shift (@leaves); # If root is empty, shift the first element of @leaves to $current
$root ||= $current;
Expand All @@ -178,7 +179,12 @@ sub LoadFile
} else { # If $next is not an integer -> We are in a hash
if ($current =~ /^\d+$/) { # If $current is an integer -> we are in an array
my $index = $current;


if ( ($previous eq 'status' ) ||
($previous eq 'statistics' ) )
{
$page=$current;
}
# Manage per file indexes unicity
if ( ($root eq "static") ||
($root eq "dynamic") ||
Expand All @@ -187,11 +193,11 @@ sub LoadFile
($previous eq "content") ) )
{
# If $index is not in $dict, add it with counter++
if ( ! $dict->{$root}[$current] )
if ( ! $dict[$page]->{$root}[$current] )
{
$dict->{$root}[$current] = ++$this->{'counter'}->{$root};
$dict[$page]->{$root}[$current] = ++$this->{'counter'}[$page]->{$root};
}
$index = $dict->{$root}[$current];
$index = $dict[$page]->{$root}[$current];
}

@{$tree}[$index-1] ||= {}; # If the branch is not an array, create an empty hash
Expand Down

0 comments on commit 935faa3

Please sign in to comment.