cPanel API 2 Functions - StatsBar::stat

Warning:

The cPanel API 2 system is deprecated. We strongly recommend that you use UAPI instead of cPanel API 2.

Description

This function retrieves an account's statistics.

Warning:

We strongly recommend that you use the following UAPI function instead of this function:

Examples


WHM API (JSON)

https://hostname.example.com:2087/cpsess###########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=StatsBar&cpanel_jsonapi_func=stat&display=ftpaccounts%7Cperlversion%7Cdedicatedip&warnings=0&warninglevel=high&warnout=0&infinityimg=/home/example/infinity.png&infinitylang="infinity"&rowcounter=even
Note:

For more information, read our Calls from the WHM API documentation.


LiveAPI PHP Class

$cpanel = new CPANEL(); // Connect to cPanel - only do this once.

//  Display stats bar data for ftpaccounts|perlversion|dedicatedip
$stats_bar = $cpanel->api2(
    'StatsBar', 'stat',
    array(
        'display'      => 'ftpaccounts|perlversion|dedicatedip',
        'warnings'      => '0',
        'warninglevel   => 'high'
        '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.

# Display stats bar data for ftpaccounts|perlversion|dedicatedip
my $stats_bar = $cpliveapi->api2(
    'StatsBar', 'stat',
    {
        'display'      => 'ftpaccounts|perlversion|dedicatedip',
        'warnings'      => '0',
        'warninglevel   => 'high'
        'warnout'       => '0'
        'infinityimg'   => '/home/example/infinity.png'
        'infinitylang'  => 'infinity'
        'rowcounter'    => 'even'
 }
);
Note:

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


cPanel Tag System (deprecated)

Warnings:
  • cPanel tags are deprecated . We strongly recommend that you only use the LiveAPI system to call the cPanel APIs. Examples are only present in order to help developers move from the old cPanel tag system to our LiveAPI .
  • cPanel API 2 calls that use cPanel tags vary in code syntax and in their output.
  • For more information, read our Deprecated cPanel Tag Usage documentation.

Command Line

cpapi2 --user=username StatsBar stat display=ftpaccounts%7Cperlversio%5C%7Cdedicatedip warnings=0 warninglevel=high warnout=0 infinityimg=\/home\/example\/infinity.png infinitylang=infinity rowcounter=even
Notes:
  • You must URI-encode values.
  • username represents your account-level username.
  • You must include the --user=username option.
  • For more information and additional output options, read our Guide to cPanel API 2 documentation or run the cpapi2 --help command.
  • If you run CloudLinux™, you must use the full path of the cpapi2 command:
    /usr/local/cpanel/bin/cpapi2

Output (JSON)

{
  "cpanelresult": {
    "apiversion": 2,
    "func": "stat",
    "data": [
      {
        "zeroisunlimited": 0,
        "percent": 0,
        "percent10": 0,
        "max": "unlimited",
        "item": "FTP Accounts",
        "feature": "ftpaccts",
        "percent5": 0,
        "id": "ftpaccounts",
        "phrase": "FTP Accounts",
        "module": "API::Ftp",
        "count": "3",
        "_count": "3",
        "name": "ftpaccounts",
        "_max": "unlimited",
        "percent20": 0,
        "_maxed": 0
      },
      {
        "count": null,
        "value": "5.10.1",
        "percent": 0,
        "percent10": 0,
        "max": "",
        "item": "Perl Version",
        "name": "perlversion",
        "percent20": 0,
        "percent5": 0,
        "_maxed": 0,
        "id": "perlversion",
        "phrase": "Perl Version",
        "module": "Serverinfo"
      },
      {
        "count": null,
        "value": "10.215.214.95",
        "percent": 0,
        "percent10": 0,
        "max": "",
        "item": "Dedicated IP Address",
        "name": "dedicatedip",
        "percent20": 0,
        "percent5": 0,
        "_maxed": 0,
        "id": "dedicatedip",
        "phrase": "Dedicated IP Address",
        "condition": 1
      }
    ],
    "event": {
      "result": 1
    },
    "module": "StatsBar"
  }
}
Note:

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


Parameters

Parameter Type Description Possible values Example
display string

Required

A list of the account's statistics.

  • 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's sendmail 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.

Separate each value with a pipe character (|).

ftpaccounts|perlversion|dedicatedip
warnings Boolean

Required

Whether to return all results.

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

Required

The minimum level at which to return warnings.

A positive integer. 87
warnout Boolean

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 file path to an alternative infinity symbol.

An absolute file path to an image file. /home/example/infinity.png
infinitylang string

Required

A phrase represent infinity that the locales system can use.

A string value. infinity
rowcounter string

Required

The type of row.

  • odd
  • even
even

Returns

Return Type Description Possible vales Example
zeroisunlimited Boolean Whether a value of 0 means unlimited or zero.
  • 1 — Unlimited.
  • 0 — Zero.
1
percent10 integer The percentage of value.

A positive integer.

Round to the nearest ten if applicable.

0
percent integer The percentage of value, if applicable. An integer value. 0
item string A human-readable version of the queried item. A string value. Disk Space Usage
max string The queried value's limit. A string value. unlimited
langkey string The value's display locale. A string value. INDXDiskUsage
percent5 integer The percentage of value.

An integer value.

Round to the nearest five if applicable.

0
id string The display key. A string value. diskusage
module string The module that retrieved the information. A string value. Quota
count string The queried data's value. A string value. 0.77
_count string The queried data's value. A string value. 0.77
name string The display key. A string value. diskusage
_max string The queried parameter's limit. A string value. unlimited
normalized Boolean Whether the function normalized the output values.
  • 1 — Normalized.
  • 0 — Did not normalize.
1
_percent20 integer The percentage of value.

An integer value.

Round to the nearest twenty if applicable.

0
_maxed Boolean Whether the values reached their maximum value.
  • 1 — Reached maximum value.
  • 0 — Has not reached maximum value.
0
units string The queried value's unit of measure. A string value. MB