myps

command module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2020 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

myps

Like pgrep and pkill, grep MySQL processlist and kill threads.

terminal

Example

grep by TIME

$ myps grep --duration 0
ID:142  USER:root       HOST:localhost:59393    DB:     COMMAND:Query   TIME:57 STATE:User sleep        INFO:select  sleep(3600)
ID:150  USER:root       HOST:localhost:59814    DB:     COMMAND:Sleep   TIME:2  STATE:  INFO:
ID:145  USER:root       HOST:localhost:59800    DB:     COMMAND:Query   TIME:13 STATE:User sleep        INFO:select sleep(360)

grep by TIME and Query

$ myps grep --duration 10 --info 'select%'
ID:142  USER:root       HOST:localhost:59393    DB:     COMMAND:Query   TIME:86 STATE:User sleep        INFO:select  sleep(3600)
ID:145  USER:root       HOST:localhost:59800    DB:     COMMAND:Query   TIME:42 STATE:User sleep        INFO:select sleep(360)

and kill them

$ myps kill --duration 10 --info 'select%'
KILLED:142      USER:root       HOST:localhost:59393    DB:     COMMAND:Query   TIME:129        STATE:User sleep        INFO:select  sleep(3600)
KILLED:145      USER:root       HOST:localhost:59800    DB:     COMMAND:Query   TIME:85 STATE:User sleep        INFO:select sleep(360)

Usage

$ ./myps -h
Usage:
  myps [OPTIONS] <grep | kill>

Help Options:
  -h, --help  Show this help message

Available commands:
  grep
  kill
grep
Usage:
  myps [OPTIONS] grep [grep-OPTIONS]

Help Options:
  -h, --help                     Show this help message

[grep command options]
          --mysql-host=          Hostname
          --mysql-port=          Port
          --mysql-user=          Username
          --mysql-password=      Password
          --mysql-socket=        path to mysql listen sock
          --mysql-timeout=       Timeout to connect mysql (default: 30s)
          --defaults-extra-file= path to defaults-extra-file
      -t, --time=                display/kill process only >= time
      -u, --user=                display/kill process of user name
      -d, --db=                  display/kill process of db name. % wildcard allowed
      -c, --command=             display/kill process of command. % wildcard allowed
      -s, --state=               display/kill process of state. % wildcard allowed
      -i, --info=                display/kill process of info(query). % wildcard allowed
      -D, --debug                Display debug
      -f, --full                 Display query all (like show full processlist)
kill
Usage:
  myps [OPTIONS] kill [kill-OPTIONS]

Help Options:
  -h, --help                     Show this help message

[kill command options]
          --mysql-host=          Hostname
          --mysql-port=          Port
          --mysql-user=          Username
          --mysql-password=      Password
          --mysql-socket=        path to mysql listen sock
          --mysql-timeout=       Timeout to connect mysql (default: 30s)
          --defaults-extra-file= path to defaults-extra-file
      -t, --time=                display/kill process only >= time
      -u, --user=                display/kill process of user name
      -d, --db=                  display/kill process of db name. % wildcard allowed
      -c, --command=             display/kill process of command. % wildcard allowed
      -s, --state=               display/kill process of state. % wildcard allowed
      -i, --info=                display/kill process of info(query). % wildcard allowed
      -D, --debug                Display debug
      -f, --full                 Display query all (like show full processlist)
      -y, --yes                  Skip confirmation prompt to kill threads

LIMITATION

If my_print_defaults is installed, myps load my.cnf and .my.cnf to connect DB. If you want to use another my.cnf, you can use --defaults-extra-files option like mysql cli.

myps access to INFORMATION_SCHEMA.PROCESSLIST table. Grant access to query INFORMATION_SCHEMA.PROCESSLIST and KILL if you needed.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址