Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding cpu to LPAR via cron

Status
Not open for further replies.

aixuser1

Technical User
May 8, 2007
4
CA
I would like to add one cpu to a LPAR via cron...I want to add cpu at 8am and remove it at 5pm...Can someone please tell me the commands to do this....Thanks
 
Yeah i think this is doable!

You can either do what you said, schedule this thru crontab and have access (for example: password free ssh) to the HMC!

Or you can configure PLM (Partition Load Manager)! It is much easier and it will give you more control on your LPARs for such dynamic operations.


Regards,
Khalid
 
You'll have to make some changes for your environment, but here's the script I use. Particularly, I use a mysql database for tracking certain information about my LPAR environment (multiple P5's), and passwordless authentication to my HMCs.

Code:
#!/bin/ksh

P_HOSTNAME="${1}"
P_COMMAND="${2}"
P_VALUE="${3}"
HMC="hscroot@hmc1"

##############################################################################
### first establish that it's a legit LPAR, at least according to the database

R_HOSTNAME=`sql lpar "select hostname from lpar where hostname='${P_HOSTNAME}'"`
if test "${R_HOSTNAME}" = ""
then
        echo "Undefined LPAR name ${P_HOSTNAME}"
        exit
fi

##############################################################################
### second, obtain the LPAR serial number.

R_P5UNITNUMBER=`sql lpar "select hostp5 from lpar where hostname='${P_HOSTNAME}'"`

#echo "R_HOSTNAME = ${R_HOSTNAME}"
#echo "R_HOSTP5   = ${R_HOSTP5}"
#echo "R_P5UNIT   = ${R_P5UNITNUMBER}"

##############################################################################
### third, figure out what exactly we're doing
case "${P_COMMAND}" in
        "addcpu")
                echo "ADDCPU"
                ssh -n ${HMC} "chhwres -r proc -m ${R_P5UNITNUMBER} -p ${R_HOSTNAME} -o a --procs ${P_VALUE} --procunits 0.${P_VALUE}"
                ;;

        "delcpu")
                echo "DELCPU"
                ssh -n ${HMC} "chhwres -r proc -m ${R_P5UNITNUMBER} -p ${R_HOSTNAME} -o r --procs ${P_VALUE} --procunits 0.${P_VALUE}"
                ;;

        "addmem")
                echo "ADDMEM"
                ssh -n ${HMC} "chhwres -r mem -m ${R_P5UNITNUMBER} -p ${R_HOSTNAME} -o a -q ${P_VALUE}"
                ;;

        "delmem")
                echo "DELMEM"
                ssh -n ${HMC} "chhwres -r mem -m ${R_P5UNITNUMBER} -p ${R_HOSTNAME} -o r -q ${P_VALUE}"
                ;;

        "poweron")
                echo "POWERON"
                PROFILE=`sql lpar "select profile from lpar where hostname='${R_HOSTNAME}'"`
                ssh -n ${HMC} "chsysstate -m ${R_P5UNITNUMBER} -r lpar -o on -n ${R_HOSTNAME} -f '${PROFILE}'"
                ;;

        "poweroff")
                echo "POWEROFF"
                ssh -n ${HMC} "chsysstate -m ${R_P5UNITNUMBER} -r lpar -o shutdown --immed -n ${R_HOSTNAME}"
                ;;

        *)
                echo "Invalid command ${P_COMMAND}"
                ;;
esac
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top