Page tree
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

This function returns a list of hashes that contain the following data:

ReturnTypeDescriptionPossible valuesExample
descriptionstringThe resource's UI display name.A string value.
MySQL® Databases
formatter

string

The resource's defined output format.

Note:

Third-party modules will return their defined formatter value.

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

The resource's reference name.

  • diskusage
  • 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.

  • bandwidthusage
  • addondomains
  • subdomains
  • parkeddomains
  • emailaccounts
  • mailinglists

    Note:

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

  • autoresponders
  • emailforwarders
  • emailfilters
  • ftpaccounts

    Note:

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

  • mysqldatabases

    Note:

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

  • postgresqldatabases
mysql_databases
maximuminteger

The resources's maximum usage value.

Note:

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

A non-negative integer value.15
urlstring

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

A valid string.
sql/index.html
usageintegerThe resource's current usage value.A non-negative integer value.0