Skip to content

Latest commit

 

History

History
81 lines (59 loc) · 1.98 KB

README.md

File metadata and controls

81 lines (59 loc) · 1.98 KB

PgSniffer is a command-line tool, capture PostgreSQL network traffic, calculate slow-sql-log.

image

Why PgSniffer


  • Forgot open log_min_duration_statement? Edit the configuration file and restart pg-server, so trouble...
  • Slow SQL list, SQL number of calls.
  • Minimize effect the production environment.

Binary Installation


Compile Installation


Mac OS / Linux

You need install libpcap on Linux platform.

yum install libpcap-devel -y

{OS}: windows, linux, drawin, freebsd

{ARCH}: amd64, 386, arm

GOOS={OS} GOARCH={ARCH} go build -o pgsniffer sniffer.go

Mac OS X 64bit

GOOS=darwin GOARCH=amd64 go build -o pgsniffer sniffer.go

Windows

Windows 64bit

GOOS=windows GOARCH=amd64 go build -o pgsniffer.exe sniffer.go

Usage


sudo ./pgsniffer -i lo0 -f "tcp port 5432"

Options


-i 		lo0						device interface
-l                              list all device interface
-f		"tcp port 5432"			port and direction
-n 		50						show top-n slowest sql
-v 								output all sqls captured

TODO


  • Get PostgreSQL basic performance data
  • Automatically saved to a capture file
  • SQL index hit Analysis

License


The MIT License