UAPI Functions - StatsBar::get_stats

Description

This function retrieves a cPanel account's statistics.

Examples


 cPanel or Webmail Session URL

https://hostname.example.com:2083/cpsess##########/StatsBar/get_stats?display=perlversion%7Coperatingsystem&warnings=0&warninglevel=high&warnout=0&infinityimg=%2Fhome%2Fexample%2Finfinity.png&infinitylang=

 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'
  )
);

 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'
    }
);

 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 %]

 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.

 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 (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.

Note:

 Separate each value with a pipe character (|).

 perlversion|operatingsystem 

warnings

 Boolean 

Required

Whether to return all results. 

  • 1 — Return only warnings that exceed the warninglevelparameter'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 filepath to an alternative infinity symbol.

A valid image's filepath.

/home/example/infinity.png

infinitylang

string

Required

 A phrase to 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 that the system rounds 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 that the system rounds 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 that the system rounds 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

 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.

 

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.

 

 

  • 6 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....