Tips & Tricks
Join the $PLAY airdrop 🔥 campaign and prepare for PlayFi’s upcoming node sale.
Tip: Mining logs
In May, the Nimble team announced an essential update on logging the tasks performed.
Basically, upon completion of each task, the mining script updates my_logs.json in the nimble-miner-public directory with the status of the task: Success or Failed. You can then run another script to print a human-readable version of that JSON file.
An original version using showlogs.py
Below is the code you can copy and paste to your mining machine to see the results table.
cd ~/nimble/nimble-miner-public && \
source ./nimenv_localminers/bin/activate && \
pip3 install prettytable && \
python3 showlogs.py
My version of the logs output
I wanted a better and quicker overview of the running tasks, and I prepared (after quite some digging 🤓) my own version of log printing.
You only need to install the jq library with apt install jq -y
before running the script. I do this as part of my initial setup the newly rented machines.
Update June 14th, 2024: added the last five characters of the wallet address (in the square brackets) and revised the message.
cat $(find $HOME -type f -name "my_logs.json") | jq --arg today $(date +"%Y-%m-%d") '.[] | (select(.CompletedTime|startswith($today))).CompletedTime |=sub($today;"Today") | (select(.Status=="Failed").Status |="FAILED") | (.WalletAddr |=scan("([a-z0-9]{5,5}$)")) | "[\(.WalletAddr[0])] \(.CompletedTime) UTC: \(.TrainRuntime/3600?*100|round/100) hrs - \(.Status)"' && \
echo '- Time now:' $(date +"%T") 'UTC' && \
tmux capture-pane -pt "$target-pane" -S -1 | grep -e '^.*%' && tmux ls | grep no
- Remove the last line if you’re not running the nimble mining script in a tmux session.
- If your nimble mining script is located outside the $HOME directory, i.e., you used a custom image or script to set it up, you must explicitly specify the path to the my_logs.json file. To do that, replace
cat $(find $HOME -type f -name "my_logs.json")
withcat "/full/path/to/my_logs.json"
.
Assuming the nimble mining script (nimble-miner-public) folder is located in your $HOME directory, you should see the following output.
The output is compact and fits nicely on a narrow mobile screen. It shows the time spent on a task in a human-readable format. Finally, it prints the current time and mining status (extracted from a tmux session).
Tip: Print the tmux session status
tmux capture-pane -pt "$target-pane" -S -1 | grep -e '^.*%' && tmux ls | grep no
Tip: Print the tmux session with the essential details
The above nimble logs will only show you the status of the completed tasks. For the failed ones, though, you usually want to know why they failed in the first place.
While we can run tmux a -t nimble
(or tmux attach
if there’s just one session), we normally can’t scroll up to find the failed task details without tweaking the tmux config or exporting the entire tmux session to a text file.
Again, I’m lazy; I don’t want to scroll the entire log (it can be pretty large for the machines that have been running for a few days), so I created a command that exports the tmux session log to a text file, parses it and saves only the lines of text where the keywords of my interest were found.
These keywords are:
- wallet address
- when a task was executed and completed
- timeout errors
First, export a variable with your your wallet address.
export NIMBLE_WALLET_ADDRESS=your_wallet_address
Next, run the following command to print the relevant parts of the tmux session.
mkdir -p ~/logs && \
tmux capture-pane -pS - > ~/logs/tmux-buffer.txt && \
grep -ihnr -A2 -B2 "${NIMBLE_WALLET_ADDRESS}\|the task\|executed\|completed\|TimeoutError\|timeout\|error" ~/logs > ~/output.txt && \
cat ~/output.txt
After running the above command, you can find the entire session log in ~/logs/tmux-buffer.txt; e.g., print it with the cat ~/logs/tmux-buffer.txt
command.