mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-16 08:17:20 +00:00
Several corrections as per Daniel and Baron's feedback.
Still TODO: Attributes still have a single method that doubles as a getter and setter. The constructor for Diskstats is still weird -- A tad more stricter than it should be, if anything. ->print_rest is still rest, even though that's hardly memorable, mostly because of a lack of ideas on what to rename it. The main loop in the Menu is still a while (1). As a nice perk, it's nearly twice as fast now! It also adds a _very_ experimental --memory-for-speed argument, which turns on memoization for the current biggest bottleneck.
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
{
|
||||
# ###########################################################################
|
||||
# This is a combination of modules and programs in one -- a runnable module.
|
||||
# http://www.perl.com/pub/a/2006/07/13/lightning-articles.html?page=last
|
||||
# Or, look it up in the Camel book on pages 642 and 643 in the 3rd edition.
|
||||
#
|
||||
# Check at the end of this package for the call to main() which actually runs
|
||||
# the program.
|
||||
# ###########################################################################
|
||||
package pt_diskstats;
|
||||
|
||||
use strict;
|
||||
@@ -17,27 +25,36 @@ local $SIG{__DIE__} = sub {
|
||||
} if MKDEBUG;
|
||||
|
||||
sub main {
|
||||
shift;
|
||||
local @ARGV = @_; # set global ARGV for this package
|
||||
|
||||
# ########################################################################
|
||||
# Get configuration information.
|
||||
# ########################################################################
|
||||
my $o = OptionParser->new( file => __FILE__ );
|
||||
my $o = new OptionParser file => __FILE__;
|
||||
$o->get_specs();
|
||||
$o->get_opts();
|
||||
|
||||
# Interactive mode. Delegate to Diskstats::Menu
|
||||
return DiskstatsMenu->run_interactive( o => $o, filename => $ARGV[0] );
|
||||
my $diskstats = new DiskstatsMenu;
|
||||
|
||||
# Interactive mode. Delegate to DiskstatsMenu::run_interactive
|
||||
return $diskstats->run_interactive( OptionParser => $o, filename => $ARGV[0] );
|
||||
}
|
||||
|
||||
# Somewhat important if STDOUT is tied to a terminal.
|
||||
END { close STDOUT or die "Couldn't close stdout: $OS_ERROR" }
|
||||
|
||||
__PACKAGE__->main(@ARGV) unless caller;
|
||||
# ############################################################################
|
||||
# Run the program.
|
||||
# ############################################################################
|
||||
if ( !caller ) { exit main(@ARGV); }
|
||||
|
||||
1;
|
||||
}
|
||||
|
||||
# #############################################################################
|
||||
# Documentation.
|
||||
# #############################################################################
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
@@ -247,6 +264,12 @@ type: int
|
||||
|
||||
When in interactive mode, stop after N samples.
|
||||
|
||||
=item --redisplay-interval
|
||||
|
||||
type: int; default: 1
|
||||
|
||||
When in interactive mode, wait N seconds before printing to the screen.
|
||||
|
||||
=item --interval
|
||||
|
||||
type: int; default: 1
|
||||
@@ -257,6 +280,10 @@ Sample /proc/diskstats every N seconds.
|
||||
|
||||
Show rows with all zero values.
|
||||
|
||||
=item --memory-for-speed
|
||||
|
||||
XXX TODO INTERNAL yadda
|
||||
|
||||
=item --help
|
||||
|
||||
Show help and exit.
|
||||
@@ -320,7 +347,7 @@ Replace C<TOOL> with the name of any tool.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Baron Schwartz
|
||||
Baron Schwartz, Brian Fraser, and Daniel Nichter
|
||||
|
||||
=head1 ABOUT PERCONA TOOLKIT
|
||||
|
||||
|
Reference in New Issue
Block a user