zoukankan      html  css  js  c++  java
  • pgmetrics 一个灵活方便的pg 监控cli

    pgmetrics 是基于golang 编写的一个灵活的pg性能分析cli,我们可以方便的看到关于pg 以及系统的一些metrics
    使用简单,支持human,json,csv 等格式

    下载

    参考以下地址https://github.com/rapidloop/pgmetrics/releases

    使用

    • 命令
     
    pgmetrics -U <user> -p <port> -h <host>
    • 命令
    pgmetrics collects PostgreSQL information and metrics.
    Usage:
      pgmetrics [OPTION]... [DBNAME]
    General options:
      -t, --timeout=SECS individual query timeout in seconds (default: 5)
      -i, --input=FILE don't connect to db, instead read and display
                                       this previously saved JSON file
      -V, --version output version information, then exit
      -?, --help[=options] show this help, then exit
          --help=variables list environment variables, then exit
    Collection options:
      -S, --no-sizes don't collect tablespace and relation sizes
      -c, --schema=REGEXP collect only from schema(s) matching POSIX regexp
      -C, --exclude-schema=REGEXP do NOT collect from schema(s) matching POSIX regexp
      -a, --table=REGEXP collect only from table(s) matching POSIX regexp
      -A, --exclude-table=REGEXP do NOT collect from table(s) matching POSIX regexp
          --omit=WHAT do NOT collect the items specified as a comma-separated
                                       list of: "tables", "indexes", "sequences",
                                       "functions", "extensions", "triggers",
                                       "statements", "log"
          --sql-length=LIMIT collect only first LIMIT characters of all SQL
                                       queries (default: 500)
          --statements-limit=LIMIT collect only utmost LIMIT number of row from
                                       pg_stat_statements (default: 100)
          --only-listed collect info only about the databases listed as
                                       command-line args (use with Heroku)
          --log-file location of PostgreSQL log file
          --log-span=MINS examine the last MINS minutes of logs (default: 5)
    Output options:
      -f, --format=FORMAT output format; "human", "json" or "csv" (default: "human")
      -l, --toolong=SECS for human output, transactions running longer than
                                       this are considered too long (default: 60)
      -o, --output=FILE write output to the specified file
          --no-pager do not invoke the pager for tty output
    Connection options:
      -h, --host=HOSTNAME database server host or socket directory
                                       (default: "10.16.225.178")
      -p, --port=PORT database server port (default: 5433)
      -U, --username=USERNAME database user name (default: "postgres")
      -w, --no-password never prompt for password
    For more information, visit <https://pgmetrics.io>.
    • 环境变量方式
      通过环境变量的方式,比较适合基于容器(比如k8s的configmap)以下是支持的环境变量
     
    Environment variables:
    Usage:
      NAME=VALUE [NAME=VALUE] pgmetrics ...
      PAGER name of external pager program
      PGAPPNAME the application_name connection parameter
      PGDATABASE the dbname connection parameter
      PGHOST the host connection parameter
      PGPORT the port connection parameter
      PGUSER the user connection parameter
      PGPASSWORD connection password (not recommended)
      PGPASSFILE path to the pgpass password file
      PGSSLMODE "disable", "require", "verify-ca", "verify-full"
      PGSSLCERT path to client SSL certificate
      PGSSLKEY path to secret key for client SSL certificate
      PGSSLROOTCERT path to SSL root CA
      PGCONNECT_TIMEOUT connection timeout in seconds
    Also, the following libpq-related environment variarables are not
    required/used by pgmetrics and are IGNORED:
      PGHOSTADDR, PGSERVICE, PGSERVICEFILE, PGREALM, PGREQUIRESSL,
      PGSSLCRL, PGREQUIREPEER, PGKRBSRVNAME, PGGSSLIB, PGSYSCONFDIR,
      PGLOCALEDIR

    说明

    官方同时提供了一个dashboard(云服务),实际上我们基于json 文件,使用prometheus 的push gateway 以及
    grok exporter,或者mtail,也都可以方便的进行数据分析的,同时官方文档也提供了比较详细的参数说明,pg_top,
    pg_systat 也是不错的工具

    参考资料

    https://github.com/rapidloop/pgmetrics/releases
    https://pgmetrics.io/docs/

  • 相关阅读:
    缓存架构设计细节二三事
    数据库软件架构设计些什么
    100亿数据1万属性数据架构设计
    这才是真正的表扩展方案
    啥,又要为表增加一列属性?
    究竟啥才是互联网架构“高可用”
    究竟啥才是互联网架构“高并发”
    Linux用过的命令
    Xshell远程连接工具
    oracle分组取第一条
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/12401330.html
Copyright © 2011-2022 走看看