monitors:ldom

Error loading plugin struct
ParseError: syntax error, unexpected 'fn' (T_STRING), expecting :: (T_PAAMAYIM_NEKUDOTAYIM)
More info is available in the error log.

This is an old revision of the document!


ldom.ksh

Author Vernon Everett
Compatibility Xymon but might work elsewhere - it's simple enough
Requirements T-series hardware running LDoms
Download None
Last Update 2010-06-10

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”.

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=

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=$BBTMP/ldom
# 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 | 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 | 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
# 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)
                     echo $ECPU
                     echo "$NAME : $ECPU" >> $TEMPFILE.3
                  done
echo >> $TEMPFILE.3
$BB $BBDISP "status $MACHINE.ldom green $(cat $TEMPFILE)"
$BB $BBDISP "data $MACHINE.ldom green $(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.
  • monitors/ldom.1375248703.txt.gz
  • Last modified: 2013/07/31 05:31
  • by vernon