The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need an script for restart mysql

Discussion in 'General Discussion' started by persianwhois, Feb 22, 2008.

  1. persianwhois

    persianwhois Well-Known Member

    Joined:
    Apr 18, 2007
    Messages:
    117
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Mahallat
    cPanel Access Level:
    Root Administrator
    Hello,
    I need an script for restart mysql service when server load is more than 10
    Help me please.
     
  2. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
    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. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,482
    Likes Received:
    203
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    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. persianwhois

    persianwhois Well-Known Member

    Joined:
    Apr 18, 2007
    Messages:
    117
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Mahallat
    cPanel Access Level:
    Root Administrator
    Yes, it's true, but apf currently installed on my server. is this work with apf?
     
  5. ramprage

    ramprage Well-Known Member

    Joined:
    Jul 21, 2002
    Messages:
    667
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Canada
  6. persianwhois

    persianwhois Well-Known Member

    Joined:
    Apr 18, 2007
    Messages:
    117
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Mahallat
    cPanel Access Level:
    Root Administrator
    It's good, but how can install and configure PRM (Process Resource Monitor)?
     
  7. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,482
    Likes Received:
    203
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:

    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

     
  8. persianwhois

    persianwhois Well-Known Member

    Joined:
    Apr 18, 2007
    Messages:
    117
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Mahallat
    cPanel Access Level:
    Root Administrator
    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?
     
  9. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
    Its saying PRM killed it for you.
     
  10. persianwhois

    persianwhois Well-Known Member

    Joined:
    Apr 18, 2007
    Messages:
    117
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Mahallat
    cPanel Access Level:
    Root Administrator
    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)
     
  11. pirrup

    pirrup Well-Known Member

    Joined:
    Nov 27, 2004
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    6
    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
     
    #11 pirrup, Feb 25, 2008
    Last edited: Feb 25, 2008
  12. hostmedic

    hostmedic Well-Known Member

    Joined:
    Apr 30, 2003
    Messages:
    559
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Washington Court House, Ohio, United States
    cPanel Access Level:
    DataCenter Provider
    interesting approach

    PHP:
    #!/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
     
  13. NetX

    NetX Well-Known Member

    Joined:
    Jun 18, 2003
    Messages:
    177
    Likes Received:
    0
    Trophy Points:
    16
    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
     
Loading...

Share This Page