Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit a44ae84

Browse files
author
Brice Figureau
committed
Small refactoring to group binlogs computations
1 parent 12dbe36 commit a44ae84

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

mysql-snmp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ sub fetch_mysql_data {
744744

745745
# Older versions of MySQL may not have the File_size column in the
746746
# results of the command.
747-
if (exists($newrow{'file_size'})) {
747+
if (exists($newrow{'file_size'}) && $newrow{'file_size'} > 0) {
748748
push(@binlogs, $newrow{'file_size'});
749749
}
750750
else {
@@ -753,6 +753,13 @@ sub fetch_mysql_data {
753753
}
754754
}
755755

756+
if (scalar @binlogs) {
757+
$status{'binary_log_space'} = 0;
758+
foreach my $log (@binlogs) {
759+
$status{'binary_log_space'} += $log;
760+
}
761+
}
762+
756763
# Get SHOW INNODB STATUS and extract the desired metrics from it.
757764
if ($opt{innodb} && $status{'have_innodb'} eq 'YES') {
758765
my $innodb_array = $dbh->selectall_arrayref("SHOW /*!50000 ENGINE*/ INNODB STATUS",{Slice => {}});
@@ -822,13 +829,6 @@ sub fetch_mysql_data {
822829
}
823830
}
824831

825-
if (scalar @binlogs) {
826-
$status{'binary_log_space'} = 0;
827-
foreach my $log (@binlogs) {
828-
$status{'binary_log_space'} += $log;
829-
}
830-
}
831-
832832
$dbh->disconnect();
833833

834834
my %trans;

0 commit comments

Comments
 (0)