\n";
}
}
}
my $single = sub {
my $role = shift;
return @{$role{$role}} == 1;
};
my $slaveroleperc = sub {
my $sid = shift;
my $role = shift;
return sprintf("%0.1f%%", 100*$weights{$sid}->{$role}->{'curr'}/($roletweight{$role}||1));
};
my $dumpslaves = sub
{
my $mid = shift;
my $depth = shift;
my $rec = shift;
return unless $slaves{$mid};
my $indent = " " x ($depth*5);
foreach my $sid (sort { $#{$slaves{$a}} <=> $#{$slaves{$b}} } @{$slaves{$mid}}) {
my $db = $dbinfo{$sid};
$p->("
$indent$db->{'name'} ($sid)
");
foreach my $role (sort keys %{$weights{$sid}}) {
my $r = $weights{$sid}->{$role};
my $col;
if ($r->{'norm'} != $r->{'curr'}) {
$col = "bgcolor='#800000'";
}
$p->("
$indent$role
");
$p->("
");
$p->("
");
$p->("
" . $slaveroleperc->($sid, $role) . "
");
$p->("
");
}
$rec->($sid, $depth+1, $rec);
}
};
my $dumprole = sub
{
my $role = shift;
return if $single->($role);
$p->("
$role
");
foreach my $sid (sort { $weights{$b}->{$role}->{'curr'} <=> $weights{$a}->{$role}->{'curr'} } @{$role{$role}})
{
my $r = $weights{$sid}->{$role};
my $col;
$col = "bgcolor='#800000'" if $r->{'norm'} != $r->{'curr'};
$p->("