{"id":13528833,"url":"https://github.com/sjmudd/ps-top","last_synced_at":"2025-04-09T13:05:39.288Z","repository":{"id":23141340,"uuid":"26496513","full_name":"sjmudd/ps-top","owner":"sjmudd","description":"ps-top - a top-like program for MySQL","archived":false,"fork":false,"pushed_at":"2024-06-01T12:11:52.000Z","size":840,"stargazers_count":204,"open_issues_count":0,"forks_count":31,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-10-14T10:23:46.775Z","etag":null,"topics":["mysql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sjmudd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-11T17:43:41.000Z","updated_at":"2024-09-25T21:02:22.000Z","dependencies_parsed_at":"2023-11-11T10:26:07.842Z","dependency_job_id":"daeffd50-08a0-4e37-816b-a25240ce8033","html_url":"https://github.com/sjmudd/ps-top","commit_stats":null,"previous_names":["sjmudd/pstop"],"tags_count":71,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjmudd%2Fps-top","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjmudd%2Fps-top/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjmudd%2Fps-top/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjmudd%2Fps-top/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sjmudd","download_url":"https://codeload.github.com/sjmudd/ps-top/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045231,"owners_count":21038553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mysql"],"created_at":"2024-08-01T07:00:25.745Z","updated_at":"2025-04-09T13:05:39.264Z","avatar_url":"https://github.com/sjmudd.png","language":"Go","funding_links":[],"categories":["分析工具","Go","Analysis"],"sub_categories":[],"readme":"## ps-top\n\nps-top - a top-like program for MySQL\n\nps-top is a program which collects information from MySQL 5.6+'s\nperformance_schema database and uses this information to display\nserver load in real-time. Data is shown by table or filename and\nthe metrics also show how this is split between select, insert,\nupdate or delete activity.  User activity is now shown showing the\nnumber of different hosts that connect with the same username and\nthe activity of those users.  There are also statistics on mutex\nand sql stage timings.\n\n### Installation\n\nInstall each binary by doing:\n`$ go install github.com/sjmudd/ps-top@latest`\n\nCheck the version of go you are using as older versions of GO may\nnot work.\n\nThe sources will be downloaded together with the dependencies and\nthe binary will be built and installed into `$GOPATH/bin/`. If\nthis path is in your `PATH` setting then the program can be run\ndirectly without having to specify any specific path.\n\n### Configuration\n\nSometimes you may want to combine different tables together and show\nthe combined output. A typical example might be if you have lots\nof similarly named tables. Should you want to do this you can\nuse the following configuration file `~/.pstoprc` to hole the\nconfiguration information:\n\n```\n[munge]\n\u003cregexp_match\u003e = \u003creplacement_string\u003e\n_[0-9]{8}$ = _YYYYMMDD\n_[0-9]{6}$ = _YYYYMM\n```\n\n#### MySQL Access\n\nAccess to MySQL can be made by one of the following methods:\n* Default: use a defaults-file named `~/.my.cnf`.\n* use an explicit defaults-file with `--defaults-file=/path/to/.my.cnf`.\n* connect to a host with `--host=somehost --port=999 --user=someuser --password=somepass`, or\n* connect via a socket with `--socket=/path/to/mysql.sock --user=someuser --password=somepass`\n* to avoid the password being stored or provided as a command line\n  argument you can use `--askpass` which will request this from the\n  user on startup\n\nThe user if not specified will default to the contents of `$USER`.\nThe port if not specified will default to 3306.\n\n* If you use the command line option `--use-environment` `ps-top`\nwill look for the credentials in the environment\nvariable `MYSQL_DSN` and connect with that.  This is a GO DSN and\nis expected to be in the format:\n`user:pass@tcp(host:port)/performance_schema` and currently ALL\nfields must be filled in. With a suitable wrapper function this\nallows you to access one of many different servers without making\nthe credentials visible on the command line.\n\nAn example setting could be to use TLS which is not fully supported\nat the moment with command line parameters:\n```\n$ export MYSQL_DSN='user:pass@tcp(host:3306)/performance_schema?tls=skip-verify\u0026allowCleartextPasswords=1'\n$ ps-top\n```\n\n#### MySQL/MariaDB configuration\n\nThe `performance_schema` database **MUST** be enabled for `ps-top` to work.\nBy default on MySQL this is enabled, but on MariaDB \u003e= 10.0.12 it is disabled.\nSo please check your settings. Simply configure in `/etc/my.cnf`:\n\n`performance_schema = 1`\n\nIf you change this setting you'll need to restart MariaDB for it to take\neffect.\n\n### Grants\n\n`ps-top` needs `SELECT` grants to access `performance_schema`\ntables. They will not run if access to the required tables is not\navailable.\n\n`setup_instruments`: To view `mutex_latency` or `stages_latency`\n`ps-top` will try to change the configuration if needed and if you\nhave grants to do this.  If the server is `--read-only` or you do not\nhave sufficient grants to change these tables these views may be empty.\nPior to stopping `ps-top` will restore the `setup_instruments` configuration\nback to its original settings if it had successfully updated the table\nwhen starting up.\n\n### Views\n\n`ps-top` can show 7 different views of data, the views\nare updated every second by default.  The views are named:\n\n* `table_io_latency`: Show activity by table by the time waiting to perform operations on them.\n* `table_io_ops`: Show activity by number of operations MySQL performs on them.\n* `file_io_latency`: Show where MySQL is spending it's time in file I/O.\n* `table_lock_latency`: Show order based on table locks\n* `user_latency`: Show ordering based on how long users are running\nqueries, or the number of connections they have to MySQL. This is\nreally missing a feature in MySQL (see: [bug#75156](http://bugs.mysql.com/75156))\nto provide higher resolution query times than seconds. It gives\nsome info but if the queries are very short then the integer runtime\nin seconds makes the output far less interesting. Total idle time is also\nshown as this gives an indication of perhaps overly long idle queries,\nand the sum of the values here if there's a pile up may be interesting.\n* `mutex_latency`: Show the ordering by mutex latency [1].\n* `stages_latency`: Show the ordering by time in the different SQL query stages [1].\n\nYou can change the polling interval and switch between modes (see below).\n\n[1] See Grants above. These views may appear empty if `setup_instruments` is not\nconfigured correctly.\n\n### Keys\n\nWhen in `ps-top` mode the following keys allow you to navigate around the different ps-top displays or to change it's behaviour.\n\n* h - gives you a help screen.\n* - - reduce the poll interval by 1 second (minimum 1 second)\n* + - increase the poll interval by 1 second\n* q - quit\n* t - toggle between showing the statistics since resetting ps-top started or you explicitly reset them (with 'z') [REL] or showing the statistics as collected from MySQL [ABS].\n* z - reset statistics. That is counters you see are relative to when you \"reset\" statistics.\n* `\u003ctab\u003e` - change display modes between: latency, ops, file I/O, lock, user, mutex, stages and memory modes.\n* left arrow - change to previous screen\n* right arrow - change to next screen\n\n### See also\n\nSee also:\n* [BUGS](https://github.com/sjmudd/ps-top/blob/master/BUGS) currently known issues\n* [NEW_FEATURES](https://github.com/sjmudd/ps-top/blob/master/NEW_FEATURES) which describe things that probably need looking at\n* [screen_samples.txt](https://github.com/sjmudd/ps-top/blob/master/screen_samples.txt) provides some sample output from my own system.\n\n### Incompatible Changes\n\nAs of v1.0.7 ps-stats has been removed.  I never used it and it is simpler\nto remove unused functionality.\n\nAs of v0.5.0 the original utility was renamed from `pstop` which\ncould work in `stdout` _or_ `top` mode into two utilities named\n`ps-top` and `ps-stats`.  This change of name was triggered to avoid\nthe name conflict with the Oracle command pstop(1). See\nhttps://docs.oracle.com/cd/E19683-01/816-0210/6m6nb7mii/index.html.  While\nthe two commands are not related it was felt better to avoid the\nname overload, and while `ps-top` is reasonably young this change\nshould not yet cause too much trouble.\n\n### Contributing\n\nThis program was started as a simple project to allow me to learn\ngo, which I'd been following for a while, but hadn't used in earnest.\nThis probably shows in the code so suggestions on improvement are\nmost welcome.\n\n### Licensing\n\nBSD 2-Clause License\n\n### Feedback\n\nFeedback and patches welcome. I am especially interested in hearing\nfrom you if you are using ps-top, or if you have ideas of how I can\nbetter use other information from the `performance_schema` tables\nto provide a more complete vision of what MySQL is doing or where\nit's busy.  The tool has been used by myself and colleagues and\nhelped quickly identify bottlenecks and problems in several systems.\n\nSimon J Mudd\n\u003csjmudd@pobox.com\u003e\n\n### Code Documenton\n[godoc.org/github.com/sjmudd/ps-top](http://godoc.org/github.com/sjmudd/ps-top)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjmudd%2Fps-top","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsjmudd%2Fps-top","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjmudd%2Fps-top/lists"}