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
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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:
sunhuxAuthor Commented:
Btw, if the number of vCPUs is odd, say 5, then pbind to 3 vCPUs
(ie half+1)
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)
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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)
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.

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?
You need to either spread scheduled jobs by couple of minutes, or enable SIOC, or both.
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
Yes - spread AV scanner startup during 1 hour. Thats all the best practice there is.
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.