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/)
printf '<command>\n' | ckpmsg -s <parent> -n <pool-name> -N <process>Two things about ckpmsg are easy to get wrong, and both fail silently:
- The command is read from stdin, not argv (
src/ckpmsg.c:121). A trailingckpmsg ... statsis ignored and you get empty output with exit status 0. - The socket path is assembled from three flags as
<-s>/<-n>/<-N>(src/ckpmsg.c:252-262) —-sis a parent directory, not the socket itself.
With the default "sockdir": "/tmp/ckpool", the stratifier socket is
/tmp/ckpool/stratifier, so the flags are -s /tmp -n ckpool -N stratifier.
For any other sockdir, either split it into parent and basename, or point -n
at the current directory:
printf 'stats\n' | ckpmsg -s /var/run/mypool -n . -N stratifierckpmsg is a debugging tool, not a JSON transport. It writes its logging to
stdout, mixed in with the reply, and it prints through LOGMSGSIZ, which
emits at most 510 characters per line — so any sizeable response arrives split
across several lines behind two lines of chatter. Piping it straight into jq
fails on anything bigger than a toy pool.
ckpmsg_json() {
printf '%s\n' "$1" \
| ckpmsg -s /tmp -n ckpool -N "${2:-stratifier}" 2>/dev/null \
| sed -n '/Received response: /,$p' \
| sed '1s/^.*Received response: //' \
| tr -d '\n'
}
ckpmsg_json stats | jq .
ckpmsg_json users | jq '.users | length'For anything programmatic — a dashboard, monitoring, a web app — prefer the read-only HTTP service in
api/. It returns clean JSON over an authenticated socket and does not require shell access to the pool host.
Where <process> is one of:
stratifier- Main mining process (most commands)connector- Network connectionsgenerator- Block generationpool- Main pool process
Get overall pool statistics:
printf 'stats\n' | ckpmsg -s /tmp -n ckpool -N stratifierReturns 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:
printf 'users\n' | ckpmsg -s /tmp -n ckpool -N stratifierReturns JSON array with all users and their statistics.
Get detailed worker information:
printf 'workers\n' | ckpmsg -s /tmp -n ckpool -N stratifierReturns JSON with all workers grouped by user.
Get information about a specific user:
printf 'user.info=USERNAME\n' | ckpmsg -s /tmp -n ckpool -N stratifierExample:
printf 'user.info=skaisser\n' | ckpmsg -s /tmp -n ckpool -N stratifierView the current work template:
printf 'current.workbase\n' | ckpmsg -s /tmp -n ckpool -N stratifierAdjust logging verbosity:
# Set to debug
printf 'loglevel=7\n' | ckpmsg -s /tmp -n ckpool -N stratifier
# Set to notice (default)
printf 'loglevel=5\n' | ckpmsg -s /tmp -n ckpool -N stratifier
# Set to warning only
printf 'loglevel=3\n' | ckpmsg -s /tmp -n ckpool -N stratifierLog levels:
- 0: EMERG
- 1: ALERT
- 2: CRIT
- 3: ERR
- 4: WARNING
- 5: NOTICE
- 6: INFO
- 7: DEBUG
Disconnect a specific user:
printf 'dropuser=USERNAME\n' | ckpmsg -s /tmp -n ckpool -N stratifierGet a quick summary:
printf 'summary\n' | ckpmsg -s /tmp -n ckpool -N poolGracefully shutdown the pool:
printf 'shutdown\n' | ckpmsg -s /tmp -n ckpool -N poolCreate a monitoring script:
#!/bin/bash
while true; do
clear
echo "=== CKPool Stats ==="
ckpmsg_json stats stratifier | jq '.'
sleep 5
doneExtract specific user's hashrate:
ckpmsg_json user.info=skaisser stratifier | jq '.hashrate1m'Show all active workers with hashrate:
ckpmsg_json workers stratifier | jq '.workers[] | {user: .user, worker: .worker, hashrate: .hashrate1m}'Save pool statistics:
printf 'stats\n' | ckpmsg -s /tmp -n ckpool -N stratifier > 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"*)
printf 'stats\n' | ckpmsg -s /tmp -n ckpool -N stratifier
;;
*"/users"*)
printf 'users\n' | ckpmsg -s /tmp -n ckpool -N stratifier
;;
*"/workers"*)
printf 'workers\n' | ckpmsg -s /tmp -n ckpool -N stratifier
;;
*)
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', '/tmp', '-n', 'ckpool', '-N', socket]
# ckpmsg reads the command from stdin -- passing it in argv is ignored.
result = subprocess.run(cmd, input=command + '\n',
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:
printf 'loglevel=7\n' | ckpmsg -s /tmp -n ckpool -N stratifier 2>&1You can send custom JSON-RPC style queries:
echo '{"method":"stats","params":[]}' | printf '-\n' | ckpmsg -s /tmp -n ckpool -N stratifierCreate a comprehensive monitoring script:
#!/bin/bash
# monitor.sh
echo "CKPool Monitor - $(date)"
echo "===================="
echo -e "\n📊 Pool Stats:"
ckpmsg_json stats stratifier | jq '{
hashrate: .hashrate1m,
workers: .workers,
users: .users,
shares: .accounted_shares,
uptime: .elapsed
}'
echo -e "\n👥 Top Users by Hashrate:"
ckpmsg_json users stratifier | 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