Skip to content

Commit

Permalink
add log check script
Browse files Browse the repository at this point in the history
  • Loading branch information
bonedaddy committed Aug 24, 2021
1 parent deaca30 commit d683c31
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ crank:
max_markets_per_tx: 6
```

# Log Analysis

To enable quick analysis of the serum crank log file, `scripts/check_logs.sh` can be used to dump the logs of the running crank docker container, which will show a warning if any errors were detected. When no errors have been detected the output looks similar to:

```
$ ./check_logs.sh
found records of 320 cranks, with highest markets in tx 5
5 most recent crank transactions
2s6Uxd....bfB9TkPKeV
4trQ1n....DRaMZ3hcDS
5A3RT2....MRcVRCSyK4
23jksg....rdLSVPQ2pd
3U4jTe....kMuQgZKMvW
```

# License

Based on code from Serum, so for their [click here](https://github.com/project-serum/serum-dex/blob/master/LICENSE)
23 changes: 23 additions & 0 deletions scripts/check_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /bin/bash
docker-compose logs > logs
LOGS=$(grep -i "processed .* instructions for" logs)
HIGHEST_MARKET_COUNT=$(echo "$LOGS" | awk -F 'markets:' '{print $1}' | awk '{print $NF}' | sort -u | tail -n 1)
CRANK_COUNT=$(echo "$LOGS" | awk -F 'markets:' '{print $1}' | wc -l)
echo "found records of $CRANK_COUNT cranks, with highest markets in tx $HIGHEST_MARKET_COUNT"
ERRORS=$(echo "$LOGS" | grep -i "error")
FAILS=$(echo "$LOGS" | grep -i "fail")

if [[ "$ERRORS" != "" ]]; then
echo "found possible errors"
echo "$ERRORS"
fi

if [[ "$FAILS" != "" ]]; then
echo "found possible failures"
echo "$FAILS"
fi

CRANK_TXS=$(grep -i "crank ran" logs | awk -F 'crank ran' '{print $2}' | awk '{print $1}')
FIVE_TXS=$(grep -i "crank ran" logs | awk -F 'crank ran' '{print $2}' | awk '{print $1}' | tail -n 5)
echo "5 most recent crank transactions"
echo "$FIVE_TXS"

0 comments on commit d683c31

Please sign in to comment.