mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
limit and sort the config entries the same way as we sort values, based on values
This commit is contained in:
parent
88ba6e86be
commit
02c5c4b6d6
@ -82,17 +82,11 @@ sub print_graph_data() {
|
|||||||
$upper_limit = poll_variables($MYSQL_VARIABLES,"max_connections");
|
$upper_limit = poll_variables($MYSQL_VARIABLES,"max_connections");
|
||||||
|
|
||||||
# Return the values to Munin
|
# Return the values to Munin
|
||||||
my $threads = get_thread_list();
|
my $counts = count_thread_users();
|
||||||
my %counts = ();
|
my %counts = %{$counts};
|
||||||
my ($thread, $user, $count);
|
|
||||||
|
|
||||||
while (($thread, $user) = each %$threads) {
|
|
||||||
$counts{$user} = 0 unless defined($counts{$user});
|
|
||||||
$counts{$user}++;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub valsort {
|
sub valsort {
|
||||||
return $$threads{$a} <=> $$threads{$b};
|
return $counts{$a} <=> $counts{$b};
|
||||||
}
|
}
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
foreach my $user (sort valsort keys(%counts)) {
|
foreach my $user (sort valsort keys(%counts)) {
|
||||||
@ -130,31 +124,31 @@ graph_info The number of current connexions per user.
|
|||||||
graph_category mysql
|
graph_category mysql
|
||||||
graph_total Total
|
graph_total Total
|
||||||
EOM
|
EOM
|
||||||
my $threads = get_thread_list();
|
|
||||||
my %seen = ();
|
my $counts = count_thread_users();
|
||||||
my ($thread, $user);
|
my %counts = %{$counts};
|
||||||
while (($thread, $user) = each %$threads) {
|
my $stacked = 0;
|
||||||
# display user only once
|
|
||||||
if (defined($seen{$user})) {
|
sub valsort {
|
||||||
next;
|
return $counts{$a} <=> $counts{$b};
|
||||||
}
|
}
|
||||||
else {
|
my $i = 0;
|
||||||
print <<EOM;
|
foreach my $user (sort valsort keys(%counts)) {
|
||||||
|
last if $i++ >= $numusers;
|
||||||
|
print <<EOM;
|
||||||
$user.label Connexions for user $user
|
$user.label Connexions for user $user
|
||||||
$user.info Number of connexions used by user $user
|
$user.info Number of connexions used by user $user
|
||||||
EOM
|
EOM
|
||||||
print "$user.draw ";
|
print "$user.draw ";
|
||||||
# if we already printed an entry, make the next ones stacked
|
# if we already printed an entry, make the next ones stacked
|
||||||
if (scalar %seen) {
|
if ($i > 1) {
|
||||||
print "STACK\n";
|
print "STACK\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print "AREA\n";
|
print "AREA\n";
|
||||||
}
|
|
||||||
$seen{$user} = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print <<EOM;
|
print <<EOM;
|
||||||
current.label In Use
|
current.label In Use
|
||||||
current.draw LINE1
|
current.draw LINE1
|
||||||
@ -167,20 +161,20 @@ limit.info The current value of the "max_connections" variable
|
|||||||
EOM
|
EOM
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_thread_list {
|
sub count_thread_users {
|
||||||
my %threads = ();
|
my %counts = ();
|
||||||
my $command = 'mysql -N -B -e "SHOW PROCESSLIST;"';
|
my $command = 'mysql -N -B -e "SHOW PROCESSLIST;"';
|
||||||
open(SERVICE, "$command |")
|
open(SERVICE, "$command |")
|
||||||
or die("Could not execute '$command': $!");
|
or die("Could not execute '$command': $!");
|
||||||
while (<SERVICE>) {
|
while (<SERVICE>) {
|
||||||
my ($threadid, $user) = split "\t";
|
my ($threadid, $user) = split "\t";
|
||||||
next unless ($threadid);
|
next unless ($threadid);
|
||||||
$threads{$threadid} = $user;
|
$counts{$user} = 0 unless defined($counts{$user});
|
||||||
|
$counts{$user}++;
|
||||||
}
|
}
|
||||||
return \%threads;
|
return \%counts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub test_service {
|
sub test_service {
|
||||||
my $return = 1;
|
my $return = 1;
|
||||||
system ("$MYSQLADMIN --version >/dev/null 2>/dev/null");
|
system ("$MYSQLADMIN --version >/dev/null 2>/dev/null");
|
||||||
|
Loading…
Reference in New Issue
Block a user