Page tree
Skip to end of metadata
Go to start of metadata

 

Description

This function retrieves a cPanel account's statistics.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/StatsBar/get_stats?display=perlversion%7Coperatingsystem&warnings=0&warninglevel=high&warnout=0&infinityimg=%2Fhome%2Fexample%2Finfinity.png&infinitylang="infinity"&rowcounter=even

Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Get account stats for example.com
$get_stats = $cpanel->uapi(
    'Statsbar', 'get_stats',
    array(
        'display'    	=> 'perlversion|operatingsystem',
        'warnings'      => '0',
		'warninglevel	=> '87'
		'warnout'		=> '0'
		'infinityimg'	=> '/home/example/infinity.png'
		'infinitylang'	=> 'infinity'
		'rowcounter'	=> 'even'
  )
);

Note:

For more information, read our Guide to the LiveAPI System.

 

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Get account stats for example.com
my $get_stats = $cpliveapi->uapi(
    'Stats', 'get_stats',
    {
        'display'    	=> 'perlversion|operatingsystem',
        'warnings'      => '0',
		'warninglevel	=> '87'
		'warnout'		=> '0'
		'infinityimg'	=> '/home/example/infinity.png'
		'infinitylang'	=> 'infinity'
		'rowcounter'	=> 'even'
    }
);

Note:

For more information, read our Guide to the LiveAPI System.

 

 cPanel Template Toolkit
<!-- Get a hash of all the data, then display the count values. -->
[% data = execute( 'Stats', 'get_stats' {display => 'perlversion|operatingsystem', 'warnings' => '0', 'warninglevel => '87', 'warnout' => '0', 'infinityimg' => '/home/example/infinity.png', 'infinitylang' => 'infinity', 'rowcounter => 'even'} ) ; %]
[% FOREACH q = data.count %]
     <p>
         [% q %]
     </p>
[% END %]
   
<!-- Get only the count value. -->
[% execute('StatsBar', 'get_stats' {display => 'perlversion|operatingsystem', 'warnings' => '0', 'warninglevel => '87', 'warnout' => '0', 'infinityimg' => '/home/example/infinity.png', 'infinitylang' => 'infinity', 'rowcounter => 'even'} ).data.count %]

Note:

For more information, read our Guide to Template Toolkit documentation. 

 

 Command Line
uapi --user=example StatsBar get_stats display=perlversion%7Coperatingsystem warnings=0 warninglevel=high warnout=0 infinityimg=%2Fhome%2Fexample%2Finfinity.pnginfinitylang="infinity" rowcounter=even

Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • We introduced this functionality in cPanel & WHM version 56.

 Output (JSON)
{
  "messages": null,
  "errors": null,
  "status": 1,
  "data": [
    {
      "zeroisunlimited": 1,
      "percent10": 0,
      "percent": 0,
      "item": "Disk Space Usage",
      "max": "unlimited",
      "langkey": "INDXDiskUsage",
      "percent5": 0,
      "id": "diskusage",
      "module": "Quota",
      "count": "0.77",
      "_count": 0.77,
      "name": "diskusage",
      "_max": "unlimited",
      "normalized": 1,
      "percent20": 0,
      "_maxed": 0,
      "units": "MB"
      "near_limit_phrase":"You are using [format_bytes,_1] of the [format_bytes,_2] of storage available to you.",
      "maxed_phrase":"You are using your maximum storage allotment, [format_bytes,_1]."
     }
  ],
  "metadata": {
    "transformed": 1
  }
}

Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

   

Parameters

ParameterTypeDescriptionPossible valuesExample
displaystring

Required

A list of the account's statistics.

 Click to view...
  • ftpaccounts — Information about the account's FTP accounts.
  • perlversion — The server's Perl version.
  • dedicatedip —  cPanel account websites that use dedicated IP addresses.
  • hostname — The server's hostname.
  • operatingsystem — The server's operating system
  • sendmailpath — The path to the system'ssendmail binary.
  • autoresponders — Information about the cPanel account's auto-responders.
  • perlpath — The Perl binary's absolute oath.
  • emailforwarders — Information about the cPanel account's forwarders.
  • bandwidthusage — Information about the account's bandwidth usage.
  • emailfilters — Information the cPanel account's email filters.
  • mailinglists — Information the cPanel account's mailing lists.
  • diskusage — Information the account's disk space usage.
  • phpversion — The server's PHP version.
  • sqldatabases — Information about the account's SQL databases.
  • apacheversion — The server's Apache version.
  • kernelversion — The operating system's kernel version.
  • shorthostname — The short version of your server's hostname.
  • parkeddomains — Information about the cPanel account's parked domains (aliases).
  • cpanelbuild — The server's cPanel build.
  • theme — The cPanel account's theme.
  • addondomains — Information about the cPanel account's addon domains.
  • cpanelrevision — The build of cPanel that runs on the server.
  • machinetype — The type of operating system your server runs.
  • cpanelversion — The server's cPanel version.
  • mysqldiskusage — The amount of disk space that the cPanel account's MySQL® databases use.
  • mysqlversion — The server's MySQL version.
  • subdomains — Information about the cPanel account's subdomains.
  • postgresdiskusage — The amount of disk space that the cPanel account's PostgreSQL databases use.
  • sharedip — Any of the cPanel account's websites that use a shared IP address.
  • hostingpackage — The cPanel account's hosting package.
  • emailaccounts — Information about the cPanel account's email accounts.

Note:

 Separate each value with a pipe character (|).

perlversion|operatingsystem
warningsBoolean

Required

Whether to return all results.

  • 1 — Return only warnings that exceed the warninglevel parameter's value.
  • 0 — Return all results.
0
warninglevelinteger

Required

The minimum level at which to return warnings.

A positive integer.87
warnoutBoolean

Required

Whether to display results with a value of 100%.

  • 1 — Display results with a value of 100%
  • 0 — Hide results with a value of 100%
0

infinityimg

string

Required

The full filepath to an alternative infinity symbol.

A valid image's filepath./home/example/infinity.png
infinitylangstring

Required

A phrase to represent infinity that the locales system can use.

A string value.infinity
rowcounterstring

Required

The type of row.

  • odd
  • even 
even

 

Returns

ReturnTypeDescriptionPossible valesExample
zeroisunlimitedBooleanWhether a value of 0 means unlimited or zero.
  • 1 — Unlimited.
  • 0 — Zero.
1
percent10integerThe percentage of value.

A positive integer that the system rounds to the nearest ten if applicable.

0
percentintegerThe percentage of value, if applicable.An integer value.0
itemstringA human-readable version of the queried item.A string value.Disk Space Usage
maxstringThe queried value's limit.A string value.unlimited
langkeystringThe value's display locale.A string value.INDXDiskUsage
percent5integerThe percentage of value.

An integer value that the system rounds to the nearest five if applicable.

0
idstringThe display key.A string value.diskusage
modulestringThe module that retrieved the information.A string value.Quota
countstringThe queried data's value.A string value.0.77
_countstringThe queried data's value.A string value.0.77
namestringThe display key.A string value.diskusage
_maxstringThe queried parameter's limit.A string value.unlimited
normalizedBooleanWhether the function normalized the output values.
  • 1 — Normalized.
  • 0 — Did not normalize.
1
_percent20integerThe percentage of value.

An integer value that the system rounds to the nearest twenty if applicable.

0
_maxedBooleanWhether the values reached their maximum value.
  • 1 — Reached maximum value.
  • 0 — Has not reached maximum value.
0
unitsstringThe queried value's unit of measure.A string value.MB
near_limit_phrase
string

A maketext-formatted message that the interface displays when the user approaches their maximum allowed value.

Note:

We introduced this return in cPanel & WHM version 56.

A string value with Template Toolkit tags.
 Click to view...
You are using [format_bytes,_1] of the [format_bytes,_2] of storage available to you.
maxed_phrase
string

The maketext-formatted message that the interface displays when the user reaches their maximum allowed value.

Note:

We introduced this return in cPanel & WHM version 56.

A string value with Template Toolkit tags.
 Click to view...
You are using your maximum storage allotment, [format_bytes,_1].