Results 1 to 3 of 3

Thread: Looking up cPanel API call parameters

  1. #1
    Member MattDees's Avatar
    Join Date
    Apr 2005
    Location
    Houston, TX
    Posts
    409

    Default Looking up cPanel API call parameters

    So, I'm not sure if I posted this here previous or not, but I have a nifty little dumper CustomEventHandler I wrote that logs all cPanel API calls made to the error_log. This means that you can see what parameters it was called with which is very handy if you need information on how API1/API2 calls are made (for theme development, etc).

    This will only print returned data for API2 calls, API1 calls print data rather than return so it is rather difficult to do this.

    Installation:

    wget sdk.cpanel.net/utils/CustomEventHandler-Dumper.tar.gz
    tar vzxf CustomEventHandler-Dumper.tar.gz
    cp CustomEventHandler-Dumper/CustomEventHandler.pm /usr/local/cpanel/Cpanel
    cp CustomEventHandler-Dumper/Dumper.pm /usr/local/cpanel/perl/Data
    tail -f /usr/local/cpanel/logs/error_log

    and hit something in the interface.

    NOTE: this shold never by run on a production server, thigns like password of new email/ftp/whatever accounts will be logged to the error_log with this enabled

    NOTE: if you wish to filter to look for calls within a specific module, please check out the commented line within the event function of CustomEventHandler.pm

    When you hit an API call in cPanel (which you will several times for every page):

    statsbar:stat
    $apiv = 2
    $type = post
    -----
    $cfgref

    $VAR1 = {
    'rowcounter' => 'mainstats',
    'infinitylang' => 'true',
    'display' => 'diskusage|bandwidthusage'
    };

    -----
    $dataref

    $VAR1 = [
    {
    'percent10' => 0,
    'normalized' => 1,
    'rowtype' => 'even',
    'percent20' => 0,
    'item' => 'Monthly Bandwidth Transfer',
    'zeroisunlimited' => 1,
    'name' => 'bandwidthusage',
    '_maxed' => 1,
    '_count' => 0,
    'units' => 'MB',
    'percent' => 0,
    '_max' => 'unlimited',
    'count' => 0,
    'max' => '∞ MB',
    'percent5' => 0,
    'langkey' => 'INDXBandwidth',
    'module' => 'Stats',
    'feature' => 'bandwidth',
    'id' => 'bandwidthusage'
    },
    {
    'percent10' => 0,
    'normalized' => 1,
    'percent5' => 0,
    'rowtype' => 'odd',
    'percent20' => 0,
    'item' => 'Disk Space Usage',
    'zeroisunlimited' => 1,
    'name' => 'diskusage',
    'langkey' => 'INDXDiskUsage',
    '_maxed' => 0,
    '_count' => '1.32',
    'units' => 'MB',
    'module' => 'Quota',
    '_max' => 1000,
    'percent' => 0,
    'count' => '1.32',
    'max' => '1000 MB',
    'id' => 'diskusage'
    }
    ];
    Last edited by MattDees; 09-09-2009 at 10:08 AM.
    Matt Dees

  2. #2
    Member MattDees's Avatar
    Join Date
    Apr 2005
    Location
    Houston, TX
    Posts
    409

    Default

    This has been updated to log API1 parameters as well.

    This now relies on /dev/shm being accessible, so please remember, development servers ONLY.
    Matt Dees

  3. #3
    Member
    Join Date
    May 2008
    Posts
    30

    Default

    I just thought I'd mention that I've found this to be supremely useful in debugging API calls as well. It's a great way to verify that you are, indeed, making the calls you think you are, for example, and also gives you a chance to inspect the output from a different interface as well.

    For example you make a call and it doesn't produce any output. Check the error_log after installing this, and if you don't see it in there--you know you probably aren't interfacing with WHM correctly. Or you do see it, but the parameters aren't what you thought they were--also good information that would be difficult to obtain otherwise.

    Golden.

Similar Threads

  1. API Call Safe?
    By hostb in forum cPanel Developers
    Replies: 9
    Last Post: 09-26-2011, 12:07 PM
  2. API call from within CustomEventHandler
    By tizoo in forum cPanel Developers
    Replies: 2
    Last Post: 06-02-2011, 10:59 AM
  3. Confused on parameters for XML-API in 11.25
    By ozace in forum cPanel Developers
    Replies: 3
    Last Post: 10-22-2009, 10:35 AM
  4. API call to change cpanel password?
    By electric in forum cPanel & WHM Discussions
    Replies: 16
    Last Post: 07-27-2007, 08:58 AM
  5. mod_security question - Anyway to call exec WITH parameters?
    By jols in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 03-11-2007, 12:25 AM