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/

  • 相关阅读:
    spring 循环依赖问题
    spring data jpa 关键字 命名
    mongodb 添加字段并设置默认值
    java mongoTemplate的group统计
    java8 从对象集合中取出某个字段的集合
    springboot12-zuul
    springboot11-01-security入门
    springboot项目怎么部署到外部tomcat
    springboot10-springcloud-eureka 服务注册与发现,负载均衡客户端(ribbon,feign)调用
    UML
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/12401330.html
Copyright © 2011-2022 走看看