mpchadwick / straceout-utils

A set of tools for working with strace out

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

straceout-utils

Build Status

A set of tools for working with strace out.

Installation

PHAR

From Source

  • Clone the repository from GitHub
  • Run composer install

TIP: If installing from source, execution entry point is bin/straceout-utils

Features

MySQL Query Results

strace out will include the packets received from MySQL in Client / Server Protocol format. This is not a format that can be read by humans. straceout-utils will process these packets and transform them into a format that is digestable for humans.

Notes

  • You must use the strace -x flag so that the packets are in hex format
  • When capturing the strace use the -s flag to ensure that strings are not truncated. It is not possible to reconstruct the query response if they are.

Example

Obtain the strace

In this example we capture an strace of execution of the script test.php.

$ strace -s 65535 -x -o strace-out.txt php test.php

Review strace-out.txt

You see something like the following in strace-out.txt

sendto(3, "\x2e\x00\x00\x00\x03\x53\x45\x4c\x45\x43\x54\x20\x60\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x60\x2e\x2a\x20\x46\x52\x4f\x4d\x20\x60\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x60", 50, MSG_DONTWAIT, NULL, 0) = 50
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x01\x00\x00\x01\x06\x54\x00\x00\x02\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0a\x77\x65\x62\x73\x69\x74\x65\x5f\x69\x64\x0a\x77\x65\x62\x73\x69\x74\x65\x5f\x69\x64\x0c\x3f\x00\x05\x00\x00\x00\x02\x23\x42\x00\x00\x00\x48\x00\x00\x03\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77", 126, MSG_DONTWAIT, NULL, NULL) = 126
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x04\x63\x6f\x64\x65\x04\x63\x6f\x64\x65\x0c\x21\x00\x60\x00\x00\x00\xfd\x04\x40\x00\x00\x00\x48\x00\x00\x04\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x04\x6e\x61\x6d\x65\x04\x6e\x61\x6d\x65\x0c\x21\x00\xc0\x00\x00\x00\xfd\x00\x00\x00\x00\x00\x54\x00\x00\x05\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0a\x73\x6f\x72\x74\x5f\x6f\x72\x64\x65\x72\x0a\x73\x6f\x72\x74\x5f", 189, MSG_DONTWAIT, NULL, NULL) = 189
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x6f\x72\x64\x65\x72\x0c\x3f\x00\x05\x00\x00\x00\x02\x29\x40\x00\x00\x00\x60\x00\x00\x06\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x10\x64\x65\x66\x61\x75\x6c\x74\x5f\x67\x72\x6f\x75\x70\x5f\x69\x64\x10\x64\x65\x66\x61\x75\x6c\x74\x5f\x67\x72\x6f\x75\x70\x5f\x69\x64\x0c\x3f\x00\x05\x00\x00\x00\x02\x29\x40\x00\x00\x00\x54\x00\x00\x07\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0a\x69\x73\x5f\x64\x65\x66\x61\x75\x6c\x74\x0a\x69\x73\x5f\x64\x65\x66", 189, MSG_DONTWAIT, NULL, NULL) = 189
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x61\x75\x6c\x74\x0c\x3f\x00\x05\x00\x00\x00\x02\x20\x00\x00\x00\x00\x05\x00\x00\x08\xfe\x00\x00\x22\x00\x14\x00\x00\x09\x01\x30\x05\x61\x64\x6d\x69\x6e\x05\x41\x64\x6d\x69\x6e\x01\x30\x01\x30\x01\x30\x1a\x00\x00\x0a\x01\x31\x04\x62\x61\x73\x65\x0c\x4d\x61\x69\x6e\x20\x57\x65\x62\x73\x69\x74\x65\x01\x30\x01\x31\x01\x31\x05\x00\x00\x0b\xfe\x00\x00\x22\x00", 189, MSG_DONTWAIT, NULL, NULL) = 89
sendto(3, "\x25\x00\x00\x00\x03\x53\x48\x4f\x57\x20\x54\x41\x42\x4c\x45\x20\x53\x54\x41\x54\x55\x53\x20\x4c\x49\x4b\x45\x20\x27\x73\x74\x6f\x72\x65\x5f\x67\x72\x6f\x75\x70\x27", 41, MSG_DONTWAIT, NULL, 0) = 41

Process the strace output

straceout-utils writes output to stdout. In this example we sent that to a new text file, named straceout-utils-out

$ straceout-utils process strace-out.txt > straceout-utils-out.txt

Review straceout-utils-out.txt

In straceout-utils-out.txt you see the following:

sendto(3, "\x2e\x00\x00\x00\x03\x53\x45\x4c\x45\x43\x54\x20\x60\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x60\x2e\x2a\x20\x46\x52\x4f\x4d\x20\x60\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x60", 50, MSG_DONTWAIT, NULL, 0) = 50
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x01\x00\x00\x01\x06\x54\x00\x00\x02\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0a\x77\x65\x62\x73\x69\x74\x65\x5f\x69\x64\x0a\x77\x65\x62\x73\x69\x74\x65\x5f\x69\x64\x0c\x3f\x00\x05\x00\x00\x00\x02\x23\x42\x00\x00\x00\x48\x00\x00\x03\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77", 126, MSG_DONTWAIT, NULL, NULL) = 126
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x04\x63\x6f\x64\x65\x04\x63\x6f\x64\x65\x0c\x21\x00\x60\x00\x00\x00\xfd\x04\x40\x00\x00\x00\x48\x00\x00\x04\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x04\x6e\x61\x6d\x65\x04\x6e\x61\x6d\x65\x0c\x21\x00\xc0\x00\x00\x00\xfd\x00\x00\x00\x00\x00\x54\x00\x00\x05\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0a\x73\x6f\x72\x74\x5f\x6f\x72\x64\x65\x72\x0a\x73\x6f\x72\x74\x5f", 189, MSG_DONTWAIT, NULL, NULL) = 189
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x6f\x72\x64\x65\x72\x0c\x3f\x00\x05\x00\x00\x00\x02\x29\x40\x00\x00\x00\x60\x00\x00\x06\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x10\x64\x65\x66\x61\x75\x6c\x74\x5f\x67\x72\x6f\x75\x70\x5f\x69\x64\x10\x64\x65\x66\x61\x75\x6c\x74\x5f\x67\x72\x6f\x75\x70\x5f\x69\x64\x0c\x3f\x00\x05\x00\x00\x00\x02\x29\x40\x00\x00\x00\x54\x00\x00\x07\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0a\x69\x73\x5f\x64\x65\x66\x61\x75\x6c\x74\x0a\x69\x73\x5f\x64\x65\x66", 189, MSG_DONTWAIT, NULL, NULL) = 189
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x61\x75\x6c\x74\x0c\x3f\x00\x05\x00\x00\x00\x02\x20\x00\x00\x00\x00\x05\x00\x00\x08\xfe\x00\x00\x22\x00\x14\x00\x00\x09\x01\x30\x05\x61\x64\x6d\x69\x6e\x05\x41\x64\x6d\x69\x6e\x01\x30\x01\x30\x01\x30\x1a\x00\x00\x0a\x01\x31\x04\x62\x61\x73\x65\x0c\x4d\x61\x69\x6e\x20\x57\x65\x62\x73\x69\x74\x65\x01\x30\x01\x31\x01\x31\x05\x00\x00\x0b\xfe\x00\x00\x22\x00", 189, MSG_DONTWAIT, NULL, NULL) = 89
-- Begin -- StraceOutUtils\Processor\MysqlQueryResult
.SELECT `store_website`.* FROM `store_website`
************* 1 *************
website_id: 0
code: admin
name: Admin
sort_order: 0
default_group_id: 0
is_default: 0
************* 2 *************
website_id: 1
code: base
name: Main Website
sort_order: 0
default_group_id: 1
is_default: 1

-- End -- StraceOutUtils\Processor\MysqlQueryResult
sendto(3, "\x25\x00\x00\x00\x03\x53\x48\x4f\x57\x20\x54\x41\x42\x4c\x45\x20\x53\x54\x41\x54\x55\x53\x20\x4c\x49\x4b\x45\x20\x27\x73\x74\x6f\x72\x65\x5f\x67\x72\x6f\x75\x70\x27", 41, MSG_DONTWAIT, NULL, 0) = 41

About

A set of tools for working with strace out

License:MIT License


Languages

Language:PHP 100.0%