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.

Stats Bar

Discussion in 'cPanel Developers' started by davidelliott, Jul 21, 2010.

  1. davidelliott

    davidelliott Well-Known Member

    Joined:
    Jun 27, 2010
    Messages:
    67
    Likes Received:
    0
    Trophy Points:
    6
    Hello,

    I am customising this theme for cPanel but I have this problem :). Basically this is what I have coded:

    Code:
    <!--
    --------------------------------------------------------------------------------------------------
    STATS BAR START
    --------------------------------------------------------------------------------------------------
    -->
    		<div id="sidebar">
    			<div id="stats" class="side-box">
    				<h3>
    					<cpanel langprint="Account Information">
    				</h3>
    				<div class="cellbox">
    					<table summary="Statistics">
    						
    							<?cp StatsBar::stat([tr class="row-%"][td]%[/td][td class="info"]%[/td][/tr],rowtype,item,value) display=hostingpackage|sharedip|dedicatedip|shorthostname|cpanelversion|cpanelrevision|sendmailpath|machinetype,rowcounter=mainstats ?>
                                
                                <!--
                                apacheversion|theme|mysqlversion|kernalversion|machinetype
                                -->
    						</tbody>
    					</table>
    				</div>
    			</div>
    		</div>
    	</div>
    <!--  
    --------------------------------------------------------------------------------------------------
    STATS BAR END
    ---------------------------------------------------------------------------------------------------->
    The problem I am having is with this piece of code

    Code:
    ?cp StatsBar::stat([tr class="row-%"][td]%[/td][td class="info"]%[/td][/tr],rowtype,item,value) display=hostingpackage|sharedip|dedicatedip|shorthostname|cpanelversion|cpanelrevision|sendmailpath|machinetype,rowcounter=mainstats ?>
    The order of the list above, hosting package, shared IP and dedicated IP and so on.... is no in that order, however that is the order I want it to be in.

    Is there a place I can find out more of these?

    Thanks!
     
  2. 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
    Hi

    You can find the documentation of the API2 call "StatsBar::stat" here:
    ApiStatsBar < ApiDocs/Api2 < TWiki

    This function will always return an unsorted list of hashes. A great tool for "peeking under the hood" with APIs is the API Tracer:
    http://sdk.cpanel.net/utils/CustomEventHandler-Dumper.tar.gz
    Inside the tarball is a README. You'll need root to install it.
    NOTE: NEVER place this tracer on a production machine, as it records all data for API requests, which is likely to contain sensitive information.

    Once you know what the returned data is, you can use the (cPanel) Template Toolkit to sort/render the data as necessary.
    UsingCpttTags < AllDocumentation/AutomationIntegration < TWiki

    I think for your purposes, you're probably need to make your own template that can loop over or extract the individual stat and render each in the desired order.

    Regards,
    -DavidN

    ex. Tracer dump on a test box using the command you provided
    Code:
    --------------------
    statsbar:stat
    $apiv = 2
    $type = post
    -----
    $cfgref
    
    $VAR1 = {
              'rowcounter' => 'mainstats',
              'display' => 'hostingpackage|sharedip|dedicatedip|shorthostname|cpanelversion|cpanelrevision|sendmailpath|machinetype'
            };
    
    -----
    $dataref
    
    $VAR1 = [
              {
                'percent10' => 0,
                'percent5' => 0,
                'rowtype' => 'even',
                'percent20' => 0,
                'item' => 'Hosting package',
                'value' => 'default',
                'name' => 'hostingpackage',
                'langkey' => 'INDXHostingPackage',
                '_maxed' => 0,
                'module' => 'PkgInfo',
                'percent' => 0,
                'count' => undef,
                'max' => ' ',
                'id' => 'hostingpackage'
              },
              {
                'percent10' => 0,
                'percent5' => 0,
                'rowtype' => 'odd',
                'percent20' => 0,
                'item' => 'Server Name',
                'value' => 'mybox',
                'name' => 'shorthostname',
                'langkey' => 'INDXServername',
                '_maxed' => 0,
                'module' => 'Hostname',
                'percent' => 0,
                'count' => undef,
                'max' => ' ',
                'id' => 'shorthostname'
              },
              {
                'percent10' => 0,
                'percent5' => 0,
                'rowtype' => 'even',
                'percent20' => 0,
                'item' => 'cPanel Version',
                'value' => '11.25.0-STABLE',
                'name' => 'cpanelversion',
                'langkey' => 'INDXBuildVersion',
                '_maxed' => 0,
                'module' => 'Version',
                'percent' => 0,
                'count' => undef,
                'max' => ' ',
                'id' => 'cpanelversion'
              },
              {
                'percent10' => 0,
                'percent5' => 0,
                'rowtype' => 'odd',
                'percent20' => 0,
                'item' => 'Architecture',
                'value' => 'i686',
                'name' => 'machinetype',
                'langkey' => 'INDXMachineType',
                '_maxed' => 0,
                'module' => 'Serverinfo',
                'percent' => 0,
                'count' => undef,
                'max' => ' ',
                'id' => 'machinetype'
              },
              {
                'percent10' => 0,
                'percent5' => 0,
                'rowtype' => 'even',
                'percent20' => 0,
                'item' => 'cPanel Build',
                'value' => 30000,
                'name' => 'cpanelrevision',
                'langkey' => 'INDXRevision',
                '_maxed' => 0,
                'module' => 'Version',
                'percent' => 0,
                'count' => undef,
                'max' => ' ',
                'id' => 'cpanelrevision'
              },
              {
                'percent10' => 0,
                'percent5' => 0,
                'rowtype' => 'odd',
                'percent20' => 0,
                'item' => 'Shared IP Address',
                'value' => '10.1.1.1',
                'name' => 'sharedip',
                'langkey' => 'INDXSharedIp',
                '_maxed' => 0,
                'percent' => 0,
                'count' => undef,
                'max' => ' ',
                'id' => 'sharedip',
                'condition' => 1
              },
              {
                'percent10' => 0,
                'percent5' => 0,
                'rowtype' => 'even',
                'percent20' => 0,
                'item' => 'Path to sendmail',
                'value' => '/usr/sbin/sendmail',
                'name' => 'sendmailpath',
                'langkey' => 'INDXSendmailPath',
                '_maxed' => 0,
                'module' => 'Serverinfo',
                'percent' => 0,
                'count' => undef,
                'max' => ' ',
                'id' => 'sendmailpath'
              }
            ];
    
    --------------------
    
     
  3. davidelliott

    davidelliott Well-Known Member

    Joined:
    Jun 27, 2010
    Messages:
    67
    Likes Received:
    0
    Trophy Points:
    6
    Sorted it out now, stats bar is not ordering properly and the technician I spoke with believed it was a 'bug'. I am waiting on cPanel support to reply with the solution to the 'bug'. Thanks for the API list you gave me.
     
  4. davidelliott

    davidelliott Well-Known Member

    Joined:
    Jun 27, 2010
    Messages:
    67
    Likes Received:
    0
    Trophy Points:
    6
    However I am looking for something that will show, for each account:

    Processes Running
    CPU Usage
    Memory Usage
    Server Time
     
Loading...

Share This Page