Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 13 of 13
  1. #1
    Member persianwhois's Avatar
    Join Date
    Apr 2007
    Location
    Mahallat
    Posts
    114

    Default Need an script for restart mysql

    Hello,
    I need an script for restart mysql service when server load is more than 10
    Help me please.
    Regards,
    Masood Yarmohammadi

  2. #2
    Member
    Join Date
    Mar 2006
    Posts
    1,215

    Default

    This is an odd request. If your mysql failed, it will start automagically via cpanel scripts. If your mysql is causing the load of 10 or above, then you should consider fixing or eliminating the querys causing this issue or optimize your my.cnf or both. Interrupting service with restarts as a fix is not a good policy.

  3. #3
    cPanel Product Evangelist Infopro's Avatar
    Join Date
    May 2003
    Location
    Pennsylvania
    Posts
    7,894
    cPanel/Enkompass Access Level

    Root Administrator

    Lightbulb

    Correct me if I'm wrong but I think you have that backwards. Sounds like you need a script that'll kill anything causing server load to spike.
    This should help there. http://www.configserver.com/cp/csf.html

  4. #4
    Member persianwhois's Avatar
    Join Date
    Apr 2007
    Location
    Mahallat
    Posts
    114

    Default

    Quote Originally Posted by Infopro View Post
    Correct me if I'm wrong but I think you have that backwards. Sounds like you need a script that'll kill anything causing server load to spike.
    This should help there. http://www.configserver.com/cp/csf.html
    Yes, it's true, but apf currently installed on my server. is this work with apf?
    Regards,
    Masood Yarmohammadi

  5. #5
    Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    675

    Default

    You'll want to use PRM
    http://rfxnetworks.com/prm.php

    You can set the server load per application and restart limits.
    Upload Guardian 2.0 - Sign up for our early beta
    ServerProgress - Server security, consulting and assistance

  6. #6
    Member persianwhois's Avatar
    Join Date
    Apr 2007
    Location
    Mahallat
    Posts
    114

    Default

    Quote Originally Posted by ramprage View Post
    You'll want to use PRM
    http://rfxnetworks.com/prm.php

    You can set the server load per application and restart limits.
    It's good, but how can install and configure PRM (Process Resource Monitor)?
    Regards,
    Masood Yarmohammadi

  7. #7
    cPanel Product Evangelist Infopro's Avatar
    Join Date
    May 2003
    Location
    Pennsylvania
    Posts
    7,894
    cPanel/Enkompass Access Level

    Root Administrator

    Lightbulb

    Quote Originally Posted by persianwhois View Post
    Yes, it's true, but apf currently installed on my server. is this work with apf?

    You might want to read up on CSF a bit more I think. From the install.txt:

    http://www.configserver.com/free/csf/install.txt

    If you would like to disable APF+BFD (which you will need to do if you have
    them installed otherwise they will conflict horribly):

    sh disable_apf_bfd.sh

    That's it. You can then configure csf and lfd in WHM, or edit the files
    directly in /etc/csf/*

  8. #8
    Member persianwhois's Avatar
    Join Date
    Apr 2007
    Location
    Mahallat
    Posts
    114

    Default Rpm

    Hi,
    I install and configure RPM. it's a great tools.
    After install, followin email send for me from my server:
    Code:
    This is an automated status warning from linux.myserverhosting.us. The process (8507) has exceeded defined resource limits, as such a kill signal was invoked from the process resource monitor.
    
    - Event Summary:
    USER: ikaooe
    PID : 8507
    CMD : /usr/bin/php
    CPU%: 0 (limit: 40)
    MEM%: 0 (limit: 20)
    PROCS: 246 (limit: 25)
    What's this? process no 8507 killed by RPM or must kill manually?
    Regards,
    Masood Yarmohammadi

  9. #9
    Member
    Join Date
    Mar 2006
    Posts
    1,215

    Default

    Its saying PRM killed it for you.

  10. #10
    Member persianwhois's Avatar
    Join Date
    Apr 2007
    Location
    Mahallat
    Posts
    114

    Default

    Quote Originally Posted by jayh38 View Post
    Its saying PRM killed it for you.
    Thank you.
    I have new problem with RPM, can you help me?
    RPM kill apache proccess more than 150 on my server and it's not good, because apache is down and must start again. So, i can add nobody in RPM ignore list for resolve this issue, but it's not good too, because nobody user can run many proccess and RPM can't kill this.
    How can resolve this issue?

    - Event Summary:
    USER: nobody
    PID : 6349
    CMD : /usr/local/apache/bin/httpd
    CPU%: 0 (limit: 65)
    MEM%: 0 (limit: 25)
    PROCS: 250 (limit: 150)
    Regards,
    Masood Yarmohammadi

  11. #11
    Member
    Join Date
    Nov 2004
    Posts
    55

    Default

    you can always use this and put it in a cronjob (save file as load.pl for example)


    #!/usr/bin/perl -w
    #use strict;
    $|++;
    open(LOAD,"/proc/loadavg") || die "couldn't open /proc/loadavg: $!\n";
    my @load=split(/ /,<LOAD>);
    close(LOAD);
    if ($load[0] > 9) {
    `/sbin/service httpd restart`;
    }

    just change the httpd to the service you want restarted, but if it's a script that causes the high load i would restart httpd.

    Cheers,

    pirrup
    Last edited by pirrup; 02-25-2008 at 11:59 AM.

  12. #12
    Member hostmedic's Avatar
    Join Date
    Apr 2003
    Location
    Ohio
    Posts
    556
    cPanel/Enkompass Access Level

    DataCenter Provider

    Default interesting approach

    PHP Code:
    #!/usr/bin/perl -w
    #use strict;
    $|++;
    open(LOAD,"/proc/loadavg") || die "couldn't open /proc/loadavg: $!\n";
    my @load=split(/ /,<LOAD>);
    close(LOAD);
    if (
    $load[0] > 9) {
    `
    /sbin/service httpd restart`;

    Looks good
    Is there a way to have it email us and tell us if it restarts - (only if it restarts?)

    also - is there a way to tell it not to restart unless the load is over say 4 or 5

    glenn



    Feel like your Cloud Provider's just weathering the storm? Hop Off the Cloud - The Weathers nicer over here.

  13. #13
    Registered User
    Join Date
    Jun 2003
    Posts
    177

    Default

    An example:

    (This values are defined by the user admin)
    X = 5
    Y = 10

    Using the values:

    If load < 5 exim and httpd then both are working
    If 5 < load < 10 then exim is stopped but httpd is working
    If load > 10 then exim and httpd are stopped

    When the load downs:

    If 5 < load < 10 then httpd is restarted
    If load < 5 then exim is restarted (exim and httpd are working)


    The email messages obviously are sent when exim is working

Similar Threads & Tags
Similar threads

  1. Replies: 1
    Last Post: 05-16-2010, 09:53 AM
  2. Replies: 1
    Last Post: 05-16-2010, 09:53 AM
  3. Restart Script
    By biggdogg285 in forum cPGS Discussions
    Replies: 0
    Last Post: 02-27-2007, 10:36 AM
  4. Auto Restart Script
    By Netsender in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 07-07-2004, 12:18 PM
  5. a script to restart apache.
    By Chelp2 in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 06-04-2003, 08:53 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube