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.

Hook doesn't execute

Discussion in 'cPanel Developers' started by aferrer, Jun 15, 2012.

  1. aferrer

    aferrer Registered

    Joined:
    May 24, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi all,

    I've implemented a Perl module with a function to copy to another location and compress domain logs. I've registered it with manage_hooks successfully. This is what it looks like:

    [/usr/local/apache/domlogs]# /usr/local/cpanel/bin/manage_hooks list
    Stats:
    RunUser:
    stage: pre
    weight: 1000
    exectype: module
    hook: Capside::Rotatelogs::rotate

    As I understand [1], this should run right before cpanellogd comes in to process a user's log. However, if I manually run a user's statistics through WHM, nothing happens. I've put some lines in the function to print messages to STDERR as it goes, but nothing appears in /usr/local/cpanel/error_log, where I've read it should go and where messages from cpanellogd go, so I think the hook is never executed (I'm guessing that if the 'hook manager' had any trouble running the module it would appear here too).

    Any idea on what I'm missing? Is there something else I need to do for the hook to execute the function? Or is it that it won't work when run manually from WHM?

    Thanks!

    [1] Stats Functions | Standardized Hooks
     
  2. cosbeta

    cosbeta Member

    Joined:
    Jan 8, 2012
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I have the same issue.
    I have many servers with cpanel with the same configuration
    but yesterday , I found one of my cpanel server's cpanel hook stop working, /scripts/upcp --forece does not help
     
  3. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    aferrer,

    Does your hook run if you call the runweblogs script?
    ex:
    `/usr/local/cpanel/scripts/runweblogs aferrer` (a username must be provided)

    Regards,
    -David
     
  4. aferrer

    aferrer Registered

    Joined:
    May 24, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi David,

    thanks for your response. Yes, the hook runs with runweblogs:

    [2012-06-18 08:49:48 +0200] info [cpanellogd] ---debug_hooks---
    [2012-06-18 08:49:48 +0200] info [cpanellogd] msg: Beginning execution of module hook.
    [2012-06-18 08:49:48 +0200] info [cpanellogd] context: Stats::RunUser
    [2012-06-18 08:49:48 +0200] info [cpanellogd] stage: pre
    [2012-06-18 08:49:48 +0200] info [cpanellogd] point: main
    [2012-06-18 08:49:48 +0200] info [cpanellogd] hook: Capside::Rotatelogs::rotate
    [2012-06-18 08:49:48 +0200] info [cpanellogd] weight: 1000

    What's the difference between running runweblogs and the daily processing of stats and logs? To copy and compress domlogs, do you think I should put the hook somewhere else?

    Thanks!
     
  5. aferrer

    aferrer Registered

    Joined:
    May 24, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    It seems the problem was in the script, I could fix it with the output provided by runweblogs. Problem is I couldn't find a log that showed this information and I couldn't see whether the hook was being executed, but it looks like it always run. Is the runweblogs output written somewhere? (I have debug_hooks enabled).

    Thanks!
     
  6. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    There are only a few places that actually trigger the use of runweblogs directly...and those places don't get run periodically. The output is not captured, but simply sent to STDOUT when invoked from the command line and discarded with invoked by a caller. You'd have to redirect the output when you call it or modify runweblogs to capture the output (hack runweblogs, which I recommend against).

    Regards,
    -DavidN
     
Loading...

Share This Page