Skip to content

Instantly share code, notes, and snippets.

@leerspace
Created September 21, 2017 01:43
Show Gist options
  • Save leerspace/f3a2cb7985440ac9f791eaf3ccbbd045 to your computer and use it in GitHub Desktop.
Save leerspace/f3a2cb7985440ac9f791eaf3ccbbd045 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"
echo "$timestamp $res_mem $repo_size $peer_count" >> ipfs_log
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment