ldom.ksh

Author Vernon Everett
Compatibility Xymon but might work elsewhere - it's simple enough
Requirements Oracle/Fujitsu T-series or M-Series hardware running LDoms
Download None
Last Update 2015-01-19

This script was born from a need to give people visibility of the LDoms and available resources, but without giving them access to the control domain to gather this information.

Xymon, being available, seemed the most logical place to display the information for those who needed it.

Added CPU usage graphing to assist with capacity planning. Calculates and graphs an “Effective Number of VCPUs Utilised”.

Recently added a feature to alert if the SP-Config was not up to date. For those who don't know, this is the virtualisation config, which needs to be updated after changes. Forget and reboot, and it loads the previous config, potentially with disasterous results. It's nice to be reminded to update it if required.

Client side

Copy ldom.ksh in hobboit/xymon ext directory (usually in HOBBITCLIENTHOME/ext) on the control domain.

Give it appropriate sudo, SUID or RBA access to allow the hobbit/xymon user to run ldm

Add the following to clientlaunch.cfg

[ldom]
      ENVFILE $HOBBITCLIENTHOME/etc/hobbitclient.cfg
      CMD $HOBBITCLIENTHOME/ext/ldom.ksh
      LOGFILE $HOBBITCLIENTHOME/logs/ldom.log
      INTERVAL 5m

Server side

Add the following to graphs.cfg

[ldom]
    FNPATTERN ldom,(.*).rrd
    TITLE LDOM EFFECTIVE VCPU UTILISATION
    YAXIS Effective CPUs
    -l 0
    DEF:p@RRDIDX@=@RRDFN@:lambda:AVERAGE
    LINE2:p@RRDIDX@#@COLOR@:@RRDPARAM@
    GPRINT:p@RRDIDX@:LAST: \: %5.2lf (cur)
    GPRINT:p@RRDIDX@:MAX: \: %5.2lf (max)
    GPRINT:p@RRDIDX@:MIN: \: %5.2lf (min)
    GPRINT:p@RRDIDX@:AVERAGE: \: %5.2lf (avg)\n
    

Add the following to xymonserver.cfg

SPLITNCV_ldom="*:GAUGE"
  • Add ldom=ncv to TEST2RRD=
  • Add ldom to GRAPHS=

ldom.ksh

Show Code ⇲

Hide Code ⇱

#!/bin/ksh
[ -x /usr/sbin/ldm ] || exit 0      # I am not a control LDom. Exit quietly
typeset -R7 CPU_NOT
typeset -R7 MEM_NOT
typeset -R7 CPU_TOT
typeset -R7 MEM_TOT
TEMPFILE=$XYMONTMP/ldom
COLOUR=green
# Get unallocated CPUs
CPU_NOT=$(/usr/sbin/ldm list-devices cpu | egrep -v "^$|VCPU|FREE" | wc  -l | sed 's/ //g')
# Get unallocated memory
MEM_NOT=0
ldm list-devices mem | awk '{ print $2 }' | egrep -v "^$|SIZE" | while read a
do
   echo $a | egrep -s "G"
   if [ $? -eq "0" ]
   then
      MULTIPLIER=1024
   else
      MULTIPLIER=1
   fi
   MEM=$(echo $a | sed 's/G//g;s/M//g')
   ((MEM_NOT=MEM_NOT+MEM*MULTIPLIER))
done
# Get allocated CPUs
CPU_TOT=0
date > $TEMPFILE
/usr/sbin/ldm ls > $TEMPFILE.2
cat $TEMPFILE.2 >> $TEMPFILE
cat $TEMPFILE.2 | egrep -v "inactive|bound" | awk '{ print $5 }' | grep -v CPU | while read a
do
   ((CPU_TOT=CPU_TOT+a))
done
# Get allocated memory
MEM_TOT=0
cat $TEMPFILE.2 | egrep -v "inactive|bound" | awk '{ print $6 }' | grep -v MEMORY | while read a
do
   echo $a | egrep -s "G"
   if [ $? -eq "0" ]
   then
      MULTIPLIER=1024
   else
      MULTIPLIER=1
   fi
   MEM=$(echo $a | sed 's/G//g;s/M//g')
   ((MEM_TOT=MEM_TOT+MEM*MULTIPLIER))
done
echo '-----------------------------------------------------------------------------' >> $TEMPFILE
echo "Total Allocated                        $CPU_TOT ${MEM_TOT}M" >> $TEMPFILE
echo "Total Available                        $CPU_NOT ${MEM_NOT}M" >> $TEMPFILE
# And a quick check to make sure the spconfig is up to date.
LATEST_CONFIG=$(ldm list-spconfig | grep "\[current\]")
echo >> $TEMPFILE
if [ -z "$LATEST_CONFIG" ]
then
   COLOUR=yellow
   LATEST_CONFIG=$(ldm list-spconfig | grep "\[next poweron\]")
   echo "&yellow Latest SP-Config not up to date - $LATEST_CONFIG" >> $TEMPFILE
   echo 'Use "ldm add-spconfig $(date +%Y%m%d-%H%M)" to update the SP-Config' >> $TEMPFILE
else
   echo "&green SP-Config up to date - $LATEST_CONFIG" >> $TEMPFILE
fi
# Now get graphing data
> $TEMPFILE.3
cat $TEMPFILE.2 | sed "s/%//g" \
                | grep -v "^NAME" \
                | awk '{ print $1" "$5" "$7 }' \
                | while read NAME CPU UTIL
                  do
                     #echo $1" "$5" "$7
                     ECPU=$(echo "scale=2;${CPU}*${UTIL}/100" | bc 2>/dev/null)
                     #echo $ECPU
                     echo "$NAME : $ECPU" >> $TEMPFILE.3
                  done
echo >> $TEMPFILE.3
$XYMON $XYMSRV "status $MACHINE.ldom $COLOUR $(cat $TEMPFILE)"
$XYMON $XYMSRV "data $MACHINE.ldom $COLOUR $(echo;echo;cat $TEMPFILE.3;echo "";echo "ignore this")"

Let me know if you spot any.

Solve world hunger.

I acted alone, I swear it!

  • 2010-06-10
    • Initial release
  • Sometime since then
    • Added graphing, but only got round to putting the updated code up today 2013-07-31.
  • 2015-01-19
    • Added SP-Config update alerts
  • monitors/ldom.txt
  • Last modified: 2015/01/18 23:02
  • by vernon