Shell script to check number of vCPU in Solaris x86 & pbind to half the number of processors

I want to launch a tool but bind it to half the number of vCPUs only.

So I'll need a Shell script to
a) check how many vCPUs a VM has (we can have 1 to 16)
b) if it's one vCPU, then run the command in nice mode ie   nice /path/scriptname
c) if more than one, then pbind to half the number of processors/vCPU & 
    run the command (ie the command will take up at most 50% of total CPU
    at max)

I can't recall in Solaris 10 x86, it's cpu0, cpu1 or processor1, processor2 or ...
in a virtual environment
sunhuxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sunhuxAuthor Commented:
Forgot to mention what's the pid of the command to do pbind:
  Get the pid from the following command:
     ps -ef | grep "MYtools" | grep -v grep

& the script needs to create a processor set before doing the pbind:
http://stackoverflow.com/questions/10277221/binding-process-to-multiple-processors-on-sun-solaris-os
0
sunhuxAuthor Commented:
Btw, if the number of vCPUs is odd, say 5, then pbind to 3 vCPUs
(ie half+1)
0
sunhuxAuthor Commented:
One last requirement, after the niced job has been running for
6 hours, it should be terminated (in case it runs into a loop)
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

sunhuxAuthor Commented:
So basically run the command something like :
    timeout 21600 nice command_to_run

(I'm not sure if timeout is supported in Solaris x86)
0
gheistCommented:
Run process with nice, it will not prevent anything normally running from doing its job
You need to install gnu coreutils for timeout command

I think you saturate IO. What virtualisation you use? Say XEN has ionice, VMWare has SIOC, but solaris has none.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sunhuxAuthor Commented:
I'm on vSphere & guest VMs OS is Solaris 10 x86


So do I need coreutils package for Solaris 10 or it comes pre-installed?
0
gheistCommented:
You need to either spread scheduled jobs by couple of minutes, or enable SIOC, or both.
0
sunhuxAuthor Commented:
What I need desperately currently is the Shell script to create a psrset
that is about half (or slightly more than half) of the total vCPUs & then
pbind the AV scanner to them so as to cap the CPU utilization
0
gheistCommented:
Yes - spread AV scanner startup during 1 hour. Thats all the best practice there is.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.