Shell script to bind my job to half the number of vCPUs in Solaris

I would like to launch a script but bind it to half the number of vCPUs
only so that the max CPU utilization is 50-60% max

So I'll need a Shell script to

a) check how many vCPUs a VM has (we can have 1 to 16, incl odd number) so
   I read something like "psrinfo |grep -c on-line" will help: grab the number from
   the right-most  column in the output

b) if it's one vCPU, then run the command in nice mode & bind it:
     nice /path/scriptname
     sed `ps -ef |grep scriptname | grep -v grep` <== to get the pid#
     pbind -b 0 pid#

c) if more than one vCPU, then pbind to half the number of processors/vCPU & 
    run the command.  If there's odd number, say 5, then pbind to 3 vCPUs

    & 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

d) launch my script which will be run within that vCPU or set of vCPUs
   in nice mode which will self-abort if it runs for more than 8 hrs:
     timeout -k 1m 28800s nice /path/myscript
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.

gheistCommented:
Solaris does not allow to split CPU like AIX or Linux.
0
sunhuxAuthor Commented:
The following is for Solaris:
 http://stackoverflow.com/questions/10277221/binding-process-to-multiple-processors-on-sun-solaris-os

So how is it that you don't find it?
0
gheistCommented:
AIX (WLM) and Linux (cgroups) allows a process to be jailed in 10% of CPU if you like. This is not excatlry pbind/bindproc.
For your antivirus scenario it is really of value to add random sleep to scan, centrally managed (read: expensive) AV products allow doing it.
If you still have problems with IO saturation we can find solution for that too.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

nociSoftware EngineerCommented:
you may get away with f.e. Make usingit in parrallel more
with 1 + (half of #vCPU's) as the limit on the number of jobs.
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
gheistCommented:
I am pretty sure it is IO saturation in vmware, can you record iostat 30 while scan is running , i suspect IO wait 90% of CPU time
0
nociSoftware EngineerCommented:
In that case more cpu intensive work, ie.not doing IO, can be loaded onto the system.
0
sunhuxAuthor Commented:
Don't understand what Noci is saying:
get away with f.e. Make usingit in parrallel more
with 1 + (half of #vCPU's) as the limit

I heard in Solaris 10, we can use "project" facility to restrict amount
(in terms of %) that a job can consume but this project facility is
rather complex to configure & use, IMHO
0
sunhuxAuthor Commented:
Now got another challenge:
I have 50 odd Solaris 10 x86 with only 1 vCPU & running this command line
AV scan (no central management) will chew up practically 100% of the CPU.

Without using "project" facility in Solaris, is there any other way to limit its
CPU utilization?

IO saturation is not my current concern (as least not yet)
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
Shell Scripting

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.