Results 1 to 6 of 6

Thread: Hook doesn't execute

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    3
    cPanel/WHM Access Level

    Root Administrator

    Default Hook doesn't execute

    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. #2
    Member
    Join Date
    Jan 2012
    Posts
    5
    cPanel/WHM Access Level

    Root Administrator

    Default Re: Hook doesn't execute

    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. #3
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    570

    Default Re: Hook doesn't execute

    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
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Requests

  4. #4
    Registered User
    Join Date
    May 2012
    Posts
    3
    cPanel/WHM Access Level

    Root Administrator

    Default Re: Hook doesn't execute

    Quote Originally Posted by cPanelDavidN View Post
    Does your hook run if you call the runweblogs script?
    ex:
    `/usr/local/cpanel/scripts/runweblogs aferrer` (a username must be provided)
    -David
    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. #5
    Registered User
    Join Date
    May 2012
    Posts
    3
    cPanel/WHM Access Level

    Root Administrator

    Default Re: Hook doesn't execute

    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. #6
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    570

    Default Re: Hook doesn't execute

    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
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Requests

Similar Threads

  1. function hook doesn't run
    By danmc in forum cPanel Developers
    Replies: 1
    Last Post: 05-08-2012, 05:33 PM
  2. whm hook?
    By bitter_ in forum cPanel Developers
    Replies: 3
    Last Post: 07-13-2010, 10:14 AM
  3. killacc hook
    By oflus in forum cPanel Developers
    Replies: 1
    Last Post: 05-13-2009, 09:46 AM
  4. doaddpop hook?
    By dorris in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 04-16-2008, 05:32 AM
  5. newftpuser hook
    By rapidot in forum cPanel & WHM Discussions
    Replies: 15
    Last Post: 08-03-2007, 05:56 PM