mgoldman

Insert QOS data for temperatures into NimBUS

Discussion created by mgoldman on Jul 21, 2006
Latest reply on Jul 21, 2006 by sseeberg

#!/usr/bin/ksh
#
#       This program will insert a message into the NimBUS QoS database
#       in a consistant manner.


BIN_DIR=/apps/nimbus_local/bin
NIM_BIN=/apps/nimbus/bin
NIM_CREATE=${NIM_BIN}/nimqosdefinition
NIM_INSERT=${NIM_BIN}/nimqos
HOST="`/usr/bin/hostname \
        | /usr/bin/sed -e 's/.epredix.com//' -e 's/-internal//'`"


#
#       Proceedure to get the system temperature
#
GET_TEMP() {



        HARDWARE="`/usr/bin/uname -i`"


        #
        #       Case for known hardware types.
        case ${HARDWARE} in
                SUNW,Sun-Fire-V240)
                        #
                        #       SUNW,Sun-Fire-V240
                        #
                        /usr/sbin/prtpicl -c temperature-sensor -v \
                                | /usr/bin/egrep 'temperature-sensor|Temperature' \
                                | /usr/bin/egrep -v _class \
                                | /usr/bin/nawk '
                                        /temperature-sensor/ {printf ("%s Fahrenheit F ", $1)}
                                        /Temperature/ {printf ("%s\n", (($NF*9/5)+32))}' \
                                | /usr/bin/sed -e 's/_t_core//' \
                                        -e 's/_t_enc//' \
                                        -e 's?_?/?' \
                                        -e 's?^mb/p?CPU?' \
                                        -e 's?^mb?MB?'
                        ;;
                SUNW,Sun-Fire-880)
                        #
                        #       SUNW,Sun-Fire-880
                        #
                        /usr/platform/sun4u/sbin/prtdiag -v \
                                | /usr/bin/sed -n '/^System Temperatures/,/^=====/p' \
                                | /usr/bin/sed  -e '1,4d' -e '/^*$/,$d' \
                                | /usr/bin/awk '{print $1, "Fahrenheit F", ($2*9/5)+32}'
                        ;;
                *)
                        echo "Unknown Hardware"
                        ;;
        esac # end of hardware case.


        #
        #       Get the GA temperature from the US Government Weather Service
        /apps/nimbus_local/bin/show_GA_temp


} # end of GET_TEMP()


#
#       Proceedure to generate a QOS entry
#
GEN_QOS() {


        #       The necessary options
        L3="$1"
        UNITS="$2"
        SHORT="$3"
        L2="$4"
        VALUE="$5"



        ##### echo "YYY L3=${L3}, Units=${UNITS}, Short=${SHORT}, L2=${L2}, Value=${VALUE}"


        #       Values that need to be set
        #       INTERVAL in minutes, generally 15 is good.
        #       UNITS a string such as bytes.
        #       SHORT the abbreviation for units, single character.


        #
        #       Create a test QoS to see if you have the correct info
        #
        ${NIM_CREATE} -q "${L1}" \
                -g "QOS_APPLICATION" \
                -d "${L1}" \
                -u ${UNITS} \
                -s ${SHORT}


        #
        #       Generate a value to see if anything is home
        #
        ${NIM_INSERT} -q "QOS_${L1}" \
                -s ${L2} \
                -t ${L3} \
                -i ${INTERVAL}  \
                -v "${VALUE}"


} # end of GEN_QOS()


DEST_NAME="root"
typeset -i DEST_UID=`/usr/xpg4/bin/id -u ${DEST_NAME}`
ID=`/usr/xpg4/bin/id -u`


#
#       Check permissions being run as
#
if ]
then
        echo "must be run as ${DEST_NAME}."
        exit 1
fi

INTERVAL="15"
L1="Sun_Temperature"
L2="${HOST}"


GET_TEMP \
        | while read L3 UNITS SHORT VALUE
        do
                ##### echo "*** Target=${TARGET}, Units=${UNITS}, Short=${SHORT}, Tablespace=${TABLESPACE}, Value=${VALUE}"
                ##### echo "*** L3=${L3}, Units=${UNITS}, Short=${SHORT}, L2=${L2}, Value=${VALUE}"
                GEN_QOS "${L3}" "${UNITS}" "${SHORT}" "${L2}" "${VALUE}"
        done


exit 0

Outcomes