Quantcast
Channel: VMware Communities : Popular Discussions - VMware Server 1
Viewing all articles
Browse latest Browse all 74849

Script to "renice" VM processes

$
0
0

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


Viewing all articles
Browse latest Browse all 74849

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>