Coder Social home page Coder Social logo

go-pxld's Introduction

pxld

Decode your binary format ProxySQL query log.

Go Report Card Documentation license Build Status

Requirement

  • Go v1.11 or later

Build

  • go mod download
  • cd cmd/decoder
  • go build

Run

After you've build the decoder, just run the executable.

The File Format

  • 5D 00 00 00 00 00 00 00 first 8 bytes is the length of a message, this one.
  • 00 next byte denounce that this is a ProxySQL log message or not, if not 00, not valid.

The next after this line needs read_encoded_length function which itself needs mysql_decode_length function.

  • 0A this is the thread id because it is less than or equal 0xFB, convert to uint64.
  • 06 this is the length of username because it is less than or equal 0xFB, convert to uint64.
  • 64 69 64 61 73 79 is the username in ASCII.
  • 12 this is the length of schema because it is less than or equal 0xFB, convert to uint64.
  • 69 6E 66 6F 72 6D 61 74 69 6F 6E 5F 73 63 68 65 6D 61 is the schema in ASCII.
  • 0F this is the length of client address because it is less than or equal 0xFB, convert to uint64.
  • 31 32 37 2E 30 2E 30 2E 31 3A 33 32 38 32 30 is the client address in ASCII.
  • FE this tell us to read the next 8 bytes as uint64.
  • FF FF FF FF FF FF FF FF this is the HID in uint64, if HID == UINT64_MAX then we don't have server address to read.
  • FE this tell us to read the next 8 bytes as uint64.
  • 91 00 B3 4A 28 86 05 00 this is query start time in UNIX microseconds in uint64.
  • FE this tell us to read the next 8 bytes as uint64.
  • 91 00 B3 4A 28 86 05 00 this is query end time in UNIX microseconds in uint64.
  • FE this tell us to read the next 8 bytes as uint64.
  • D6 1F BA 14 4D 1F 23 AE this is query digest in uint64, but it needs to be separated into two uint32 and then it can be printed into hex sprintf("0x%X%X", n1, n2) == 0x14BA1FD6AE231F4D.
  • 0C this is the length of the actual query because it is less than or equal 0xFB, convert to uint64.
  • 2E 30 2E 31 3A 33 32 38 32 30 00 A5 this the actual query in ASCII.

Then we can go to the next line and repeat.

Decoding Message Parts Length

To decode part length, first we must take the first byte of the part. Then we check if:

  • It is less or equal than 0xFB. If so we take this byte as the message length.
  • It is equal to 0xFC. If so, we take 2 bytes as the message length.
  • It is equal to 0xFD. If so, we take 3 bytes as the message length.
  • It is equal to 0xFE. If so, we take 8 bytes as the message length.

go-pxld's People

Contributors

asdptkt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

go-pxld's Issues

Add support for ProxySQL 2.0.6+

In ProxySQL 2.0.6 the event log format was changed to include more information.
You may consider updating this tool.
Thank you for the contribution!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.