Child pages
  • UAPI Functions - ResourceUsage::get_usages

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

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

Panel
bgColor#F2F2F2
borderStylenone

Examples


Panel
bgColor#FFFFFF
borderStylenone


Expand
titlecPanel or Webmail Session URL


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

Include Page
LIB:_CallUAPIFromBrowserLink
LIB:_CallUAPIFromBrowserLink


Expand
titleLiveAPI PHP Class


Code Block
languagephp
linenumberstrue
$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'
);

Include Page
LIB:_LiveAPIPHPLink
LIB:_LiveAPIPHPLink


Expand
titleLiveAPI Perl Module


Code Block
languageperl
linenumberstrue
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'
);

Include Page
LIB:_LiveAPIPerlLink
LIB:_LiveAPIPerlLink


Expand
titlecPanel Template Toolkit


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


Include Page
LIB:_TTLink
LIB:_TTLink


Expand
titleCommand Line


Code Block
languagebash
uapi --user=username ResourceUsage get_usages

Include Page
LIB:_UAPICLINote
LIB:_UAPICLINote


Expand
titleOutput (JSON)


Code Block
languagetext
linenumberstrue
{
	"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
	}]

}


Include Page
LIB:_cPanelAPIShellNote
LIB:_cPanelAPIShellNote


Parameters

This function does not accept parameters.

Returns

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

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
titleNote:

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.

  • diskusage
  • Note
    titleNotes:
    • 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
      titleNote:

      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
      titleNote:

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


    • bandwidthusagebandwidthaddondomains
    • addon_domains
    • subdomains
    • parkeddomainsaliases
    • emailaccounts
    • mailinglistsemail_accounts
    • mailing_lists

      Note
      titleNote:

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


    • autoresponders
    • emailforwardersforwarders
    • emailfilters
    • ftpaccountsemail_filters
    • ftp_accounts

      Note
      titleNote:

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


    • mysqldatabasesmysql_databases

      Note
      titleNote:

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


    • postgresqldatabasespostgresql_databases
    mysql_databases

    maximum

    integer

    The resources's maximum usage value.

    Note
    titleNote:

    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