I thought I would share a script I wrote with the community in hopes someone can benefit from it.
This script reads in all registered VM's, the determines the current state of the machine. If the machine is running it then determines the PID, and looks in a file(location is defined in the script) for the nice value to be assigned to the particular VM.
Any comments or suggestions would be greatly appreciated!
#!/bin/bash #Define location of file with nice values for VM's NICEFILE=/etc/cron.hourly/nice.values #Loop to catch all VMs for vm in $(vmware-cmd -l) do #Define state of Current VM STATE=`vmware-cmd $vm getstate | awk '{ print $3}'` #Checks current state of VM #If the VM is on it renices if not it exits if ["$STATE" = "on"]; then #Define VM name CURRVM=`basename $vm` #Define PID of current VM PID=`vmware-cmd $vm getpid | awk '{ print $3 }'` #Define nice value for VM NICEVALUE=`awk /$CURRVM'/ { print $2 }' $NICEFILE` #Command to renice the current VM renice $NICEVALUE $PID else exit fi done
Message was edited by: oreeh
Added the code tags