diff --git a/docs/howto/object-storage/s3/.pages b/docs/howto/object-storage/s3/.pages index 8b09bd4e7..051479d09 100644 --- a/docs/howto/object-storage/s3/.pages +++ b/docs/howto/object-storage/s3/.pages @@ -8,3 +8,4 @@ nav: - object-lock.md - versioning.md - "Object encryption (SSE-C)": sse-c.md + - utilization.md diff --git a/docs/howto/object-storage/s3/utilization.md b/docs/howto/object-storage/s3/utilization.md new file mode 100644 index 000000000..2f66c7bb2 --- /dev/null +++ b/docs/howto/object-storage/s3/utilization.md @@ -0,0 +1,94 @@ +--- +description: A number of options exist to show object storage utilization. +--- +# Object storage utilization + +You may be interested in the number of objects, or their cumulative size, currently held in a bucket. + + +## Prerequisites + +In order to show the number or cumulative size of objects in a bucket, you must install `aws`, `mc`, or `s3cmd`, and [configure it with working credentials](credentials.md). + + +## Showing the number of objects in a bucket + +To show the number of objects in a given bucket, use one of the following commands: + +=== "aws" + ```bash + aws --profile \ + s3 ls \ + --recursive \ + --summarize \ + s3:// + ``` + The object count is in the line prefixed with `Total Objects`, at the end of the output. +=== "mc" + ```bash + mc ls / \ + --recursive \ + --summarize + ``` + The object count is in the line prefixed with `Total Objects`, at the end of the output. + + Alternatively, you may also use the `du` subcommand: + ```bash + mc du / + ``` + Here, the object count is the second column of the output. +=== "s3cmd" + ```bash + s3cmd -c ~/.s3cfg- \ + du \ + s3:// \ + ``` + The object count is the second column of the output. + +## Showing the total size of objects in a bucket + +To show the overall size of all objects in a given bucket, use one of the following commands: + +=== "aws" + You use the same command as for counting objects: + ```bash + aws --profile \ + s3 ls \ + --recursive \ + --summarize \ + s3:// + ``` + The total object size is in the line prefixed with `Total Size`, at the end of the output. + + By default, the total size is given in bytes. + If you prefer more sensible units, add the `--human-readable` option: + ```bash + aws --profile \ + s3 ls \ + --recursive \ + --summarize \ + --human-readable + s3:// + ``` +=== "mc" + You could use the same command as for counting objects: + ```bash + mc ls / \ + --recursive \ + --summarize + ``` + The total object size is in the line prefixed with `Total Size`, at the end of the output. + It is shown in KiB, MiB, GiB, or TiB, and the value shown may thus be approximate. + + Alternatively, you may also use the `du` subcommand: + ```bash + mc du / + ``` + The total object size is the first column of the output. +=== "s3cmd" + ```bash + s3cmd -c ~/.s3cfg- \ + du \ + s3:// + ``` + The total object size is the first column of the output. diff --git a/docs/howto/object-storage/swift/.pages b/docs/howto/object-storage/swift/.pages index b4194b87a..fc28a63f4 100644 --- a/docs/howto/object-storage/swift/.pages +++ b/docs/howto/object-storage/swift/.pages @@ -6,3 +6,4 @@ nav: - tempurl.md - expiry.md - versioning.md + - utilization.md diff --git a/docs/howto/object-storage/swift/utilization.md b/docs/howto/object-storage/swift/utilization.md new file mode 100644 index 000000000..93673d62f --- /dev/null +++ b/docs/howto/object-storage/swift/utilization.md @@ -0,0 +1,48 @@ +--- +description: A number of options exist to show object storage utilization. +--- +# Object storage utilization + +You may be interested in the number of objects, or their cumulative size, currently held in a container. + + +## Prerequisites + +In order to create a Swift container, be sure that you have [installed and configured](index.md) the required command-line interface (CLI) tools. + + +## Showing the number of objects in a container + +To show the number of objects in a given container, use one of the following commands: + +=== "OpenStack CLI" + ```bash + openstack container show -c object_count + ``` +=== "Swift CLI" + ```bash + swift stat + ``` + The object count is in the line prefixed with `Objects`. + + +## Showing the total size of objects in a container + +To show the overall size of all objects in a given container, use one of the following commands: + +=== "OpenStack CLI" + ```bash + openstack container show -c bytes_used + ``` + The total object size is always given in bytes. +=== "Swift CLI" + ```bash + swift stat + ``` + The total object size is in the line prefixed with `Bytes`. + + To scale the total size output to human-readable units, add the `--lh` option: + + ```bash + swift stat --lh + ```