Skip to content

Instantly share code, notes, and snippets.

@al3xandru
Created October 5, 2013 07:31
Show Gist options
  • Save al3xandru/6837906 to your computer and use it in GitHub Desktop.
Save al3xandru/6837906 to your computer and use it in GitHub Desktop.
Bring together the logs from ccm nodes. Run: ccmtail ~/.ccm/cluster_name/ *Note*: make sure that you include the last /
#!/bin/bash
function killtails {
echo ""
echo "Cleaning up..."
for pid in $(ps ax | grep "tail -f ${cluster_dir}/node" | grep -v grep | awk '{print $1}')
do
echo "Killing pid: ${pid}"
kill ${pid}
done
rm -vf "${cluster_dir}/system.log"
}
trap "killtails" 2
cluster_dir=$1
cluster_name=$(basename ${cluster_dir})
nodes=$(ls -A1 -I cluster.conf -I system.log ${cluster_dir})
echo "Nodes in cluster '${cluster_name}':"
echo "${nodes}"
#touch "${cluster_dir}/system.log"
for node in ${nodes}
do
echo "Attaching tail to node: ${node}"
tail -f "${cluster_dir}/${node}/logs/system.log" >> ${cluster_dir}/system.log &
done
tail -f "${cluster_dir}/system.log"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment