Server is facing high load and NS1 is not responding

paksociety

Verified User
Joined
Jul 11, 2013
Messages
89
Hello All!

I have two problems.
First my system is facing high load and after message of high load it goes offline here are detail of 3 messages after that server goes offline.
Its my server detail
Code:
Processor Name          	Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz
Vendor ID	                GenuineIntel
Processor Speed (MHz)	1999.999
Processor Name	         Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz
Vendor ID	                 GenuineIntel
Processor Speed (MHz)	1999.999
Total Memory	         1048576 kB
Free Memory	          335472 kB
Total Swap Memory	  2097144 kB
Free Swap Memory	 2036276 kB

Here is message 1
Code:
This is an automated message notifying you that the 5 minute load average on your system is 28.77.
This has exceeded the 10 threshold.

One Minute      - 57.1
Five Minutes    - 28.77
Fifteen Minutes - 13.38

top - 11:36:25 up 1 day,  4:26,  0 users,  load average: 74.29, 40.06, 18.50
Tasks: 243 total,   8 running, 235 sleeping,   0 stopped,   0 zombie
Cpu(s):  8.0%us,  4.4%sy,  0.0%ni, 85.0%id,  1.4%wa,  0.0%hi,  0.1%si,  1.1%st
Mem:   1048576k total,  1041084k used,     7492k free,     1340k buffers
Swap:  2097144k total,  1756280k used,   340864k free,    20160k cached

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
 105 root      10  -5     0    0    0 D  0.2  0.0   0:21.02 [kswapd0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
9622 admin     16   0  148m  17m 3316 D  0.1  1.7   0:00.28 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9731 admin     18   0  139m 8496 2932 D  0.1  0.8   0:00.05 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9652 admin     16   0  148m  18m 3240 D  0.1  1.8   0:00.30 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9703 admin     16   0  139m 9952 3464 S  0.1  0.9   0:00.49 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9732 admin     18   0  138m 7352 2904 D  0.1  0.7   0:00.03 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9130 admin     16   0  153m 9836 4148 D  0.0  0.9   0:08.57 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9236 admin     17   0  162m 7640 3940 D  0.0  0.7   0:04.37 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9244 admin     16   0  162m 8188 4060 D  0.0  0.8   0:04.35 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9267 admin     16   0  170m 6488 4080 D  0.0  0.6   0:03.95 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9424 admin     16   0  170m   9m 4492 R  0.0  1.0   0:03.96 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9518 admin     16   0  165m  12m 4020 D  0.0  1.2   0:01.48 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9524 admin     16   0  150m 9312 3892 D  0.0  0.9   0:01.67 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9539 admin     16   0  165m 8688 4128 D  0.0  0.8   0:01.61 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9545 admin     16   0  165m 7872 3936 D  0.0  0.8   0:01.55 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9566 admin     16   0  153m 6052 4020 D  0.0  0.6   0:00.94 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9568 admin     16   0  165m 9004 4060 D  0.0  0.9   0:01.65 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9601 admin     16   0  148m  15m 3280 D  0.0  1.5   0:00.33 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9619 admin     16   0  165m  32m 3744 D  0.0  3.2   0:00.65 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
9620 admin     18   0  155m  23m 3424 R  0.0  2.3   0:00.46 /usr/sbin/httpd -k start -DSSL

It is 2nd one
Code:
This is an automated message notifying you that the 5 minute load average on your system is 41.35.
This has exceeded the 10 threshold.

One Minute      - 95.93
Five Minutes    - 41.35
Fifteen Minutes - 16.13

top - 04:52:28 up 1 day, 18:27,  0 users,  load average: 99.30, 44.77, 17.65
Tasks: 283 total,   6 running, 277 sleeping,   0 stopped,   0 zombie
Cpu(s):  9.1%us,  5.0%sy,  0.0%ni, 82.5%id,  2.0%wa,  0.0%hi,  0.1%si,  1.3%st
Mem:   1048576k total,  1021056k used,    27520k free,     1212k buffers
Swap:  2097144k total,  1452144k used,   645000k free,    19184k cached

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
1721 root      18   0  136m 4668 2464 S  0.2  0.4   0:04.07 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
31946 root      16   0 12888 1324  860 R  0.2  0.1   0:00.02 /usr/bin/top -c -b -n 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
31919 root      16   0 12888 1324  860 R  0.1  0.1   0:00.02 /usr/bin/top -c -b -n 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
31954 apache    15   0  136m 4400 1820 S  0.1  0.4   0:00.01 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
   1 root      15   0 10368  444  416 S  0.0  0.0   0:00.04 init [3]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
   2 root      RT  -5     0    0    0 S  0.0  0.0   0:00.11 [migration/0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
   3 root      34  19     0    0    0 S  0.0  0.0   0:00.08 [ksoftirqd/0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
   4 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 [watchdog/0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
   5 root      10  -5     0    0    0 S  0.0  0.0   0:00.14 [events/0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
   6 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 [khelper]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
   7 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 [kthread]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
   9 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 [xenwatch]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  10 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 [xenbus]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  16 root      RT  -5     0    0    0 S  0.0  0.0   0:00.32 [migration/1]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  17 root      34  19     0    0    0 S  0.0  0.0   0:00.16 [ksoftirqd/1]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  18 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 [watchdog/1]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  19 root      10  -5     0    0    0 S  0.0  0.0   0:00.01 [events/1]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  22 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 [kblockd/0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  23 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 [kblockd/1]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  24 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 [cqueue/0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  25 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 [cqueue/1]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  29 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 [khubd]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
  31 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 [kseriod]

And it is 3rd one

Code:
This is an automated message notifying you that the 5 minute load average on your system is 47.63.
This has exceeded the 10 threshold.

One Minute      - 86.13
Five Minutes    - 47.63
Fifteen Minutes - 20.11

top - 10:11:11 up 18 days,  2:34,  0 users,  load average: 86.84, 49.04, 20.86
Tasks: 268 total,   2 running, 266 sleeping,   0 stopped,   0 zombie
Cpu(s):  7.3%us,  4.0%sy,  0.0%ni, 86.5%id,  1.4%wa,  0.0%hi,  0.1%si,  0.7%st
Mem:   1048576k total,  1039272k used,     9304k free,     2576k buffers
Swap:  2097144k total,  1391324k used,   705820k free,    18948k cached

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
 105 root      10  -5     0    0    0 S  5.3  0.0   1:38.52 [kswapd0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
27499 admin     16   0  164m  35m 3884 D  1.4  3.5   0:00.56 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
27535 admin     16   0  164m  36m 4012 D  1.2  3.5   0:00.65 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
27526 admin     16   0  164m  34m 3988 D  0.5  3.4   0:00.65 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
27533 admin     16   0  164m  35m 3816 D  0.3  3.5   0:00.52 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
27534 admin     16   0  164m  35m 4004 D  0.3  3.5   0:00.55 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
27621 root      16   0 12888 1308  860 R  0.3  0.1   0:00.03 /usr/bin/top -c -b -n 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
1446 mysql     18   0  556m  12m 2212 D  0.2  1.2 224:49.28 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --log-error=/var/lib/mysql/vps.paksociety.com.err --pid-file=/var/lib/mysql/vps.paksociety.com.pid                                                                                                                                                                                                                                                                                                                                                              
27508 admin     16   0  150m  22m 3416 D  0.2  2.2   0:00.17 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
27564 admin     15   0  140m  11m 3280 S  0.2  1.1   0:00.05 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
27619 apache    15   0  138m 9668 3404 S  0.2  0.9   0:00.08 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
27633 root      16   0 12888 1328  868 D  0.2  0.1   0:00.01 /usr/bin/top -c -b -n 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
27643 apache    15   0  137m 6124 1900 S  0.2  0.6   0:00.02 /usr/sbin/httpd -k start -DSSL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
   1 root      15   0 10368  512  484 S  0.0  0.0   0:00.10 init [3]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
   2 root      RT  -5     0    0    0 S  0.0  0.0   0:01.28 [migration/0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
   3 root      34  19     0    0    0 S  0.0  0.0   0:01.14 [ksoftirqd/0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
   4 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 [watchdog/0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
   5 root      10  -5     0    0    0 S  0.0  0.0   0:01.62 [events/0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
   6 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 [khelper]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
   7 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 [kthread]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
   9 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 [xenwatch]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  10 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 [xenbus]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  16 root      RT  -5     0    0    0 S  0.0  0.0   0:02.85 [migration/1]

Sharing 3 messages for beter understanding.

Please help me to resolve this.

Now my 2nd problem is
I have csf installed and it is showing me error of ns1.site.com is not responding plus intodns.com also showing the same problem.

Please tell me how to correct it??
i created ns1 and ns2 on my domain panel.
and in direct admin too.
i have 2 ips. please tell me how to resolve this?? and i want that if i enter direct ip address my site open means ip=site.com

Please guys help me, please
 
Last edited:
That is what I thought. There is nothing you can do, it is caused by the host or even another VPS on the same host. I saw the same thing and it is due to high iowait times. They don't really cause a lot of CPU usage but they are cause the load values to be quite high. Especially if you have anything that wants to write to disk ( log files, database, etc ). Contact your provider and hopefully they can help trace the problem, in my case I tried for about 2 months to get my old provider to find the issue (they initially blamed my VPS and took it offline). After providing my provider with a ton of debug logs like sar and iostat I was able to prove to them, that it was my VPS that reported the high loads, but it was not mine that caused it, and that it was high iowait ( waiting for I/O to complete ) that was the real issue. I switched providers and haven't had an issue since.

As for your second issue, I assume you have a firewall blocking your access, that you need to look at iptables (you can see your current config via 'iptables --list -n') and make sure you aren't blocking any IP address or ports that you want/need to use. As for making sure your site.com shows when doing http://$IP, just make sure you have a "DocumentRoot" defined in your httpd.conf that isn't enclosed in VirtualHost tags, and have that DocumentRoot point to the site.com you want to show.
 
As far as problem 2:
I have csf installed and it is showing me error of ns1.site.com is not responding plus intodns.com also showing the same problem.
In order to be able to investigate what's really wrong, we should need the real domain name, otherwise we can't lookup the problem.
 
Also... it appears you're using a lot of swap memory. This can cause severe issues with slowness, as swap memory is stored on a physical hard drive and data stored on hard drives takes a long time to move to working memory when it's needed.

If rebooting your VPS doesn't resolve your swap memory issue then you need to resoove the issue with your provider.

Jeff
 
thanks 4 rply . plz tel me how can i ristrict swap memory to a specific point. nd yes when i restart it site becm online again. but nw direct admin is nt shwng heavy load bt vps goes ofline infact nt acesble because solusv admin shows it online. any help?
 
About the NS1 not working.
Intodns.com strangely enough does not give a real error on it, but the dns check of mxtoolbox does.
You can also see this in the Intodns report:

ns2.yourdomain.com ['198.167.138.238'] [TTL=14400] -> no problem here
ns1.yourdomain.com [] (NO GLUE) [TTL=14400] <--- No glue record.

You have to do the same for ns1.yourdomain.com as you did for ns2.yourdomain.com with your registrar. Set the ip (make a glue record) for ns1.yourdomain.com and if that is done, your ns1 will start responding again.
Could take up to 72 hours to sync the dns servers over the world though after the change, so you have to keep that in mind.

I hope Nobaloney or somebody can help you with the other problems.
 
Swap memory is only restricted by having enough real memory (RAM) to hold everything that is running. If a lot of swap is constantly being used, then your VPS doesn't have enough real memory allocated to it, and you need to speak with your provider about adding more (it will be more expensive).

To change your DocumentRoot, that would involve editing some file(s) directly namely the /etc/httpd/conf/httpd.conf and/or the /usr/local/directadmin/data/users/$USERNAME/httpd.conf files. Not only would you need to modify the DocumentRoot setting, but the associated Directory value to match your DocumentRoot, for example:
Code:
<VirtualHost 99.99.99.99:80 >
        ServerName www.example.com
        ServerAlias www.example.com 
        ServerAdmin [email protected]
[COLOR="#FF0000"]        DocumentRoot /home/dauser/domains/example.com/public_html[/COLOR]
        ScriptAlias /cgi-bin/ /home/dauser/domains/example.com/public_html/cgi-bin/
        UseCanonicalName OFF
        <IfModule !mod_ruid2.c>
                SuexecUserGroup dauser dauser
        </IfModule>
        CustomLog /var/log/httpd/domains/example.com.bytes bytes
        CustomLog /var/log/httpd/domains/example.com.log combined
        ErrorLog /var/log/httpd/domains/example.com.error.log

[COLOR="#FF0000"]        <Directory /home/dauser/domains/example.com/public_html>[/COLOR]
                php_admin_flag safe_mode OFF
                php_admin_flag engine ON
                php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f [email protected]'
                php_admin_value open_basedir /home/dauser/:/tmp:/var/tmp:/usr/local/lib/php/
        </Directory>
        AddHandler server-parsed html
</VirtualHost>

Note the two lines in red above, both would need to be updated together.
 

Please tell me that according to my logs is 1 GB ram is not sufficient for my site??
and if it is showing 1 GB than its really 1 GB or less than 1 GB?????


And is there any script which automatically restart vps or apache when server is not responding??? or system load goes up from a certain limit???

Thanks every one. will tell you when apply it :-)
Will share results:-)
 
Last edited:
Also... it appears you're using a lot of swap memory. This can cause severe issues with slowness, as swap memory is stored on a physical hard drive and data stored on hard drives takes a long time to move to working memory when it's needed.

If rebooting your VPS doesn't resolve your swap memory issue then you need to resoove the issue with your provider.

Jeff

Sir from your another post i came to know that you was using a script ro restart apache when system load goes above 10 can you please share it with me??
Regards
 
Swap memory is only restricted by having enough real memory (RAM) to hold everything that is running. If a lot of swap is constantly being used, then your VPS doesn't have enough real memory allocated to it, and you need to speak with your provider about adding more (it will be more expensive).

To change your DocumentRoot, that would involve editing some file(s) directly namely the /etc/httpd/conf/httpd.conf and/or the /usr/local/directadmin/data/users/$USERNAME/httpd.conf files. Not only would you need to modify the DocumentRoot setting, but the associated Directory value to match your DocumentRoot, for example:
Code:
<VirtualHost 99.99.99.99:80 >
        ServerName www.example.com
        ServerAlias www.example.com 
        ServerAdmin [email protected]
[COLOR="#FF0000"]        DocumentRoot /home/dauser/domains/example.com/public_html[/COLOR]
        ScriptAlias /cgi-bin/ /home/dauser/domains/example.com/public_html/cgi-bin/
        UseCanonicalName OFF
        <IfModule !mod_ruid2.c>
                SuexecUserGroup dauser dauser
        </IfModule>
        CustomLog /var/log/httpd/domains/example.com.bytes bytes
        CustomLog /var/log/httpd/domains/example.com.log combined
        ErrorLog /var/log/httpd/domains/example.com.error.log

[COLOR="#FF0000"]        <Directory /home/dauser/domains/example.com/public_html>[/COLOR]
                php_admin_flag safe_mode OFF
                php_admin_flag engine ON
                php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f [email protected]'
                php_admin_value open_basedir /home/dauser/:/tmp:/var/tmp:/usr/local/lib/php/
        </Directory>
        AddHandler server-parsed html
</VirtualHost>

Note the two lines in red above, both would need to be updated together.


I have this file through file editor option in Direct admin /etc/httpd/conf/httpd.conf, no other file as you mentioned.

I have to put these lines into this file??? and replace ip and website address???
because no such code is already there.


Regards
 

Please tell me that according to my logs is 1 GB ram is not sufficient for my site??
and if it is showing 1 GB than its really 1 GB or less than 1 GB?????

I got tired of yuour shouting and edited your post. Please do not shout in your posts; it turns people off and they just won't respond. I don't know how looking at logs will tell you if you need more memory or not. I can understand why you might not want to pay for more memory if it doesn't solve your problem. But I'm not going to be able to tell you unless I do a forensic exam of your server while it's running over time, and that's probably going to cost a lot more than adding memory for a month or two to see if it solves the problem. Perhaps others who post here will know with certainty, but i doubt it.

Generally high use of swap memory means not enough memory.

Generally high server load generally means nnot enough memory.

Both can be identified through the top command.

Sir from your another post i came to know that you was using a script ro restart apache when system load goes above 10 can you please share it with me??
I didn't write it; I don't generally give out scripts I haven't either written or studied, and in this case I'm not even sure if I should.

That said, check these forums; I or someone else may have posted it or something simiar.

All you need to do is pars the output of the uptime command and if the serverload is above a certain point, do an apache restart.
 
I dont know how to tell people about my problem other than replying to thread?

However i found following script to restart apache after load goes 20.
Code:
Sometimes one of apache nodes tends to go crazy causing the server to be inaccessible for us. A good solution would be to analyze the log files that are generated but we don’t have much spare time so I came up with a simple script that will monitor the apache2 web server and take action when needed.

The script both checks whether apache2 is running and if the server load isn’t too high. If the server load goes above 20 it restarts the apache2 web server. The script also checks whether apache2 is actually running on the host machine, and if it’s not, it gives the start command.

It's a really simple yet effective script:
[syntax=bash]#!/bin/sh
#*/5 * * * * /home/scripts/apache_check >> /home/scripts/apache_check.log
# Bash script that checks apache:
# - Apache running or not, if needed start it up again
# - If server load is higher than 20, restart apache
#
# Script to be ran as cronjob (every 5 minutes)
# */5 * * * * /path/to/apache_check >> /path/to/apache_check.log
 
echo "Apache checker running at " `date`
run=`ps ax | grep /usr/sbin/apache2 | grep -v grep | cut -c1-5 | paste -s -`
if [ "$run" ];
then
echo "Apache is running"
else
echo "Apache seems to be down, starting it up again"
/etc/init.d/apache2 start
fi

check=`uptime | sed 's/\./ /g' | awk '{print $10}'`
if [ $check -gt 20 ]
then
echo "Server load too high ($check), restarting apache"
/etc/init.d/apache2 restart
else
echo "Server load OK ($check)"
fi

echo "----------------"
[/syntax]

I am not a developer nor a linux user, dont know about commands.
please any one tell me how to use script.
plus how to change limit of 20 to 10.

Regrds
 
As is it's probably not going to run successfully on a DirectAdmin basee server. The instructions for running it are in the first few lines; the ones commented out.

You write that you're not a linux user, but y ou are. So you need tolearn how to do these things, or hire someone to do them for you.

I'm going to check to see if I can upload the script I use to my downloads directory, and if so I'll place a link to it on these forujs. But in the meantime if you search these forums you may find that I've given it out here before; I'm not sure.

Jeff
 
Thanks nobaloney ,
please tell me i have to juat increase ram? currentlly i have 2 core cpu. i have to increase it also or not???

Unfortunately my service provider told me that planes are not upgradeable.
Now i have very much need of the script to restart apache after certain load.
 
Last edited:
Restarting apache because it is using alot of resources is absolutely unacceptable. You should NEVER restart apache just because it is busy. Learn how to use caching and tweak your config settings.
 
Back
Top