Skip to content

Instantly share code, notes, and snippets.

@cbluth
Forked from leerspace/bash_ipfs_memory_logger.sh
Last active September 21, 2017 03:55
Show Gist options
  • Save cbluth/53e6ff85d0a8919d42dc47f1dc9e2c41 to your computer and use it in GitHub Desktop.
Save cbluth/53e6ff85d0a8919d42dc47f1dc9e2c41 to your computer and use it in GitHub Desktop.
bash script for logging ipfs daemon memory utilization, repo size, and peer count
#/bin/bash
while sleep 1; do
# get process id for ipfs daemon
output=`ps aux | grep "ipfs daemon" | grep -v grep`
set -- $output
pid=$2
# 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
repo_size=$2
# get ipfs peer count
peer_count=`ipfs swarm peers | wc -l`
# write to log file
echo "$timestamp $res_mem $repo_size $peer_count" | tee -a ipfs_log
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment