ganglia & rrdtool

Here’s a little script for developing systems digests across clusters using rrdtool and ganglia. We’re also working on a cluster profiler, perhaps using cacti, in order to monitor all processes running on cluster(s). This tool will also use PBS data in the interests of developing comprehensive performance and usage documents and statistics. We also have boost::multi_index,threads  and serialize in mind, with a  Solr backend.

#!/bin/bash

echo
echo "The following is a brief summary of systems average usage over the last hour :"
echo
echo

declare -a machs=('clusterA' 'clusterB')

echo        $'\t\t'    $'\t\t'jobs$'\t\t'jobs
echo Cluster$'\t\t'%CPU$'\t\t'queued$'\t\t'running$'\t\t'CPU cores avail.
echo "-------------------------------------------------------------------------------"

for x in ${machs[@]}
do

#load calculation
total=$(ssh uid@my.dom.edu rrdtool fetch \
/var/lib/ganglia/rrds/$x/__SummaryInfo__/cpu_num.rrd AVERAGE --start end-1h |\
 awk '!/n/{print $2}' | sort -r | awk 'NR<2 {print $0}')

avg=$(ssh uid@my.dom.edu rrdtool fetch \
/var/lib/ganglia/rrds/$x/__SummaryInfo__/load_fifteen.rrd AVERAGE --start end-1h |\
awk '!/n/{print $2}' | awk 'BEGIN{count=-1} { total += $1; count++ } END { print total/count }')

ntotal=`echo ${total} | sed -e 's/[eE]+*/\\*10\\^/'`
navg=`echo ${avg} | sed -e 's/[eE]+*/\\*10\\^/'`

load=$(echo "scale=2; $navg / ($ntotal) * 100" | bc)

jobsq=$(ssh uid@my.dom.edu rrdtool fetch \
/var/lib/ganglia/rrds/$x/__SummaryInfo__/pbs_jobs_queued.rrd AVERAGE --start end-1h |\
awk '!/n/{print $2}' | awk 'BEGIN{count=-1} { total += $1; count++ } END { print total/count }')

jobsr=$(ssh uid@my.dom.edu rrdtool fetch \
/var/lib/ganglia/rrds/$x/__SummaryInfo__/pbs_jobs_running.rrd AVERAGE --start end-1h |\
awk '!/n/{print $2}' | awk 'BEGIN{count=-1} { total += $1; count++ } END { print total/count }')

echo $x$'\t\t'$load$'\t\t'$jobsq$'\t\t'$jobsr$'\t\t'$total

done
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s