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




https://hostname.example.com:2083/cpsess##########/execute/ResourceUsage/get_usages



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



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



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




uapi --user=username ResourceUsage get_usages



{
	"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
	}]

}



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.

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.

  • 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

    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

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


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

    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

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


  • mysql_databases

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


  • postgresql_databases
mysql_databases

maximum

integer

The resources's maximum usage value.

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