Created
March 13, 2012 22:01
-
-
Save Kagee/2032045 to your computer and use it in GitHub Desktop.
summarize_binlog.pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
if ($#ARGV < 0 ) { | |
print "usage: $0 <path> [path...]\n"; | |
exit; | |
} | |
my $file = $ARGV[0]; | |
# Check that the path exsists, is a file, and is readable | |
if((-e $file) && (-f $file) && (-r $file)) { | |
open F, "mysqlbinlog $file |" or print "couldn't read from mysqlbinlog $file\n" && exit; | |
my $queries = 0; | |
while (<F>) { | |
if (my ($found) = m/(^#.*Rotate to)/o) { | |
print "Startdato: ", (substr $found, 1, 6), "\n"; | |
} | |
if (my ($found) = m/(^#.*Start: binlog)/o) { | |
print "Sluttdato: ", (substr $found, 1, 6), "\n"; | |
} | |
if (my ($found) = m/(^#.*Query)/o) { | |
$queries++; | |
} | |
} | |
close F; | |
print "$queries queries found\n"; | |
} else { | |
print "Does not exsist, is not a file, or ir unreadable: $file\n"; | |
exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment