Child pages
  • UAPI Functions - ResourceUsage::get_usages
Skip to end of metadata
Go to start of metadata

Description

This function retrieves resource usage and custom statistics for a cPanel user account. For more information, read our cPanel Interface and cPanel Plugins - Pluggable Statistics Modules documentation.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/ResourceUsage/get_usages


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.

// Retrieve resource usage statistics for a cPanel user account.
$get_usages = $cpanel->uapi(
    'ResourceUsage', 'get_usages'
);


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.

# Retrieve resource usage statistics for a cPanel user account.
my $get_usages = $cpanel->uapi(
    'ResourceUsage', 'get_usages'
);


Note:

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

 cPanel Template Toolkit
<!-- List the account's resource usage statistics. -->
[% data = execute( 'ResourceUsage', 'get_usages' ); %]
[% FOREACH q = data %]
     <p>
         [% q %]
     </p>
[% END %]


Note:

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

 Command Line
uapi --user=username ResourceUsage get_usages


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. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{
	"errors": null,
	"messages": null,
	"metadata": {
		"transformed": 1
	},
	"status": 1,
	"data": [
       {
		 "description": "Disk Usage",
		 "formatter": "format_bytes",
		 "id": "disk_usage",
		 "maximum": undef,
		 "url: "diskusage/index.html",
		 "usage: "4427776"
	}, {
		"description": "MySQL® Disk Usage",
		"formatter": "format_bytes",
		"id": "cachedmysqldiskusage",
		"maximum": undef,
		"url": undef,
		"usage": 0
	}, {
		"description": "Bandwidth",
		"formatter": "format_bytes",
		"id": "bandwidth",
		"maximum": 1048576000,
		"url": "stats/bandwidth.html",
		"usage": 2986
	}, {
		"description": "Addon Domains",
		"formatter": undef,
		"id": "addon_domains",
		"maximum": undef,
		"url": "addon/index.html",
		"usage": 4
	}, {
		"description": "Subdomains",
		"formatter": undef,
		"id": "subdomains",
		"maximum": undef,
		"url": "subdomain/index.html",
		"usage": "4"
	}, {
		"description": "Aliases",
		"formatter": undef,
		"id": "aliases",
		"maximum": undef,
		"url": "park/index.html",
		"usage": 0
	}, {
		"description": "Email Accounts",
		"formatter": undef,
		"id": "email_accounts",
		"maximum": undef,
		"url": "mail/pops/index.html",
		"usage": 1
	}, {
		"description": "Mailing Lists"
		"formatter": undef,
		"id": "mailing_lists",
		"maximum": undef,
		"url": "mail/lists.html",
		"usage": 0
	}, {
		"description": "Autoresponders"
		"formatter": undef,
		"id": "autoresponders",
		"maximum": undef,
		"url": "mail/autores.html",
		"usage": 0
	}, {
		"description": "Forwarders",
		"formatter": undef,
		"id": "forwarders",
		"maximum": undef,
		"url": "mail/fwds.html",

		"usage": 0
	}, {
		"description": "Email Filters",
		"formatter": undef,
		"id": "email_filters",
		"maximum": undef,
		"url": "mail/filters/managefilters.html",
		"usage": 1

	}, {
		"description": "FTP Accounts",
		"formatter": undef,
		"id": "ftp_accounts",
		"maximum": undef,
		"url": "ftp/accounts.html",
		"usage": "0"
	}, {
		"description": "MySQL® Databases",
		"formatter": undef,
		"id": "mysql_databases",
		"maximum": 15,
		"url": "sql/index.html",
		"usage": 0

	}, {
		"description": "Percentage",
		"formatter": "format_bytes",
		"id": "disk_usage",
		"maximum": undef,
		"url": "diskusage/index.html",
		"usage": 4427776
	}]

}


Note:

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

Parameters

This function does not accept parameters.

Returns

ReturnTypeDescriptionPossible valuesExample
dataarray of hashesThis array of hashes contains results from the account's query.This array of hashes contains the description, formatter, id, maximum, url, and usage returns.

description

string

The resource's UI display name.

This function returns this value in the data array of hashes.

A string value.
MySQL® Databases

formatter

string

The resource's defined output format, if applicable.

Note:

Third-party modules will return their defined formatter value.

This function returns this value in the data array of hashes.

  • format_bytes
  • format_bytes_per_second
  • percent
  • An undefined value.
format_bytes

id

string

The resource's reference name.

Notes:

  • Certain id values may not display, based on the server's current profile. For more information, read our How to Use Server Profiles documentation.
  • We changed this return in cPanel & WHM version 76.

This function returns this value in the data array of hashes.

  • disk_usage
  • filesusage

    Note:

    This function only returns this value if the Display File Usage information in the cPanel stats bar setting is enabled in the Display section of WHM's Tweak Settings interface (WHM >> Home >> Server Configuration >> Tweak Settings).

  • cachedmysqldiskusage
  • cachedpostgresdiskusage

    Note:

    This function only returns this value if PostgreSQL® databases are enabled.

  • bandwidth
  • addon_domains
  • subdomains
  • aliases
  • email_accounts
  • mailing_lists

    Note:

    This function only returns this value if Mailman service is enabled. For more information, read our Mailman FAQ documentation.

  • autoresponders
  • forwarders
  • email_filters
  • ftp_accounts

    Note:

    This function only returns this value if FTP accounts exist on the server.

  • mysql_databases

    Note:

    This function only returns this value if MySQL databases are enabled.

  • postgresql_databases
mysql_databases

maximum

integer

The resources's maximum usage value.

Note:

This function returns an undef value for an undefined (unlimited) quota.

This function returns this value in the data array of hashes.

A non-negative integer value.15

url

string

The resource's defined URL link to its corresponding interface, in applicable.

This function returns this value in the data array of hashes.

A valid string.
sql/index.html

usage

integer

The resource's current usage value.

This function returns this value in the data array of hashes.

A non-negative integer value.0