monitors:ldom

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.

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

No changes required

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=/tmp/ldom
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
/usr/sbin/ldm ls | awk '{ print $5 }' | grep -v CPU | while read a
do
   ((CPU_TOT=CPU_TOT+a))
done
# Get allocated memory
MEM_TOT=0
/usr/sbin/ldm ls | 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 $CPU_NOT
echo $MEM_NOT
echo '-----------------------------------------------------------------------------' >> $TEMPFILE
echo "Total Allocated                        $CPU_TOT ${MEM_TOT}M" >> $TEMPFILE
echo "Total Available                        $CPU_NOT ${MEM_NOT}M" >> $TEMPFILE
$BB $BBDISP "status $MACHINE.ldom green $(cat $TEMPFILE)"

Let me know if you spot any.

Solve world hunger.

I acted alone, I swear it!

  • 2010-06-10
    • Initial release
  • monitors/ldom.1276148043.txt.gz
  • Last modified: 2013/07/31 05:18
  • (external edit)