![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| average value | su_in99 | UNIX for Dummies Questions & Answers | 2 | 03-10-2007 01:41 PM |
| Need help in wrting Load Script for a Load-Resume type of load. | ankitgupta | Shell Programming and Scripting | 1 | 11-10-2006 12:46 AM |
| Load Average | Heathe_Kyle | UNIX for Dummies Questions & Answers | 3 | 10-24-2006 04:57 PM |
| High cpu load average | squid04 | Red Hat | 2 | 09-27-2006 09:07 AM |
| load average | gfhgfnhhn | UNIX for Advanced & Expert Users | 0 | 09-12-2006 12:49 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi,
I'm new to shell scripting. I need to make a script to add on to my cronjobs. The script must get the value of load average from my server and if its greater than 10 it should stop my apache service. I cant find a way to get the value of load average in integer type to do the check. Any help??? Can anyone give me a sample script??? Jibu |
|
|||||
|
Jibu,
Be careful, you may be breaking one of the Unix forum rule: Code:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post or send a private message where your goal is to get an answer more quickly. |
|
|||||
|
Yes, do not cross-post please.
This was a hidden catch, just to see if you will get my example verbatim. Why I did that ? If you want to run such script, means you have root priviledges, means someone at your organization trust you, means you're not supposed to be a simple user. I would also assume that the server you're running has only apache there, hence you want to switch it off when high load is determined. If not, how you can be sure that this is the application that causes the problem ? In regards to the script - see "man test" for more information. Of course you can compare integer to integer, but bash doesn't have good handling of floating points generated from uptime. Therefore there are few solutions : using awk in this manner : Code:
if echo $loadhttpd | awk '{ if ($loadhttpd < '10') {print "10 is bigger then httpload"}}'; then
I won't write more code, please, try think to about it, and be a real admin, not a user. Regards and no bad feelings. |
![]() |
| Bookmarks |
| Tags |
| load average, performance |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|