Documentation
¶
Overview ¶
Command ps-top collects performance_schema metrics on one interval and shows table views on another, full screen (the TUI, see internal/tui) or printed as text with --batch:
ps-top # the TUI: one view at a time, h for the keys ps-top --interval=5s --window=30s # redraw every 5 s, differences over 30 s ps-top --batch # all views, every --interval, until interrupted ps-top --batch --interval=10s --count=6 # every 10 s, 6 outputs ps-top --batch --view=table_io_latency:current,file_io_latency ps-top --batch --view=user_latency --limit=10 # top 10 lines ps-top --batch --totals # totals lines only ps-top --batch --anonymise # schema1.table2, user1: output to share ps-top --batch --database-filter=shop,crm # only the shop and crm databases
The first output shows values up to now, as vmstat's first line does, the following ones each view in its style (by default the difference over --window, or current values).
File I/O's table names are renamed by the munge section of ~/.pstoprc, if it exists (see internal/munge), so tables named alike show as one row:
[munge]
_[0-9]{8}$ = _YYYYMMDD # shop.orders_20260101 shows as shop.orders_YYYYMMDD
Connecting (see internal/connect):
ps-top --batch # ~/.my.cnf if it exists, else $USER on 127.0.0.1:3306 ps-top --batch --defaults-file=/path/to/my.cnf ps-top --batch --host=db1 --port=3307 --user=app --askpass ps-top --batch --socket=/run/mysqld/mysqld.sock ps-top --batch --dsn='app:secret@tcp(db1:3306)/?interpolateParams=true' MYSQL_DSN='app:secret@tcp(db1:3306)/?interpolateParams=true' ps-top --batch --use-environment
A DSN given with --dsn or MYSQL_DSN is used as given. The DSN built from the option file and flags sets interpolateParams=true, so a query with arguments is one round trip, not a prepared statement's three: add it to a DSN given.
Logging (none by default):
ps-top --log # info to ./ps-top.log ps-top --log=debug # debug to ./ps-top.log ps-top --log-file=/tmp/p.log # info to /tmp/p.log ps-top --log=help # list the levels
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
anonymise
Package anonymise replaces the names of objects, such as schemas, tables and users, with anonymous equivalents, so output can be shared without showing them.
|
Package anonymise replaces the names of objects, such as schemas, tables and users, with anonymous equivalents, so output can be shared without showing them. |
|
app
Package app wires the program: it probes the server, builds the metrics, starts the collector, and presents views on its own interval.
|
Package app wires the program: it probes the server, builds the metrics, starts the collector, and presents views on its own interval. |
|
collector
Package collector collects every metric on its own ticker, one ring of snapshots per metric, and answers requests for the snapshots a metric type needs: the latest for CurrentValue, the start and end of a window for DifferenceValues.
|
Package collector collects every metric on its own ticker, one ring of snapshots per metric, and answers requests for the snapshots a metric type needs: the latest for CurrentValue, the start and end of a window for DifferenceValues. |
|
connect
Package connect works out the DSN ps-top connects with, from its command line connection options.
|
Package connect works out the DSN ps-top connects with, from its command line connection options. |
|
derive
Package derive computes what to display from the snapshots of a metric type: for DifferenceValues the difference between a start and an end snapshot (Window), for CurrentValue one snapshot's values as they are (Current).
|
Package derive computes what to display from the snapshots of a metric type: for DifferenceValues the difference between a start and an end snapshot (Window), for CurrentValue one snapshot's values as they are (Current). |
|
fakesql
Package fakesql is a database/sql driver for tests.
|
Package fakesql is a database/sql driver for tests. |
|
formatter
Package formatter turns values into display strings: times in picoseconds, counts, amounts and percentages.
|
Package formatter turns values into display strings: times in picoseconds, counts, amounts and percentages. |
|
logging
Package logging sets up slog's default logger from the --log and --log-file flags.
|
Package logging sets up slog's default logger from the --log and --log-file flags. |
|
mapper
Package mapper turns a raw key, as collected, into the key a view shows.
|
Package mapper turns a raw key, as collected, into the key a view shows. |
|
metric
Package metric describes the shape of a collected metric: its value columns, how each behaves over time, and the metric types (current values or a difference) its views can ask for.
|
Package metric describes the shape of a collected metric: its value columns, how each behaves over time, and the metric types (current values or a difference) its views can ask for. |
|
metrics
Package metrics lists the metrics the program collects, and reads one snapshot of a metric from the server.
|
Package metrics lists the metrics the program collects, and reads one snapshot of a metric from the server. |
|
metrics/fileio
Package fileio is file I/O per file name: operation counts, wait times and bytes, in total and per operation, from file_summary_by_instance.
|
Package fileio is file I/O per file name: operation counts, wait times and bytes, in total and per operation, from file_summary_by_instance. |
|
metrics/memory
Package memory is memory in use per instrument, from memory_summary_global_by_event_name: current and highest allocation counts and bytes, and the number of allocations and frees.
|
Package memory is memory in use per instrument, from memory_summary_global_by_event_name: current and highest allocation counts and bytes, and the number of allocations and frees. |
|
metrics/stages
Package stages is time spent per statement execution stage, from events_stages_summary_global_by_event_name.
|
Package stages is time spent per statement execution stage, from events_stages_summary_global_by_event_name. |
|
metrics/synchwaits
Package synchwaits is waits on server mutexes and InnoDB sx-locks per instrument, from events_waits_summary_global_by_event_name.
|
Package synchwaits is waits on server mutexes and InnoDB sx-locks per instrument, from events_waits_summary_global_by_event_name. |
|
metrics/tableio
Package tableio is table I/O per table: operation counts and wait times, in total and per operation, from table_io_waits_summary_by_table.
|
Package tableio is table I/O per table: operation counts and wait times, in total and per operation, from table_io_waits_summary_by_table. |
|
metrics/tablelocks
Package tablelocks is table lock wait time per table, in total and per lock type, from table_lock_waits_summary_by_table.
|
Package tablelocks is table lock wait time per table, in total and per lock type, from table_lock_waits_summary_by_table. |
|
metrics/userlatency
Package userlatency is activity per user from the processlist.
|
Package userlatency is activity per user from the processlist. |
|
munge
Package munge renames table names by the rules of the munge section of ~/.pstoprc, as v1 does, so that tables named alike show as one row.
|
Package munge renames table names by the rules of the munge section of ~/.pstoprc, as v1 does, so that tables named alike show as one row. |
|
presenter
Package presenter turns the difference over a window into table lines.
|
Package presenter turns the difference over a window into table lines. |
|
probe
Package probe finds out once, at connect, what the server provides: flavour, version, which metric queries run, which tables may be updated, and the values of named variables and status counters.
|
Package probe finds out once, at connect, what the server provides: flavour, version, which metric queries run, which tables may be updated, and the values of named variables and status counters. |
|
query
Package query runs a SQL statement and hands each result row to the caller, with each column scanned by its declared type.
|
Package query runs a SQL statement and hands each result row to the caller, with each column scanned by its declared type. |
|
registry
Package registry is the metrics registry: what ps-top's own pipeline does, so its costs can be seen.
|
Package registry is the metrics registry: what ps-top's own pipeline does, so its costs can be seen. |
|
setupinstruments
Package setupinstruments makes sure the performance_schema instruments some views need are enabled and timed, and puts back what it changed.
|
Package setupinstruments makes sure the performance_schema instruments some views need are enabled and timed, and puts back what it changed. |
|
snapshot
Package snapshot holds the transformed entries returned by a single query taken at time Snapshot.Time, indexed by key.
|
Package snapshot holds the transformed entries returned by a single query taken at time Snapshot.Time, indexed by key. |
|
store
Package store keeps the most recent snapshots of one metric in a ring buffer.
|
Package store keeps the most recent snapshots of one metric in a ring buffer. |
|
transform
Package transform turns raw query entries into snapshot entries, and maps the keys of a snapshot for a view.
|
Package transform turns raw query entries into snapshot entries, and maps the keys of a snapshot for a view. |
|
tui
Package tui is ps-top's terminal interface: a Bubble Tea program that draws one view at a time, full screen, and redraws it every interval.
|
Package tui is ps-top's terminal interface: a Bubble Tea program that draws one view at a time, full screen, and redraws it every interval. |
|
test
|
|
|
integration/load/loadgen
command
loadgen is a sysbench-alternative load generator using go-sql-driver/mysql, which supports caching_sha2_password natively.
|
loadgen is a sysbench-alternative load generator using go-sql-driver/mysql, which supports caching_sha2_password natively. |