We have a new documentation site for cPanel & WHM! You can find our new documentation site at docs.cpanel.net.

We will continue to maintain our API documentation on this server.

Child pages
  • WHM API 1 Functions - getdiskusage
Skip to end of metadata
Go to start of metadata

Description

This function retrieves the server's drive partition information.

Examples


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/getdiskusage?api.version=1
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/getdiskusage?api.version=1
 Command Line
whmapi1 getdiskusage


Notes:

  • Unless otherwise noted, you must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{
   "metadata":{
      "command":"getdiskusage",
      "reason":"Successfully retrieved disk usage",
      "version":1,
      "result":1
   
	},
   "data":{
      "partition":[
         {
            "device":"/dev/vda1",
            "inodes_total":20970944,
            "percentage":41,
            "available":24810196,
            "inodes_ipercentage":2,
            "mount":"/",
            "used":17121560,
            "filesystem":"/",
            "inodes_available":20575847,
            "total":41931756,
            "disk":"vda1",
            "inodes_used":395097
         
		},
         {
            "inodes_used":76,
            "disk":"loop0",
            "total":1193832,
            "inodes_available":77844,
            "used":2060,
            "filesystem":"/tmp",
            "mount":"/tmp",
            "inodes_ipercentage":0,
            "available":1129464,
            "percentage":0,
            "inodes_total":77920,
            "device":"/dev/loop0"
         
		},
         {
            "device":"/dev/loop0",
            "inodes_total":77920,
            "percentage":0,
            "available":1129464,
            "inodes_ipercentage":0,
            "mount":"/var/tmp",
            "filesystem":"/var/tmp",
            "used":2060,
            "inodes_available":77844,
            "total":1193832,
            "disk":"loop0",
            "inodes_used":76
         
		}
      
		]
   
	}
}
 Output (XML)
<result>
    <data>
        <partition>
            <disk>mapper/vg_sandbox-lv_root</disk>
            <filesystem>/dev/mapper/vg_sandbox-lv_root</filesystem>
            <mount>/</mount>
            <used>13817836</used>
            <percentage>48</percentage>
            <total>30487496</total>
            <available>15120964</available>
			<device>/dev/loop0</device>
			<inodes_total>77920</inodes_total>
			<inodes_ipercentage>0</inodes_ipercentage>
			<inodes_available>77844</inodes_available>
			<inodes_used>76</inodes_used>
        </partition>
        <partition>
            <disk>vda1</disk>
            <filesystem>/dev/vda1</filesystem>
            <mount>/boot</mount>
            <used>92388</used>
            <percentage>20</percentage>
            <total>495844</total>
            <available>377856</available>
			<device>/dev/loop0</device>
			<inodes_total>77920</inodes_total>
			<inodes_ipercentage>0</inodes_ipercentage>
			<inodes_available>77844</inodes_available>
			<inodes_used>76</inodes_used>
        </partition>
        <partition>
            <disk>vda1</disk>
            <filesystem>/dev/vda1</filesystem>
            <mount>/boot</mount>
            <used>92388</used>
            <percentage>20</percentage>
            <total>495844</total>
            <available>377856</available>
			<device>/dev/loop0</device>
			<inodes_total>77920</inodes_total>
			<inodes_ipercentage>0</inodes_ipercentage>
			<inodes_available>77844</inodes_available>
			<inodes_used>76</inodes_used>
        </partition>
    </data>
    <metadata>
        <version>1</version>
        <reason>Successfully retrieved disk usage</reason>
        <result>1</result>
        <command>getdiskusage</command>
    </metadata>
</result>


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

   

Parameters

This function does not accept parameters.

Returns

ReturnTypeDescriptionPossible valuesExample
partitionarray of hashesAn array of hashes that contain drive partition information.

The hashes include the diskfilesystemmountusedpercentagetotal, inodes_total, inodes_ipercentage,device, inodes_used, inodes_available, and available returns.


disk

string

The partition's label.

The function returns this value in the partition array of hashes.

A valid string.
vda1

filesystem

string

The partition's location.

The function returns this value in the partition array of hashes.

An absolute directory path./

mount

string

The partition's mount point.

The function returns this value in the partition array of hashes.

A valid string./boot

used

integer

The partition's disk space used.

The function returns this value in the partition array of hashes.

A positive integer, measured in kilobytes.92388

percentage

integer

The percentage of the partition's total disk space used.

The function returns this value in the partition array of hashes.

A positive integer.20

total

integer

The partition's total allocated disk space.

The function returns this value in the partition array of hashes.

A positive integer, measured in kilobytes.
495844

available

integer

The partition's disk space unused.

The function returns this value in the partition array of hashes.

A positive integer, measured in kilobytes.
377856

inodes_total

integer

The total number of inodes that the partition will allow.

The function returns this value in the partition array of hashes.

A positive integer.20970944

inodes_ipercentage

integer

The percentage of the partition's total inodes used.

The function returns this value in the partition array of hashes.

A positive integer.2 

device

string

The partition's device name.

The function returns this value in the partition array of hashes.

A valid device name on the system./dev/vda1

inodes_used

integer

The number of inodes used on the partition.

The function returns this value in the partition array of hashes.

A positive integer.395097

inodes_available

integer

The number of unused inodes on the partition.

The function returns this value in the partition array of hashes.

A positive integer.20575847