|
NAMEpgtop - display PostgreSQL performance info like `top'SYNOPSISpgtop [options]AVAILABILITYThe latest version of pgtop is available from <https://metacpan.org/author/COSIMO> or on github at <https://github.com/cosimo/pgtop>.REQUIREMENTSIn order for pgtop to function properly, you must have the following:* Perl 5.014 or newer * Getopt::Long * DBI and DBD::Pg * Term::ReadKey Most systems are likely to have all of those installed or readily available. And you obviously need access to a PostgreSQL server (version 7.2+) with the necessary security to access the pg_stat* relations. Optional Color SupportIn additon, if you want a color mytop (recommended), install Term::ANSIColor from the CPAN:https://metacpan.org/module/Term::ANSIColor Once you do, pgtop will automatically use it. However, color is not yet working on Windows. Patches welcome. :-) Optional Hi-Res TimingIf you want pgtop to provide more accurate real-time queries-per-second statistics, install the Time::HiRes module from CPAN. pgtop will automatically notice that you have it and use it rather than the standard timing mechanism.Platformspgtop currently is known to work only on Linux. Its `mytop' brother, however, has been reported to work on:* Linux (2.2.x, 2.4.x) ? * FreeBSD (2.2, 3.x, 4.x) ? * Mac OS X ? * BSDI 4.x ? * Solaris 2.x ? * Windows NT 4.x (ActivePerl) ? If you find that it works on another platform, please let us know. Given that it is all Perl code, I expect it to be rather portable to Unix and Unix-like systems. Heck, it might even work on Win32 systems. DESCRIPTIONHelp is always welcome in improving this software. Feel free to contact the author (see "AUTHOR" below) with bug reports, fixes, suggestions, and comments. Additionally "BUGS" will provide a list of things this software is not able to do yet.Having said that, here are the details on how it works and what you can do with it. The Basicspgtop was inspired by mytop (http://mytop.sourceforge.net/), which in turn was inspired by the system monitoring tool top.pgtop will connect to a PostgreSQL server and periodically run queries against the pg_stat* relations and attempt to summarize the information from them in a useful format. WHAT FOLLOWS REFERS TO MYTOPWhat you read from now on has not been revised, and refers to the original utility "mytop".The DisplayThe mytop display screen is really broken into two parts. The top 4 lines (header) contain summary information about your MySQL server. For example, you might see something like:MySQL on localhost (4.0.13-log) up 1+11:13:00 [23:29:11] Queries: 19.3M qps: 160 Slow: 1.0 Se/In/Up/De(%): 00/80/03/17 qps now: 219 Slow qps: 0.0 Threads: 1 ( 1/ 16) 00/74/00/25 Key Efficiency: 99.3% Bps in/out: 30.5k/162.8 Now in/out: 32.7k/ 3.3k The first line identifies the hostname of the server (localhost) and the version of MySQL it is running. The right had side shows the uptime of the MySQL server process in days+hours:minutes:seconds format (much like FreeBSD's top) as well as the current time. The second line displays the total number of queries the server has processed, the average number of queries per second, the number of slow queries, and the percentage of Select, Insert, Update, and Delete queries. The third real-time values. First is the number of queries per second, then the number of slow queries, followed by query precentages (like on the previous line). And the fourth line displays key buffer efficiency (how often keys are read from the buffer rather than disk) and the number of bytes that MySQL has sent and received, both over all and in the last cycle. You can toggle the header by hitting h when running mytop. The second part of the display lists as many threads as can fit on screen. By default they are sorted according to their idle time (least idle first). The display looks like: Id User Host Dbase Time Cmd Query or State -- ---- ---- ----- ---- --- -------------- 61 jzawodn localhost music 0 Query show processlist As you can see, the thread id, username, host from which the user is connecting, database to which the user is connected, number of seconds of idle time, the command the thread is executing, and the query info are all displayed. Often times the query info is what you are really interested in, so it is good to run mytop in an xterm that is wider than the normal 80 columns if possible. The thread display color-codes the threads if you have installed color support. The current color scheme only works well in a window with a dark (like black) background. The colors are selected according to the "Command" column of the display: Query - Yellow Sleep - White Connect - Green Those are purely arbitrary and will be customizable in a future release. If they annoy you just start mytop with the -nocolor flag or adjust your config file appropriately. Argumentsmytop handles long and short command-line arguments. Not all options have both long and short formats, however. The long arguments can start with one or two dashes `-' or `--'. They are shown here with just one.
Command-line arguments will always take precedence over config file options. That happens because the config file is read BEFORE the command-line arguments are applied. Config FileInstead of always using bulky command-line parameters, you can also use a config file in your home directory ("~/.pgtop"). If present, pgtop will read it automatically. It is read before any of your command-line arguments are processed, so your command-line arguments will override directives in the config file.Here is a sample config file "~/.pgtop" which implements the defaults described above. user=root pass= host=localhost db=test delay=5 port=3306 batchmode=0 header=1 color=1 idle=1 Using a config file will help to ensure that your database password isn't visible to users on the command-line. Just make sure that the permissions on "~/.pgtop" are such that others cannot read it (unless you want them to, of course). You may have white space on either side of the "=" in lines of the config file. Shortcut KeysThe following keys perform various actions while mytop is running. Those which have not been implemented are listed as such. They are included to give the user idea of what is coming.
The s key has a command-line counterpart: -s. The h key has two command-line counterparts: -header and -noheader. BUGSProbably many, but "pgtop" is still quite useful.AUTHORpgtop was adapted from mytop and is maintained by Cosimo Streppone ("cosimo@cpan.org").mytop was developed and is maintained by Jeremy D. Zawodny ("Jeremy@Zawodny.com"). If you wish to e-mail me regarding this software, please do! DISCLAIMERThis is certainly not a quality work, but before this crap, there was nothing but pg_stat_* tables. Just like Jeremy, I needed something more immediate and usable, like top.To tell the real truth, I didn't even know about pg_stat tables. :-) There is huge room for improvement! COPYRIGHTCopyright (C) 2005-2020, Cosimo Streppone. Copyright (C) 2000-2001, Jeremy D. Zawodny.MYTOP CREDITSFix a bug. Add a feature. See your name here!Many thanks go to these fine folks:
See the Changes file on the pgtop distribution page for more details on what has changed. LICENSEpgtop is licensed under the GNU General Public License version 2. For the full license information, please visit http://www.gnu.org/copyleft/gpl.htmlPOD ERRORSHey! The above document had some coding errors, which are explained below:
Visit the GSP FreeBSD Man Page Interface. |