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.

Receive email before generate a full backup

Discussion in 'cPanel Developers' started by _El_Chojin_, Jan 11, 2012.

  1. _El_Chojin_

    _El_Chojin_ Member

    Joined:
    May 22, 2009
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Hi:
    I', trying to code a script that sends me a message before the user generate a full backup.
    I have opened a ticket but this can't be done from WHM, so is needed to code a custom script.
    They have recommended me to use CustomEventHandler:
    /http://httpupdate.cpanel.net/cpanelsync/11.30.5.3/cpanel/Cpanel/CustomEventHandler.pm.sample.bz2

    I have downloaded that file and i have some questions:
    1: On that file put;
    if ($module eq 'ftp') {
    if ($event eq 'addftp') {
    # do something with ftp
    } elsif ($event eq 'delftp') {

    }
    }

    Instead of that i need to put a module of cpanel or i can put there what i want? because i think should be somthing of cpanel, otherwise how can detect cpanel that i want to execute that before cpbackupruns?

    Anyone can help me a bit more with this simple script that will help me a lot to check some load issues.

    Thanks.
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Just FYI regarding load issues, these backups (by default) run at a nice level of +9, which can be customized via Tweak Settings. Note that a nice level that high can skew the load average so that the load average is high despite the machine not using many of its resources. To summarize, this is due to the load average being an average of how long it takes a process to get some CPU time and a nice +9 process is intentionally avoiding use of the CPU - thus the higher load average reported (not necessarily because of IO or compression, though those do contribute to load average).

    You may find it easier to wait until 11.32 comes out, because that will have "Standard Hooks" - a much improved hooking system that lets you have several pre and post hooks for every cPanel function. For example, you could hook the backups function. You can find the raw call to the fullbackup function in /usr/local/cpanel/base/frontend/x3/backup/dofullbackup-include.html as of writing.

    Version 11.32 is in EDGE builds as version 11.31, and should reach production tiers in the coming weeks. Documentation for Standard Hooks (introduced in 11.31/11.32) is available at: Abstract | Standardized Hooks
     
  3. _El_Chojin_

    _El_Chojin_ Member

    Joined:
    May 22, 2009
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    The problem is that i need to identify what is using my net and server loads some times, i thinked before of a DDoS but not since firewall blocks fine all DDoS and sometimes i see on munin more than 10Mb/s of net usage, and i'm thinking is someone downloading their backups.
    I have installed othe tools to check if this is a problem when someone download their heavy backups but i can't fully identify problem so that is my reason to first check it net loads are when someone is downloading backup and server load if someone generate backups of all their accounts at same time.
    Threre is no a quick fix until 11.32 is in stable? i would appreciate any help.

    Thanks.
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You could read up on the legacy hooks system (in 11.30 and earlier) which isn't nearly as robust a system: Function Hooks
     
  5. _El_Chojin_

    _El_Chojin_ Member

    Joined:
    May 22, 2009
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    And what is the module name, and the function that i should use to the hook? i want to execute it when the user generate the full backup. This is for: /usr/local/cpanel/hooks/$module/$function

    Thanks.
     
  6. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    As stated above: "You can find the raw call to the fullbackup function in /usr/local/cpanel/base/frontend/x3/backup/dofullbackup-include.html as of writing." - and you can apply this skill to anything else you want to hook from the cPanel UI.

    You will need root access to implement the hook as well as read that file. I
     
  7. _El_Chojin_

    _El_Chojin_ Member

    Joined:
    May 22, 2009
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Hi:
    Sorry tu bug you more but i don' understand :(

    I have seen that file and inside has this:
    So i dont know what you mean with find the raw call to the fullbackup function.
    :/
     
  8. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    See that <cpanel ... > tag? That's an API1 call. You can correlate that with our API1 documentation to learn more about it and how to call API1 from the XML-API.
     
Loading...

Share This Page