Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
bash script for logging ipfs daemon memory utilization, repo size, and peer count
while sleep 1; do
# get process id for ipfs daemon
output=`ps aux | grep "ipfs daemon" | grep -v grep`
set -- $output
# get timestamp
timestamp=$(date +%s)
# get process memory usage in kilobytes
res_mem=`ps -p $pid -o rss | tail -1`
# get ipfs repo size in bytes
output=`ipfs repo stat | grep RepoSize`
set -- $output
# get ipfs peer count
peer_count=`ipfs swarm peers | wc -l`
# write to log file
echo "$timestamp $res_mem $repo_size $peer_count"
echo "$timestamp $res_mem $repo_size $peer_count" >> ipfs_log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment