diff --git a/plugins/mysql/mysql_connections_per_user b/plugins/mysql/mysql_connections_per_user index 9ec479da..d0c8f98e 100755 --- a/plugins/mysql/mysql_connections_per_user +++ b/plugins/mysql/mysql_connections_per_user @@ -82,17 +82,11 @@ sub print_graph_data() { $upper_limit = poll_variables($MYSQL_VARIABLES,"max_connections"); # Return the values to Munin - my $threads = get_thread_list(); - my %counts = (); - my ($thread, $user, $count); - - while (($thread, $user) = each %$threads) { - $counts{$user} = 0 unless defined($counts{$user}); - $counts{$user}++; - } + my $counts = count_thread_users(); + my %counts = %{$counts}; sub valsort { - return $$threads{$a} <=> $$threads{$b}; + return $counts{$a} <=> $counts{$b}; } my $i = 0; foreach my $user (sort valsort keys(%counts)) { @@ -130,31 +124,31 @@ graph_info The number of current connexions per user. graph_category mysql graph_total Total EOM -my $threads = get_thread_list(); -my %seen = (); -my ($thread, $user); -while (($thread, $user) = each %$threads) { - # display user only once - if (defined($seen{$user})) { - next; - } - else { - print < $counts{$b}; +} +my $i = 0; +foreach my $user (sort valsort keys(%counts)) { + last if $i++ >= $numusers; + print < 1) { + print "STACK\n"; + } + else { + print "AREA\n"; } - } + print <) { my ($threadid, $user) = split "\t"; next unless ($threadid); - $threads{$threadid} = $user; + $counts{$user} = 0 unless defined($counts{$user}); + $counts{$user}++; } - return \%threads; + return \%counts; } - sub test_service { my $return = 1; system ("$MYSQLADMIN --version >/dev/null 2>/dev/null");