CKPool doesn't use a traditional HTTP API. Instead, it uses Unix domain sockets accessed via the ckpmsg utility. This guide explains how to query and control your CKPool instance.
- CKPool must be running
- You need access to the
ckpmsgbinary (installed with ckpool) - Unix sockets must be accessible (typically in
/tmp/ckpool/)
ckpmsg -s /tmp/ckpool/<process> <command>Where <process> is one of:
stratifier- Main mining process (most commands)connector- Network connectionsgenerator- Block generationpool- Main pool process
Get overall pool statistics:
ckpmsg -s /tmp/ckpool/stratifier statsReturns JSON with:
- Current hashrate (1m, 5m, 15m, 1h, 1d, 7d)
- Number of connected workers and users
- Total shares submitted
- Pool uptime
- Share statistics
Get a list of all users:
ckpmsg -s /tmp/ckpool/stratifier usersReturns JSON array with all users and their statistics.
Get detailed worker information:
ckpmsg -s /tmp/ckpool/stratifier workersReturns JSON with all workers grouped by user.
Get information about a specific user:
ckpmsg -s /tmp/ckpool/stratifier user.info=USERNAMEExample:
ckpmsg -s /tmp/ckpool/stratifier user.info=skaisserView the current work template:
ckpmsg -s /tmp/ckpool/stratifier current.workbaseAdjust logging verbosity:
# Set to debug
ckpmsg -s /tmp/ckpool/stratifier loglevel=7
# Set to notice (default)
ckpmsg -s /tmp/ckpool/stratifier loglevel=5
# Set to warning only
ckpmsg -s /tmp/ckpool/stratifier loglevel=3Log levels:
- 0: EMERG
- 1: ALERT
- 2: CRIT
- 3: ERR
- 4: WARNING
- 5: NOTICE
- 6: INFO
- 7: DEBUG
Disconnect a specific user:
ckpmsg -s /tmp/ckpool/stratifier dropuser=USERNAMEGet a quick summary:
ckpmsg -s /tmp/ckpool/pool summaryGracefully shutdown the pool:
ckpmsg -s /tmp/ckpool/pool shutdownCreate a monitoring script:
#!/bin/bash
while true; do
clear
echo "=== CKPool Stats ==="
ckpmsg -s /tmp/ckpool/stratifier stats | jq '.'
sleep 5
doneExtract specific user's hashrate:
ckpmsg -s /tmp/ckpool/stratifier user.info=skaisser | jq '.hashrate1m'Show all active workers with hashrate:
ckpmsg -s /tmp/ckpool/stratifier workers | jq '.workers[] | {user: .user, worker: .worker, hashrate: .hashrate1m}'Save pool statistics:
ckpmsg -s /tmp/ckpool/stratifier stats > pool_stats_$(date +%Y%m%d_%H%M%S).jsonIf you need HTTP access, create a simple wrapper:
#!/bin/bash
# api-server.sh - Simple HTTP wrapper for ckpmsg
# Requires socat
while true; do
echo -e "HTTP/1.1 200 OK\nContent-Type: application/json\n"
case "$REQUEST" in
*"/stats"*)
ckpmsg -s /tmp/ckpool/stratifier stats
;;
*"/users"*)
ckpmsg -s /tmp/ckpool/stratifier users
;;
*"/workers"*)
ckpmsg -s /tmp/ckpool/stratifier workers
;;
*)
echo '{"error":"Unknown endpoint"}'
;;
esac
done | socat TCP-LISTEN:8080,reuseaddr,fork EXEC:"/bin/bash api-server.sh"Query CKPool from Python:
import subprocess
import json
def ckpool_command(socket, command):
"""Execute ckpmsg command and return parsed JSON"""
cmd = ['ckpmsg', '-s', f'/tmp/ckpool/{socket}', command]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode == 0:
return json.loads(result.stdout)
return None
# Get pool stats
stats = ckpool_command('stratifier', 'stats')
print(f"Pool hashrate: {stats['hashrate1m']} GH/s")
# Get all users
users = ckpool_command('stratifier', 'users')
for user in users['users']:
print(f"User: {user['user']}, Hashrate: {user['hashrate1m']}")If you get permission errors:
ls -la /tmp/ckpool/
# Check socket permissionsIf sockets don't exist:
# Check if ckpool is running
ps aux | grep ckpool
# Check ckpool logs
tail -f ~/ckpool/logs/ckpool.logSome commands may return text instead of JSON. Parse accordingly:
ckpmsg -s /tmp/ckpool/stratifier loglevel=7 2>&1You can send custom JSON-RPC style queries:
echo '{"method":"stats","params":[]}' | ckpmsg -s /tmp/ckpool/stratifier -Create a comprehensive monitoring script:
#!/bin/bash
# monitor.sh
echo "CKPool Monitor - $(date)"
echo "===================="
echo -e "\n📊 Pool Stats:"
ckpmsg -s /tmp/ckpool/stratifier stats | jq '{
hashrate: .hashrate1m,
workers: .workers,
users: .users,
shares: .accounted_shares,
uptime: .elapsed
}'
echo -e "\n👥 Top Users by Hashrate:"
ckpmsg -s /tmp/ckpool/stratifier users | jq -r '.users |
sort_by(-.hashrate1m) |
.[0:5] |
.[] |
"\(.user): \(.hashrate1m) GH/s"'
echo -e "\n⚡ Recent Blocks:"
tail -n 5 ~/ckpool/logs/ckpool.log | grep "BLOCK FOUND"- All responses are in JSON format unless otherwise noted
- Some commands may require specific pool modes (solo vs proxy)
- Commands are processed asynchronously - responses may have slight delays
- For production monitoring, implement proper error handling and rate limiting