
Huawei Cloud Obs Upload
- 121 installs
- 19 repo stars
- Updated July 31, 2026
- huaweicloud/huaweicloud-skills
Upload local files or directories to Huawei Cloud OBS buckets, list buckets with capacity, and schedule periodic uploads via crontab.
About
Uploads local files or directories to Huawei Cloud OBS buckets, lists buckets with capacity and object counts, and schedules periodic syncs via crontab. A developer uses it to push data to object storage and automate recurring uploads, with delete operations prohibited.
- File/directory upload and bucket listing
- Scheduled periodic uploads via crontab; no deletes
Huawei Cloud Obs Upload by the numbers
- 121 all-time installs (skills.sh)
- +15 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #535 of 1,042 Cloud & Infrastructure skills by installs in the Skillselion catalog
- Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/huaweicloud/huaweicloud-skills --skill huawei-cloud-obs-uploadAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 121 |
|---|---|
| repo stars | ★ 19 |
| Last updated | July 31, 2026 |
| Repository | huaweicloud/huaweicloud-skills ↗ |
What it does
Upload local files or directories to Huawei Cloud OBS buckets, list buckets with capacity, and schedule periodic uploads via crontab.
Files
Huawei Cloud OBS Upload
Upload local files or directories to Huawei Cloud OBS buckets, list OBS buckets with capacity and object count, and schedule periodic uploads via crontab.
⛔ Prohibited Operations (Security Constraints)
This skill strictly forbids the following delete operations, regardless of user requests:
| Prohibited Operation | API/Command | Reason |
|---|---|---|
| ❌ Delete bucket | DeleteBucket / obsutil rm -bucket | Irreversible; destroys the entire bucket and all objects |
| ❌ Delete object | DeleteObject / obsutil rm | Irreversible; deleted objects cannot be recovered (unless versioning is enabled) |
| ❌ Batch delete objects | DeleteObjects / obsutil rm -r | Irreversible; batch deletion has a wide impact |
| ❌ Empty bucket | obsutil rm -bucket -r | Irreversible; removes all objects in the bucket |
If a user requests a delete operation, you must refuse and inform:
"Per security constraints, this skill does not allow delete operations (delete bucket/object/batch delete/empty bucket). Please use the Huawei Cloud OBS console or obsutil manually."
Architecture
Huawei Cloud OBS Object Storage Management
├── ListBucketsWithStats (List buckets with capacity and object count)
├── UploadFile (Upload local file or directory to target bucket)
└── ScheduledUpload (Schedule periodic upload of local directory to target bucket)Prerequisites
Prerequisite check: Huawei Cloud CLI (hcloud / KooCLI) >= 3.2.0 required
Run hcloud version to verify version >= 3.2.0. If not installed or version is too low,see references/cli-installation-guide.md for installation guide.
hcloud versionPrerequisite check: obsutil >= 5.5.0 required (for upload features)
File/directory upload requires the Huawei Cloud obsutil CLI tool.
Run obsutil version to verify version >= 5.5.0. If not installed,see references/cli-installation-guide.md for installation guide.
obsutil versionPrerequisite check: obsutil credential configuration required
>
The hcloud OBS module uses obsutil under the hood, which requires separate AK/SK and Endpoint configuration.
Before performing OBS operations, you must check whether obsutil credentials are configured:
>
```bash
hcloud obs ls -limit=1
```
>
If the response is `Please set ak, sk and endpoint in the configuration file!` or `InvalidAccessKeyId`, obsutil credentials are not configured.
>
Resolution: Provide the following example command and have the user configure it in their terminal (do not ask the user to provide AK/SK directly in the conversation):
>
```
obsutil credentials are not configured. Please run the following command in your terminal to configure (AK/SK can be obtained from the Huawei Cloud console "My Credentials" page):
>
hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.<Region>.myhuaweicloud.com
>
Example (Guangzhou region):
hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.cn-south-1.myhuaweicloud.com
>
Common Endpoints:
cn-north-4 → obs.cn-north-4.myhuaweicloud.com
cn-east-3 → obs.cn-east-3.myhuaweicloud.com
cn-south-1 → obs.cn-south-1.myhuaweicloud.com
cn-southwest-2 → obs.cn-southwest-2.myhuaweicloud.com
>
Retry after configuration is complete.
```
>
Prohibited actions:
- ❌ Do not ask the user to provide AK/SK directly in the conversation
- ❌ Do not extract AK/SK from hcloud config files (credentials are encrypted and cannot be used directly)
- ❌ Do not skip the credential check before performing OBS operations
⚠️ hcloud parameter format requirements
>
hcloud (KooCLI) all parameters must use the `--param=value` format (connected with equals sign); space-separated format is not supported.
>
✅ Correct: hcloud OBS ListBuckets --region=cn-south-1>
❌ Incorrect: hcloud OBS ListBuckets --region cn-south-1---
Authentication
Prerequisite check: Huawei Cloud credentials required
Security rules (must be followed):
- Prohibited from reading, echoing, or printing AK/SK values
- Prohibited from asking the user to input AK/SK directly in the conversation
- Prohibited from using hcloud configure set to pass plaintext credential values- Prohibited from accepting AK/SK directly provided by the user in the conversation
- Only allowed to read credentials from environment variables or configured CLI config files
>
⚠️ Important: Handling user-provided credentials
>
If a user attempts to provide AK/SK directly (e.g., "my AK is xxx, SK is yyy"):
1. Stop immediately - Do not execute any commands
2. Politely refuse and return the following message:
```
For account security, please do not provide Huawei Cloud Access Key ID and Access Key Secret directly in the conversation.
>
Please use one of the following secure methods to configure credentials:
>
Method 1: Interactive configuration (recommended)
hcloud configure
# Enter AK/SK as prompted; credentials will be securely stored in a local config file
>
Method 2: Environment variable configuration
export HUAWEICLOUD_SDK_AK=<your-access-key-id>
export HUAWEICLOUD_SDK_SK=<your-access-key-secret>
>
After configuration is complete, please retry your request.
```
3. Do not continue executing any Huawei Cloud operations until credentials are configured
>
Check CLI configuration:
```bash
hcloud configure list
```
Check whether the output contains valid configuration (AK/SK, IAM, etc.).
>
If no valid credentials exist, stop here.
---
IAM Permission Policies
Ensure the IAM user has the required permissions. See references/iam-policies.md for details.
Minimum required permissions:
obs:bucket:list— List bucketsobs:bucket:get— Get bucket attributes (capacity, object count)obs:object:get— Read object informationobs:object:put— Upload objects
---
Core Workflows
Task 1: List Buckets with Capacity and Object Count
List buckets via obsutil, then query bucket capacity and object count using CES capacity metrics or OBS API.
📄 Detailed steps → references/task-list-buckets-with-stats.md
Task 2: Upload Local File or Directory to Target Bucket
Upload files or directories to a specified OBS bucket using obsutil, supporting single file and directory upload.
📄 Detailed steps → references/task-upload-file.md
Task 3: Schedule Periodic Upload of Local Directory to Target Bucket
Periodically upload a local directory to a specified OBS bucket incrementally via crontab scheduled task.
📄 Detailed steps → references/task-scheduled-upload.md
---
References
| Document | Description |
|---|---|
| task-list-buckets-with-stats.md | Task 1: List buckets with capacity and object count |
| task-upload-file.md | Task 2: Upload file or directory |
| task-scheduled-upload.md | Task 3: Scheduled upload |
| related-apis.md | API and CLI command details |
| iam-policies.md | IAM permission policies |
| obs-metrics.md | OBS CES monitoring metrics reference |
| verification-method.md | Verification steps |
| acceptance-criteria.md | Correct/error pattern comparison |
| cli-installation-guide.md | CLI installation guide |
| troubleshooting.md | Troubleshooting and practical experience |
Acceptance Criteria: huawei-cloud-obs-upload
Scenario: Huawei Cloud OBS Object Storage Management Purpose: Skill test acceptance criteria
Table of Contents
- Correct CLI Command Patterns
- Correct SDK Code Patterns
- Response Validation Criteria
- Security Criteria
- Month-over-Month Calculation Criteria
- References
---
Correct CLI Command Patterns
0. Parameter Format — hcloud must use equals sign format
✅ Correct
hcloud obs ls
hcloud CES ShowMetricData --region=cn-south-1 --namespace=SYS.OBS --metric_name=capacity_total
hcloud version❌ Incorrect
hcloud obs ls --region cn-south-1 # Incorrect: obsutil mode parameters not applicable
hcloud --version # Incorrect: hcloud does not support --version; use hcloud version⚠️ Key: hcloud OBS module is obsutil
>
The hcloud CLI OBS module directly maps to obsutil commands; use lowercasehcloud obs, nothcloud OBS.
To list buckets, usehcloud obs ls; there is noListAllMyBucketsTypecommand.
1. OBS Commands — Use obsutil mode
✅ Correct
hcloud obs ls # List all buckets
hcloud obs ls obs://my-bucket -s # List objects in bucket
hcloud obs stat obs://my-bucket # View bucket attributes❌ Incorrect
hcloud OBS ListAllMyBucketsType # Incorrect: This command does not exist
hcloud obs list-buckets # Incorrect: obsutil command is ls2. CES Commands — Query monitoring metrics
✅ Correct
hcloud CES ShowMetricData \
--region=cn-south-1 \
--namespace=SYS.OBS \
--metric_name=capacity_total \
--dim.0=bucket_name,my-bucket \
--period=86400 \
--filter=average \
--from=1746057600000 \
--to=1747612800000❌ Incorrect
hcloud ces ShowMetricData ... # Incorrect: CES product name must be uppercase
hcloud CES ShowMetricData \
--namespace=OBS # Incorrect: Should be SYS.OBS
hcloud CES ShowMetricData \
--dimensions.0.name=bucket_name \
--dimensions.0.value=my-bucket # Incorrect: hcloud uses --dim.0=key,value format3. CES Dimension Parameter Format
✅ Correct
--dim.0=bucket_name,my-bucket❌ Incorrect
--dimensions.0.name=bucket_name --dimensions.0.value=my-bucket # Incorrect: SDK format, not supported by hcloud
--dim.0=bucket,my-bucket # Incorrect: Dimension key should be bucket_name4. obsutil Upload Commands
✅ Correct
obsutil cp /home/user/file.txt obs://my-bucket/path/file.txt -flat # Single file: -flat is fine
obsutil cp /home/user/data/ obs://my-bucket/data/ -r # Directory: preserves structure (default)
obsutil cp /home/user/data/ obs://my-bucket/data/ -r -p=10 # Directory with concurrency
obsutil cp /home/user/data/ obs://my-bucket/data/ -r -flat # Directory: -flat only if user explicitly requests❌ Incorrect
obsutil upload /home/user/file.txt obs://my-bucket/ # Incorrect: obsutil upload command is cp, not upload
obsutil cp /home/user/file.txt my-bucket/path/file.txt # Incorrect: Target must start with obs://
obsutil cp /home/user/data/ obs://my-bucket/ -r -flat # Incorrect: -flat discards directory structure by default; do not use unless user explicitly requests5. CES Namespace and Metric Names
✅ Correct
--namespace=SYS.OBS
--metric_name=capacity_total
--dim.0=bucket_name,my-bucket❌ Incorrect
--namespace=OBS # Incorrect: Should be SYS.OBS
--namespace=SYS.OBJECT_STORAGE # Incorrect: Should be SYS.OBS
--metric_name=capacityTotal # Incorrect: Should be capacity_total (snake_case)
--metric_name=download_bytes # Incorrect: Not used in this skill; capacity_total is the actual metric
--dim.0=bucketName,my-bucket # Incorrect: Dimension key should be bucket_name
--dim.0=bucket,my-bucket # Incorrect: Dimension key should be bucket_name6. Time Ranges — Millisecond Timestamps
✅ Correct
--from=1746057600000 # Millisecond timestamp
--to=1747612800000 # Millisecond timestamp❌ Incorrect
--from=1746057600 # Incorrect: Second-level timestamp; CES requires millisecond-level (13 digits)
--from=2025-05-01 # Incorrect: CES requires Unix timestamp, not date string---
Correct SDK Code Patterns
1. Import Patterns
✅ Correct
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkobs.v1.client import ObsClient
from huaweicloudsdkces.v1.client import CesClient
from huaweicloudsdkces.v1.region.ces_region import CesRegion❌ Incorrect
from huaweicloudsdkobs import Client # Incorrect: Missing correct module path2. Authentication — Must use BasicCredentials; hardcoded AK/SK prohibited
✅ Correct
from huaweicloudsdkcore.auth.credentials import BasicCredentials
credentials = BasicCredentials() \
.with_ak(os.getenv("HUAWEICLOUD_SDK_AK")) \
.with_sk(os.getenv("HUAWEICLOUD_SDK_SK")) \
.with_project_id(os.getenv("HUAWEICLOUD_SDK_PROJECT_ID"))❌ Incorrect
credentials = BasicCredentials() \
.with_ak("XXXXXXXXXX") # Prohibited: Hardcoded AK
.with_sk("YYYYYYYYYY") # Prohibited: Hardcoded SK3. OBS Client Initialization
✅ Correct
from obs import ObsClient
obs_client = ObsClient(
access_key_id=os.getenv("HUAWEICLOUD_SDK_AK"),
secret_access_key=os.getenv("HUAWEICLOUD_SDK_SK"),
server='obs.cn-south-1.myhuaweicloud.com'
)❌ Incorrect
obs_client = ObsClient(
access_key_id="XXXXXXXXXX", # Prohibited: Hardcoded AK
secret_access_key="YYYYYYYYYY", # Prohibited: Hardcoded SK
server='obs.cn-south-1.myhuaweicloud.com'
)---
Response Validation Criteria
obs ls response (list buckets)
✅ Must include:
- Bucket name list
- Region information for each bucket
obs stat response (bucket attributes)
✅ Must include:
size- Total size of objects in the bucket (bytes)objectNumber- Total number of objects in the bucket
CES ShowMetricData response
✅ Must include:
datapointsarray, each containingtimestamp,unit, and an aggregate value (sum/average/max/min)metric_name(string)
---
Security Criteria
✅ Correct Security Practices
1. Use hcloud configure list to verify credentials (do not echo AK/SK) 2. SDK uses BasicCredentials to read from environment variables 3. Sensitive data uses environment variables 4. obsutil credentials configured securely via obsutil config
❌ Incorrect Security Practices
1. Hardcode access keys in code or commands 2. Print or echo credential values 3. Use hcloud configure set to pass plaintext credentials in automation scripts 4. Ask the user to provide AK/SK directly in the conversation
⛔ Prohibited Operations (Security Constraints)
The following delete operations are strictly forbidden, regardless of user requests:
❌ Absolutely Prohibited
hcloud obs rm obs://my-bucket -r # Prohibited: Recursively delete all objects in bucket
hcloud obs rm obs://my-bucket # Prohibited: Delete bucket✅ Correct: Refuse delete request and direct to console
"Per security constraints, this skill does not allow delete operations (delete bucket/object/batch delete/empty bucket). Please use the Huawei Cloud OBS console or obsutil manually."---
Month-over-Month Calculation Criteria
✅ Correct Calculation
MoM (%) = (Current Month Value - Last Month Value) / Last Month Value × 100%
Example:
Current month = 125.3 GB, Last month = 98.7 GB
MoM = (125.3 - 98.7) / 98.7 × 100% = +26.95%Special Case Handling
| Case | Correct Handling | Incorrect Handling |
|---|---|---|
| Last month=0, Current>0 | Display "New (last month was 0)" | ❌ Display +∞% |
| Last month=0, Current=0 | Display "N/A" | ❌ Display 0% |
| Last month>0, Current>0 | Calculate percentage, rounded to 2 decimal places | ❌ Integer truncation |
| Current<Last month | Display negative (e.g., -15.30%) | ❌ Display 0% |
---
References
CLI Installation Guide - Huawei Cloud OBS Object Storage Management
This skill requires two CLI tools: hcloud (KooCLI) and obsutil.
Table of Contents
- hcloud (KooCLI) Installation
- obsutil Installation
- Credential Configuration
- Verify Installation
- Troubleshooting
---
hcloud (KooCLI) Installation
macOS
# Install via Homebrew
brew install hcloudcli
# Or download directly
curl -O https://obs-community-tool.obs.cn-north-1.myhuaweicloud.com/hcloudcli/latest/hcloudcli-macos-amd64.tar.gz
tar -xzf hcloudcli-macos-amd64.tar.gz
chmod +x hcloud
sudo mv hcloud /usr/local/bin/Linux (x86_64)
curl -O https://obs-community-tool.obs.cn-north-1.myhuaweicloud.com/hcloudcli/latest/hcloudcli-linux-amd64.tar.gz
tar -xzf hcloudcli-linux-amd64.tar.gz
chmod +x hcloud
sudo mv hcloud /usr/local/bin/Linux (ARM64)
curl -O https://obs-community-tool.obs.cn-north-1.myhuaweicloud.com/hcloudcli/latest/hcloudcli-linux-arm64.tar.gz
tar -xzf hcloudcli-linux-arm64.tar.gz
chmod +x hcloud
sudo mv hcloud /usr/local/bin/Windows
# Download and extract
Invoke-WebRequest -Uri "https://obs-community-tool.obs.cn-north-1.myhuaweicloud.com/hcloudcli/latest/hcloudcli-windows-amd64.zip" -OutFile "hcloudcli.zip"
Expand-Archive hcloudcli.zip
# Add hcloud.exe to PATH---
obsutil Installation
macOS
curl -O https://obs-community-tool.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_darwin_amd64.tar.gz
tar -xzf obsutil_darwin_amd64.tar.gz
chmod +x obsutil_darwin_amd64_*
sudo mv obsutil_darwin_amd64_*/obsutil /usr/local/bin/Linux (x86_64)
curl -O https://obs-community-tool.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_linux_amd64.tar.gz
tar -xzf obsutil_linux_amd64.tar.gz
chmod +x obsutil_linux_amd64_*
sudo mv obsutil_linux_amd64_*/obsutil /usr/local/bin/Linux (ARM64)
curl -O https://obs-community-tool.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_linux_arm64.tar.gz
tar -xzf obsutil_linux_arm64.tar.gz
chmod +x obsutil_linux_arm64_*
sudo mv obsutil_linux_arm64_*/obsutil /usr/local/bin/Windows
Invoke-WebRequest -Uri "https://obs-community-tool.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_windows_amd64.zip" -OutFile "obsutil.zip"
Expand-Archive obsutil.zip
# Add obsutil.exe to PATH---
Credential Configuration
hcloud Credential Configuration
Method 1: Interactive configuration (recommended)
hcloud configure
# Enter as prompted:
# - Region (e.g., cn-south-1)
# - AK (Access Key ID)
# - SK (Access Key Secret)Method 2: Environment variables
export HUAWEICLOUD_SDK_AK=<your-access-key-id>
export HUAWEICLOUD_SDK_SK=<your-access-key-secret>Method 3: Non-interactive configuration
hcloud configure set --cli-profile=default --region=cn-south-1 --access-key-id=<AK> --secret-access-key=<SK>⚠️ Security warning: Method 3 will expose AK/SK in command history; only use in secure environments.
obsutil Credential Configuration
obsutil config -ak=<AK> -sk=<SK> -e=obs.cn-south-1.myhuaweicloud.com⚠️ obsutil Endpoint format
>
OBS Endpoint format: obs.<region-id>.myhuaweicloud.com>
Common Endpoints:
>
| Region | Endpoint |
|--------|----------|
| cn-north-1 | obs.cn-north-1.myhuaweicloud.com |
| cn-north-4 | obs.cn-north-4.myhuaweicloud.com |
| cn-east-2 | obs.cn-east-2.myhuaweicloud.com |
| cn-east-3 | obs.cn-east-3.myhuaweicloud.com |
| cn-south-1 | obs.cn-south-1.myhuaweicloud.com |
| ap-southeast-1 | obs.ap-southeast-1.myhuaweicloud.com |
---
Verify Installation
Verify hcloud
# Check version
hcloud version
# Expected: >= 3.2.0
# Test authentication
hcloud obs lsVerify obsutil
# Check version
obsutil version
# Expected: >= 5.5.0
# Test authentication (list buckets, limit 1)
obsutil ls -limit=1---
Troubleshooting
hcloud Common Issues
| Issue | Cause | Solution |
|---|---|---|
hcloud: command not found | Not installed or not in PATH | Install hcloud or add path to PATH |
authentication failed | Invalid or expired credentials | Reconfigure credentials |
insufficient permissions | Insufficient IAM permissions | Add required IAM policies |
region not found | Incorrect region ID | Use the correct region ID |
obsutil Common Issues
| Issue | Cause | Solution |
|---|---|---|
obsutil: command not found | Not installed or not in PATH | Install obsutil or add path to PATH |
Status code: 403 | Incorrect AK/SK or insufficient permissions | Re-run obsutil config to configure credentials |
Status code: 404 | Bucket does not exist | Confirm bucket name is correct |
connection timeout | Network issue or incorrect Endpoint | Check network connection and Endpoint configuration |
---
Security Best Practices
1. Do not provide AK/SK directly in conversation - Always use interactive configuration or environment variables 2. Rotate AK/SK regularly - Recommended every 90 days 3. Use IAM temporary credentials - Prefer IAM agency delegation or temporary credentials 4. Least privilege principle - Grant only the minimum required permissions 5. Audit logs - Enable OBS bucket logging for access request auditing 6. obsutil credential file permissions - Ensure obsutil config file permissions are 600
---
Official Documentation
IAM Permission Policies - Huawei Cloud OBS Object Storage Management
IAM permission policies required by this skill.
Required Permissions Overview
| Operation | IAM Action (Legacy v3) | IAM Action (New v5) | Description |
|---|---|---|---|
| List buckets | obs:bucket:ListAllMyBuckets | obs:bucket:listAllMyBuckets | List all buckets for the current account |
| Get bucket storage info | obs:bucket:GetBucketStorageInfo | obs:bucket:getBucketStorageInfo | Get bucket capacity and object count |
| Get bucket metadata | obs:bucket:GetBucketMetadata | obs:bucket:getBucketMetadata | Get bucket metadata |
| Upload object | obs:object:PutObject | obs:object:putObject | Upload object to bucket |
| List objects | obs:bucket:ListBucket | obs:bucket:listBucket | List objects in bucket |
---
Minimum Required Policy (JSON)
Legacy IAM (v3 API - Role and Policy Authorization)
{
"Version": "1.1",
"Statement": [
{
"Effect": "Allow",
"Action": [
"obs:bucket:ListAllMyBuckets",
"obs:bucket:GetBucketStorageInfo",
"obs:bucket:GetBucketMetadata",
"obs:object:PutObject",
"obs:bucket:ListBucket",
"ces:metric:get"
]
}
]
}New IAM (v5 API - Identity Policy Authorization)
{
"Version": "5.0",
"Statement": [
{
"Effect": "Allow",
"Action": [
"obs:bucket:listAllMyBuckets",
"obs:bucket:getBucketStorageInfo",
"obs:bucket:getBucketMetadata",
"obs:object:putObject",
"obs:bucket:listBucket",
"ces:metric:get"
],
"Resource": [
"OBS:*:*:bucket:*",
"CES:*:*:metric:*"
]
}
]
}---
Resource-Level Policy (Recommended)
Restrict to specific buckets for improved security:
{
"Version": "5.0",
"Statement": [
{
"Effect": "Allow",
"Action": [
"obs:bucket:listAllMyBuckets",
"obs:bucket:getBucketStorageInfo",
"obs:bucket:getBucketMetadata",
"obs:object:putObject",
"obs:bucket:listBucket"
],
"Resource": [
"OBS:*:*:bucket:<BucketName>",
"OBS:*:*:object:<BucketName>/*"
]
},
{
"Effect": "Allow",
"Action": [
"ces:metric:get"
],
"Resource": [
"CES:*:*:metric:*"
]
}
]
}---
Read-Only Policy
Only view bucket information and monitoring data (no upload allowed):
{
"Version": "5.0",
"Statement": [
{
"Effect": "Allow",
"Action": [
"obs:bucket:listAllMyBuckets",
"obs:bucket:getBucketStorageInfo",
"obs:bucket:getBucketMetadata",
"obs:bucket:listBucket",
"ces:metric:get"
],
"Resource": [
"OBS:*:*:bucket:*",
"CES:*:*:metric:*"
]
}
]
}---
System Policies
You can use Huawei Cloud preset system policies to simplify authorization:
| System Policy | Included Permissions | Applicable Scenario |
|---|---|---|
OBS OperateAccess | Bucket and object read/write (no delete) | ✅ Recommended for this skill |
OBS ReadOnlyAccess | Bucket and object read-only | View-only scenarios |
OBS Administrator | Full OBS permissions | ⚠️ Overly permissive, not recommended |
CES ReadOnlyAccess | CES read-only permissions | View monitoring metrics |
Recommended combination: OBS OperateAccess + CES ReadOnlyAccess
⚠️ OBS OperateAccess note
>
OBS OperateAccess includes bucket and object read/write permissions but does not include delete permissions,
which aligns with this skill's "no delete" security constraint. Recommended for use.
---
Bucket Policy Authorization
In addition to IAM policies, you can also authorize via bucket policies:
{
"Statement": [
{
"Effect": "Allow",
"Principal": {"ID": ["<IAMUserId>"]},
"Action": [
"obs:bucket:ListBucket",
"obs:bucket:GetBucketStorageInfo",
"obs:object:PutObject"
],
"Resource": [
"my-bucket",
"my-bucket/*"
]
}
]
}---
Policy Best Practices
1. Least privilege principle: Grant only the minimum required permissions; prefer resource-level policies 2. No delete permissions: This skill prohibits delete operations; policies should not include delete permissions 3. Recommend OBS OperateAccess: Among system policies, OBS OperateAccess best matches this skill's requirements 4. CES data access: Querying monitoring metrics requires CES ReadOnlyAccess 5. Regular review: Periodically review IAM policies to ensure no excessive permissions
---
Official Documentation
OBS CES Monitoring Metrics Reference - Huawei Cloud OBS Object Storage Management
Monitoring metrics reported by OBS to CES (Cloud Eye Service), with namespace SYS.OBS.
Reference official documentation: https://support.huaweicloud.com/usermanual-obs/obs_03_0010.html
Namespace
SYS.OBS
Dimensions
| Dimension | Key | hcloud parameter format | Description |
|---|---|---|---|
| Bucket name | bucket_name | --dim.0=bucket_name,<BucketName> | OBS bucket name |
⚠️ hcloud CES dimension parameter format
>
hcloud CES ShowMetricData dimension parameters use the --dim.N=key,value format:```bash
--dim.0=bucket_name,my-bucket
```
>
❌ Incorrect format (SDK/REST API format, not supported by hcloud):
```bash
--dimensions.0.name=bucket_name --dimensions.0.value=my-bucket
```
---
Traffic Metrics
⚠️ Key: Bandwidth metrics vs Traffic metrics
>
- Traffic metrics (cumulative, unit Bytes): Direct summation gives total bytes; must use these metrics when querying traffic
- Bandwidth metrics (rate, unit Bytes/s): Need to multiply by aggregation period to convert to bytes; error-prone; do not use for traffic queries
Traffic Metrics (Cumulative, Recommended)
| Metric Name | Metric ID | Unit | Description |
|---|---|---|---|
| External download traffic | download_traffic_extranet | Bytes | Sum of externally downloaded object sizes (includes CDN origin pull) |
| Internal download traffic | download_traffic_intranet | Bytes | Sum of internally downloaded object sizes |
| Total download traffic | download_traffic | Bytes | Sum of downloaded object sizes |
| External upload traffic | upload_traffic_extranet | Bytes | Sum of externally uploaded object sizes |
| Internal upload traffic | upload_traffic_intranet | Bytes | Sum of internally uploaded object sizes |
| Total upload traffic | upload_traffic | Bytes | Sum of uploaded object sizes |
| CDN origin pull traffic | cdn_traffic | Bytes | Sum of CDN origin pull request traffic |
Bandwidth Metrics (Rate, Avoid for Traffic Statistics)
| Metric Name | Metric ID | Unit | Description |
|---|---|---|---|
| Total download bandwidth | download_bytes | Bytes/s | Average downloaded object size per second |
| External download bandwidth | download_bytes_extranet | Bytes/s | Average externally downloaded object size per second |
| Internal download bandwidth | download_bytes_intranet | Bytes/s | Average internally downloaded object size per second |
| Total upload bandwidth | upload_bytes | Bytes/s | Average uploaded object size per second |
| External upload bandwidth | upload_bytes_extranet | Bytes/s | Average externally uploaded object size per second |
| Internal upload bandwidth | upload_bytes_intranet | Bytes/s | Average internally uploaded object size per second |
⚠️ Traffic billing notes
>
- External download traffic (download_traffic_extranet): Billable item; external outgoing traffic billed per GB (includes CDN origin pull)- Internal download traffic (download_traffic_intranet): Free; intra-region/intra-VPC internal transfer is not charged- External upload traffic (upload_traffic_extranet): Free; external incoming traffic is not charged- Internal upload traffic (upload_traffic_intranet): Free---
Request Metrics
| Metric Name | Metric ID | Unit | Description |
|---|---|---|---|
| GET-type request count | get_request_count | Count | GET request count (GetObject, HeadObject, ListObjects, etc.) |
| PUT-type request count | put_request_count | Count | PUT request count (PutObject, CopyObject, etc.) |
| POST-type request count | post_request_count | Count | POST-type request count |
| HEAD-type request count | head_request_count | Count | HEAD-type request count |
| DELETE-type request count | delete_request_count | Count | DELETE-type request count |
| 4xx status code count | request_count_4xx | Count | Server responded 4xx request count |
| 5xx status code count | request_count_5xx | Count | Server responded 5xx request count |
| GET-type first byte average latency | first_byte_latency | ms | GET request first byte average latency |
| Total TPS | request_count_per_second | Count/s | Requests per second |
⚠️ Note: OBS has no `request_count` metric
>
CES does not have an OBS metric named request_count. Total request count must be obtained by summing all request types:Total requests = get_request_count + put_request_count + post_request_count + head_request_count + delete_request_count>
Or use the TPS metric request_count_per_second (requests per second; multiply by aggregation period to convert to total count).⚠️ Request billing notes
>
- GET/HEAD-type requests: Billed per 10,000 requests (lower price)
- PUT/POST/DELETE-type requests: Billed per 10,000 requests (higher price, typically 10x GET)
---
Capacity Metrics
| Metric Name | Metric ID | Unit | Description |
|---|---|---|---|
| Total storage usage | capacity_total | Bytes | Storage space occupied by all data |
| Standard storage usage | capacity_standard | Bytes | Storage space occupied by standard storage data |
| Infrequent access storage usage | capacity_infrequent_access | Bytes | Storage space occupied by infrequent access storage data |
| Archive storage usage | capacity_archive | Bytes | Storage space occupied by archive storage data |
| Deep archive storage usage | capacity_deep_archive | Bytes | Storage space occupied by deep archive storage data |
⚠️ Capacity metric collection notes
>
- CES capacity metrics have a 30-minute collection cycle; values are not real-time
- For exact bucket capacity and object count, prefer the GetBucketStorageInfo API- CES capacity metrics are suitable for trend analysis and alerting
💡 Practical tip: Use CES capacity metrics for batch bucket capacity queries
>
When querying capacity rankings for multiple buckets, calling GetBucketStorageInfo per bucket is inefficient; recommended to batch query via CES:
>
```bash
hcloud CES ShowMetricData \
--region=cn-south-1 \
--namespace=SYS.OBS \
--metric_name=capacity_total \
--dim.0=bucket_name,<BucketName> \
--period=86400 \
--filter=average \
--from=<TodayMidnightTimestampMs> \
--to=<CurrentTimestampMs>
```
>
- Use filter=average (not sum), taking the latest sample value- The returned datapoints[-1].average is the current bucket capacity (Bytes)- CES capacity metrics are collected every 30 minutes, which is accurate enough for ranking statistics
---
Query Examples
Query bucket's external download traffic (this month)
hcloud CES ShowMetricData \
--region=cn-south-1 \
--namespace=SYS.OBS \
--metric_name=download_traffic_extranet \
--dim.0=bucket_name,my-bucket \
--period=86400 \
--filter=sum \
--from=1777564800000 \
--to=1779181505463Query bucket's internal download traffic (this month)
hcloud CES ShowMetricData \
--region=cn-south-1 \
--namespace=SYS.OBS \
--metric_name=download_traffic_intranet \
--dim.0=bucket_name,my-bucket \
--period=86400 \
--filter=sum \
--from=1777564800000 \
--to=1779181505463Query bucket's GET request count (this month)
hcloud CES ShowMetricData \
--region=cn-south-1 \
--namespace=SYS.OBS \
--metric_name=get_request_count \
--dim.0=bucket_name,my-bucket \
--period=86400 \
--filter=sum \
--from=1777564800000 \
--to=1779181505463---
Official Documentation
Related APIs - Huawei Cloud OBS Object Storage Management
This document lists all CLI commands and APIs used in the OBS object storage management skill.
Table of Contents
- API Overview
- API Details
- 1. ListBucketsWithStats - List Buckets with Capacity and Object Count
- 2. UploadFile - Upload Local File or Directory to Target Bucket
- 3. ScheduledUpload - Schedule Periodic Upload of Local Directory to Target Bucket
- 4. GetMonthlyTraffic - Query Monthly External/Internal Download Traffic
- 5. GetMonthlyRequests - Query Monthly Total Request Count
- Month-over-Month Calculation
- Official Documentation
---
API Overview
| Product | CLI Command | API Operation | Description |
|---|---|---|---|
| OBS | hcloud obs ls | obsutil ls | List all buckets (obsutil mode) |
| OBS | hcloud OBS GetBucketStorageInfo | GetBucketStorageInfo | Get bucket storage info (capacity, object count; may not be supported by hcloud) |
| CES | hcloud CES ShowMetricData | ShowMetricData | Query monitoring metric data (traffic, request count, capacity) |
| OBS | obsutil cp | PutObject / UploadPart | Upload file/directory |
---
API Details
1. ListBucketsWithStats - List Buckets with Capacity and Object Count
⚠️ Key: region parameter must be provided by the user
>
The --region parameter must be explicitly provided by the user. The Agent must not guess or use a default value.>
Pre-check steps:
1. Check whether the user has provided the --region parameter2. If region is missing, immediately ask the user to provide it:
```
Please provide the OBS region, e.g., cn-north-1, cn-north-4, cn-east-2, cn-east-3, cn-south-1, etc.
```
3. If the region is obviously invalid (empty string, pure numbers, special characters), prompt the user
Step 1: List all buckets
⚠️ Key: hcloud OBS module has no ListAllMyBucketsType command
>
hcloud CLI (v7.2.2 tested) does not have the ListAllMyBucketsType command; must use obsutil mode:# List all buckets
hcloud obs ls
# Filter by specific region
hcloud obs ls 2>&1 | grep "cn-south-1"
# Extract bucket names
hcloud obs ls 2>&1 | awk '/obs:\/\// && /cn-south-1/ {print $1}' | sed 's|obs://||'Response key fields:
| Field | Description |
|---|---|
Buckets.Bucket[].Name | Bucket name |
Buckets.Bucket[].Location | Bucket region |
Buckets.Bucket[].CreationDate | Bucket creation time |
Step 2: Get capacity and object count per bucket
⚠️ Key: CES capacity metric batch query recommended for higher efficiency
>
Calling GetBucketStorageInfo per bucket is inefficient; recommended to batch query via CES capacity_total metric:```bash
hcloud CES ShowMetricData \
--region=<RegionId> \
--namespace=SYS.OBS \
--metric_name=capacity_total \
--dim.0=bucket_name,<BucketName> \
--period=86400 \
--filter=average \
--from=<TodayMidnightTimestampMs> \
--to=<CurrentTimestampMs>
```
The returned datapoints[-1].average is the bucket capacity (Bytes).hcloud OBS GetBucketStorageInfo \
--region=<RegionId> \
--bucket=<BucketName>GetBucketStorageInfo response key fields:
| Field | Type | Description |
|---|---|---|
size | long | Total size of objects in the bucket (bytes) |
objectNumber | int | Total number of objects in the bucket |
⚠️ Note: hcloud OBS module may not have GetBucketStorageInfo command
>
If hcloud does not support GetBucketStorageInfo, alternatives:- Query bucket info via obsutil: obsutil ls -bucket=<BucketName> -limit=0 -s- Call OBS API directly: GET /?storageInfo to get bucket storage info>
If obsutil also does not support this query, you can get it by listing all objects in the bucket and summing their sizes (poor performance, use as fallback only).
Error handling: 1. If "Access Denied" is reported, prompt the user to check IAM permissions or bucket policy 2. If bucket count is 0, prompt the user that no buckets exist in the current region; they may need to switch regions 3. If GetBucketStorageInfo errors, skip the bucket and mark "query failed" in the output
---
2. UploadFile - Upload Local File or Directory to Target Bucket
⚠️ Key: Upload uses obsutil, not hcloud
>
hcloud CLI does not support OBS object upload operations; must use obsutil.
Pre-check:
1. Check obsutil is installed: obsutil version2. Check obsutil credentials are configured: obsutil ls -limit=13. Check local path exists
Required parameters:
| Parameter | Description | Example |
|---|---|---|
| Local path | File or directory path to upload | /home/user/data/report.csv |
| Target bucket name | OBS bucket name | my-bucket |
| Target object key (optional) | Object path within bucket | reports/report.csv |
CLI commands:
# Upload a single file
obsutil cp <LocalFilePath> obs://<BucketName>/<ObjectKey> -flat
# Upload an entire directory (preserves directory structure by default)
obsutil cp <LocalDirPath> obs://<BucketName>/<Prefix> -r
# Upload with specified concurrency (large files/many files)
obsutil cp <LocalPath> obs://<BucketName>/<Prefix> -r -p=10⚠️ Key: Do NOT use `-flat` for directory uploads by default
>
When the user specifies a directory, the entire directory should be uploaded as-is (preserving structure).
Only add -flat if the user explicitly requests flattening.- Without-flat:/home/user/data/sub/file.txt→obs://bucket/prefix/sub/file.txt(structure preserved)
- With-flat:/home/user/data/sub/file.txt→obs://bucket/prefix/file.txt(structure lost)
Optional parameters:
| Parameter | Default | Description |
|---|---|---|
-flat | off | Discard local directory structure (only use for single files or if user explicitly requests) |
-r | - | Recursively upload directory |
-p | 5 | Concurrency |
-threshold | 50MB | Multipart upload threshold |
-fr | resume | Resumable upload mode |
-v | off | Verbose log mode |
-config | default config | Specify obsutil config file |
⚠️ Large file upload notes
>
- Single object max size: 48.8TB
- Large files automatically use multipart upload, default part size 9MB
- For unstable networks, reduce concurrency (-p=3)- Upload interruption supports resumable upload (enabled by default)
Error handling: 1. bucket not exist: Confirm bucket name is correct; bucket names are globally unique and must match exactly 2. access denied: Check obsutil credential configuration and bucket ACL/policy 3. no such file or directory: Confirm local path is correct 4. network timeout: Reduce concurrency or increase timeout
---
3. ScheduledUpload - Schedule Periodic Upload of Local Directory to Target Bucket
Based on OS-level scheduled tasks (crontab); no additional daemon process required
Required parameters:
| Parameter | Description | Example |
|---|---|---|
| Local directory path | Directory to upload periodically | /home/user/data/ |
| Target bucket name | OBS bucket name | my-bucket |
| Target path prefix (optional) | Path prefix within bucket | backup/ |
| Schedule period | Execution period | hourly, daily at 8:00, */30 * * * * |
Implementation steps:
Step 1: Create upload script
#!/bin/bash
# OBS scheduled upload script
LOG_FILE="$HOME/obs-scheduled-upload-<BucketName>.log"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting scheduled upload" >> "$LOG_FILE"
obsutil cp <LocalDirPath> obs://<BucketName>/<Prefix> -r >> "$LOG_FILE" 2>&1
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Upload succeeded" >> "$LOG_FILE"
else
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Upload failed, exit code: $RESULT" >> "$LOG_FILE"
fiStep 2: Set crontab
| Period description | Crontab expression |
|---|---|
| Every 30 minutes | */30 * * * * |
| Every hour | 0 * * * * |
| Daily at 8:00 | 0 8 * * * |
| Monday at 0:00 | 0 0 * * 1 |
| 1st of month at 0:00 | 0 0 1 * * |
# Add crontab task
(crontab -l 2>/dev/null; echo "<CronExpr> /bin/bash $HOME/obs-scheduled-upload-<BucketName>.sh") | crontab -Step 3: Verify
crontab -l⚠️ Crontab environment notes
>
- Crontab has a minimal PATH environment variable; use the full path to obsutil in the script
- Recommend adding at the top of the script: export PATH=/usr/local/bin:$PATH- Confirm the obsutil AK/SK config file path is accessible in the crontab environment
Managing scheduled tasks:
# List all scheduled tasks
crontab -l
# Remove a specific scheduled task
crontab -l | grep -v "obs-scheduled-upload-<BucketName>" | crontab -
# View upload log
tail -f $HOME/obs-scheduled-upload-<BucketName>.log---
4. GetMonthlyTraffic - Query Monthly External/Internal Download Traffic
⚠️ Key: Traffic data is obtained via CES, not directly from OBS API
>
The OBS service itself does not provide traffic statistics APIs; traffic data is collected by CES (Cloud Eye Service).
Required parameters:
| Parameter | hcloud parameter | Description | Example |
|---|---|---|---|
| Region | --region | Bucket region | cn-south-1 |
| Bucket name | --dim.0 | Dimension bucket_name,<BucketName> | bucket_name,my-bucket |
Time range calculation:
⚠️ Key: Time range must precisely match the user's expression
>
| User expression | Time range | Description |
|----------------|-----------|-------------|
| "This month" | 1st of current month 00:00:00 ~ current time | Calendar month |
| "Last month" / "Last 30 days" | Current time - 30 days ~ current time | Rolling 30-day window |
| "Previous month" | 1st of previous month 00:00:00 ~ last day of previous month 23:59:59 | Previous calendar month |
| Specific date range | User-specified start and end times | e.g., "May 1 to May 19" |
>
"This month" ≠ "Last month": "This month" starts from the 1st of the current month; "Last month" goes back 30 days from the current time.
Huawei Cloud OBS console defaults to "Last 30 days".
Month-over-month comparison period calculation:
| Query period | Comparison period |
|---|---|
| This month (calendar month) | Previous month (previous calendar month) |
| Last 30 days | 30 days prior (days 31-60) |
| Specific date range | Previous equal-length period |
# This month
Start: 1st of current month 00:00:00 → Unix timestamp (ms)
End: Current time → Unix timestamp (ms)
# Last 30 days
Start: Current time - 30 days → Unix timestamp (ms)
End: Current time → Unix timestamp (ms)
# Previous month (comparison period)
Start: 1st of previous month 00:00:00 → Unix timestamp (ms)
End: Last day of previous month 23:59:59 → Unix timestamp (ms)CLI commands:
⚠️ CES ShowMetricData does not support --User-Agent parameter; do not append it
# Query this month's external download traffic
hcloud CES ShowMetricData \
--region=<RegionId> \
--namespace=SYS.OBS \
--metric_name=download_traffic_extranet \
--dim.0=bucket_name,<BucketName> \
--period=86400 \
--filter=sum \
--from=<FromTimestamp> \
--to=<ToTimestamp>
# Query this month's internal download traffic
hcloud CES ShowMetricData \
--region=<RegionId> \
--namespace=SYS.OBS \
--metric_name=download_traffic_intranet \
--dim.0=bucket_name,<BucketName> \
--period=86400 \
--filter=sum \
--from=<FromTimestamp> \
--to=<ToTimestamp>CES ShowMetricData parameter description:
| Parameter | Required | Description |
|---|---|---|
--namespace | Yes | Fixed value SYS.OBS |
--metric_name | Yes | Metric name |
--dim.0 | Yes | Dimension, format bucket_name,<BucketName> |
--period | Yes | Aggregation period, 86400 (1 day) |
--filter | Yes | Aggregation method, sum (sum) |
--from | Yes | Start time (millisecond timestamp) |
--to | Yes | End time (millisecond timestamp) |
Response key fields:
| Field | Description |
|---|---|
datapoints[].average | Average value within the aggregation period |
datapoints[].sum | Sum value within the aggregation period |
datapoints[].timestamp | Data point timestamp |
⚠️ Key: Must use traffic metrics, not bandwidth metrics
>
- ✅ download_traffic_extranet: External download traffic (unit: Bytes, cumulative)- ✅ download_traffic_intranet: Internal download traffic (unit: Bytes, cumulative)- ❌ download_bytes: Total download bandwidth (unit: Bytes/s, rate, not cumulative)- ❌download_bytes_extranet/download_bytes_intranet: Bandwidth metrics (rate values)
>
Use filter=sum to get total traffic within the time range; summing traffic metrics directly gives total bytes.Results need to be converted to appropriate units:GB = bytes / (1024^3),MB = bytes / (1024^2),KB = bytes / 1024
---
5. GetMonthlyRequests - Query Monthly Total Request Count
⚠️ Key: Request data is obtained via CES, not directly from OBS API
Required parameters: Same as GetMonthlyTraffic
CLI commands:
# Query this month's total request count
hcloud CES ShowMetricData \
--region=<RegionId> \
--namespace=SYS.OBS \
--metric_name=request_count \
--dim.0=bucket_name,<BucketName> \
--period=86400 \
--filter=sum \
--from=<FromTimestamp> \
--to=<ToTimestamp>
# Query this month's GET request count
hcloud CES ShowMetricData \
--region=<RegionId> \
--namespace=SYS.OBS \
--metric_name=get_request_count \
--dim.0=bucket_name,<BucketName> \
--period=86400 \
--filter=sum \
--from=<FromTimestamp> \
--to=<ToTimestamp>
# Query this month's PUT request count
hcloud CES ShowMetricData \
--region=<RegionId> \
--namespace=SYS.OBS \
--metric_name=put_request_count \
--dim.0=bucket_name,<BucketName> \
--period=86400 \
--filter=sum \
--from=<FromTimestamp> \
--to=<ToTimestamp>⚠️ Note: OBS request billing relevance
>
- GET-type requests (GetObject, HeadObject, ListObjects, etc.)
- PUT-type requests (PutObject, CopyObject, CreateMultipartUpload, etc.)
- Different request types have different billing rates; see OBS pricing page for details
---
Month-over-Month Calculation
Formula:
MoM (%) = (Current Month Value - Last Month Value) / Last Month Value × 100%Special cases:
| Case | Handling |
|---|---|
| Last month value = 0, current month value > 0 | Display "New (last month was 0)" |
| Last month value = 0, current month value = 0 | Display "N/A" |
| Last month value > 0 | Calculate MoM percentage, rounded to 2 decimal places |
Example:
Current month external download traffic = 125.3 GB
Last month external download traffic = 98.7 GB
MoM = (125.3 - 98.7) / 98.7 × 100% = +26.95%---
Official Documentation
Task 1: List Buckets with Capacity and Object Count
⚠️ Important: region must be provided by the user
When querying the bucket list, --region must be explicitly provided by the user. Do not guess the region.⚠️ Key: hcloud OBS module has no ListAllMyBucketsType command
>
Tested hcloud CLI (v7.2.2) OBS module does not have the ListAllMyBucketsType command. Listing buckets must use obsutil:```bash
hcloud obs ls
```
You can filter buckets in a specific region via grep:
```bash
hcloud obs ls 2>&1 | grep "cn-south-1"
```
Step 1: List all buckets (using obsutil)
hcloud obs lsStep 2: Query bucket capacity (CES capacity metric recommended, higher efficiency)
When querying capacity for multiple buckets in batch, it is recommended to use the CES capacity_total metric to avoid calling the API per bucket:
hcloud CES ShowMetricData \
--region=<RegionId> \
--namespace=SYS.OBS \
--metric_name=capacity_total \
--dim.0=bucket_name,<BucketName> \
--period=86400 \
--filter=average \
--from=<TodayMidnightTimestamp(ms)> \
--to=<CurrentTimestamp(ms)>⚠️ Capacity metric uses `filter=average` (takes the latest sample value), not filter=sum.The returned datapoints[-1].average is the current bucket capacity (Bytes).Step 2 (alternative): Query capacity and object count per bucket (via OBS API)
If exact object count is needed, you can get it via hcloud OBS GetBucketStorageInfo:
hcloud OBS GetBucketStorageInfo \
--region=<RegionId> \
--bucket=<BucketName>⚠️ Note: GetBucketStorageInfo may not be supported by hcloud
If it reports "No such command", the alternative is: obsutil ls obs://<BucketName> -limit=0 -sResponse key fields:
| Field | Description |
|---|---|
size | Total size of objects in the bucket (bytes) |
objectNumber | Total number of objects in the bucket |
Output format example:
Bucket Capacity(GB) Objects
my-bucket-1 125.3 1024
my-bucket-2 0.5 15
my-bucket-3 2048.0 50000⚠️ Note: GetBucketStorageInfo does not apply to unrestored objects in archived buckets
>
Archived storage class objects need to be restored before they can be accessed; unrestored objects are not counted.
If the bucket contains archived storage objects, the returned capacity and object count may not include unrestored archived objects.
💡 Practical tip: Quick query for top N buckets by capacity
>
When querying the top N buckets by capacity, the process is:
1. hcloud obs ls to list all bucket names in the target region2. Call CES capacity_total metric per bucket to get capacity3. Sort by capacity in descending order, take top N
>
This approach is far more efficient than calling GetBucketStorageInfo API per bucket.
Task 3: Schedule Periodic Upload of Local Directory to Target Bucket
⚠️ Key: Scheduled upload is based on OS-level scheduled task mechanisms
>
This skill implements periodic uploads via OS-level scheduled tasks (Linux: crontab / macOS: crontab / Windows: Task Scheduler)
and does not depend on additional daemon processes.
⚠️ Key: Required parameters must be provided by the user; do not guess
| # | Prompt | Description |
|---|---|---|
| 1 | Local directory path | The local directory to upload periodically; must exist |
| 2 | Target bucket name | The target OBS bucket name for upload |
| 3 | Target path prefix (optional) | The target path prefix within the bucket; defaults to bucket root |
| 4 | Schedule period | The execution period, e.g., hourly, daily at 8:00, every 30 minutes |
| 5 | Crontab expression (optional) | If the user is familiar with cron expressions, they can provide one directly |
Implementation (Linux/macOS)
⚠️ Key: Script and log file location
>
- If the user specifies a storage path, use the user-specified path
- If the user does not specify, scripts and logs are stored in the user's home directory ($HOME); do not use/tmp(may be lost on reboot)
- Script path: $HOME/obs-scheduled-upload-<BucketName>.sh- Log path: $HOME/obs-scheduled-upload-<BucketName>.logStep 1: Generate obsutil upload script
Create the upload script $HOME/obs-scheduled-upload-<BucketName>.sh:
#!/bin/bash
# OBS scheduled upload script
# Bucket: <BucketName>
# Local directory: <LocalDirPath>
# Generated at: <Timestamp>
LOG_FILE="$HOME/obs-scheduled-upload-<BucketName>.log"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting scheduled upload" >> "$LOG_FILE"
obsutil cp <LocalDirPath> obs://<BucketName>/<Prefix> -r -f >> "$LOG_FILE" 2>&1
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Upload succeeded" >> "$LOG_FILE"
else
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Upload failed, exit code: $RESULT" >> "$LOG_FILE"
fi⚠️ Key: Do NOT use `-flat` for directory uploads
>
The user specified a directory to upload, so the entire directory structure should be preserved.
- Default command: obsutil cp <LocalDirPath> obs://<BucketName>/<Prefix> -r -f (preserves directory structure)- Only add -flat if the user explicitly requests flattening (e.g., "upload all files without directory structure")Step 2: Set crontab scheduled task
# Run every hour
(crontab -l 2>/dev/null; echo "0 * * * * /bin/bash $HOME/obs-scheduled-upload-<BucketName>.sh") | crontab -
# Run daily at 8:00
(crontab -l 2>/dev/null; echo "0 8 * * * /bin/bash $HOME/obs-scheduled-upload-<BucketName>.sh") | crontab -
# Run every 30 minutes
(crontab -l 2>/dev/null; echo "*/30 * * * * /bin/bash $HOME/obs-scheduled-upload-<BucketName>.sh") | crontab -Step 3: Verify scheduled task is set
crontab -lImplementation (Windows - Task Scheduler)
# Create a scheduled task (run daily at 8:00)
schtasks /create /tn "OBS-ScheduledUpload-<BucketName>" /tr "obsutil cp <LocalDirPath> obs://<BucketName>/<Prefix> -r" /sc daily /st 08:00 /f⚠️ Important: Notes on scheduled uploads
>
1. Idempotency: obsutil cp skips objects that already exist and are identical (via MD5 comparison); repeated uploads do not create duplicates
2. Incremental upload: Only newly added or modified local files are uploaded; existing unchanged files are not re-uploaded
3. Logs: Upload logs are recorded in $HOME/obs-scheduled-upload-<BucketName>.log4. Deletes are not synced: Scheduled upload only syncs new/modified files; objects deleted locally will not be deleted from the bucket (user must clean up manually)
5. Crontab environment: The crontab execution environment differs from an interactive shell; ensure obsutil is in PATH, and recommend using the full path to obsutil in the script
6. Directory structure preserved: By default, the full local directory structure is preserved in OBS. Only use -flat if the user explicitly requests it.Managing Scheduled Tasks
# List current user's scheduled tasks
crontab -l
# Remove a specific scheduled task
crontab -l | grep -v "obs-scheduled-upload-<BucketName>" | crontab -Task 2: Upload Local File or Directory to Target Bucket
⚠️ Key: Upload operations require obsutil, not hcloud
>
hcloud CLI does not support OBS object upload operations (no PutObject/UploadPart CLI commands).
Uploading files/directories must use the obsutil CLI tool.
Prerequisites:
- obsutil >= 5.5.0 required
- obsutil must have AK/SK configured: obsutil config -ak=<AK> -sk=<SK> -e=<Endpoint>- Do not ask the user to input AK/SK directly in the conversation; guide them to configure via obsutil config themselves
⚠️ Key: Required parameters must be provided by the user; do not guess
| # | Prompt | Description |
|---|---|---|
| 1 | Local file/directory path | The local path to upload; must exist and be readable |
| 2 | Target bucket name | The target OBS bucket name for upload |
| 3 | Target path prefix (optional) | The target path prefix within the bucket; defaults to bucket root |
Upload a single file:
obsutil cp <LocalFilePath> obs://<BucketName>/<ObjectKey> -flatExample:
obsutil cp /home/user/data/report.csv obs://my-bucket/reports/report.csv -flatUpload an entire directory (preserves directory structure by default):
obsutil cp <LocalDirPath> obs://<BucketName>/<Prefix> -rExample:
obsutil cp /home/user/data/ obs://my-bucket/data/ -rThe above command preserves the full directory structure:
/home/user/data/sub/file.txt→obs://my-bucket/data/sub/file.txt
⚠️ `-flat` parameter — use only when explicitly needed
>
-flat discards the local directory structure and uploads only the files (flattened).- For directory uploads: Do NOT use `-flat` by default. The user specified a directory, so the entire directory should be uploaded as-is.
- For single file uploads: `-flat` can be used (a single file has no directory structure to preserve).
- With-flat:/home/user/data/sub/file.txt→obs://bucket/prefix/file.txt(directory structure lost)
- Without-flat:/home/user/data/sub/file.txt→obs://bucket/prefix/sub/file.txt(directory structure preserved)
>
Only add -flat for directory uploads if the user explicitly requests flattening (e.g., "upload all files without directory structure").⚠️ Large file automatic multipart upload
>
obsutil automatically uses multipart upload for large files, with a default part size of 9MB.
You can specify concurrency with the-pparameter (default 5) and multipart threshold with-threshold.
Error handling 1. If "bucket not exist" is reported, prompt the user to confirm the bucket name 2. If "access denied" is reported, prompt the user to check obsutil configuration and bucket permissions 3. If the local path does not exist, prompt the user to confirm the path 4. If upload times out or network error occurs, suggest using -p to reduce concurrency or retry
Troubleshooting - Huawei Cloud OBS Object Storage Management
Table of Contents
- hcloud CLI Issues
- obsutil Upload Issues
- CES Monitoring Data Issues
- Scheduled Upload Issues
- Bucket Capacity Query Issues
- Month-over-Month Calculation Issues
---
hcloud CLI Issues
1. hcloud OBS module has no ListAllMyBucketsType command
Problem: Running hcloud OBS ListAllMyBucketsType returns Error: No such command: "ListAllMyBucketsType".
Root cause: hcloud CLI (v7.2.2 tested) OBS module does not include the ListAllMyBucketsType command. The hcloud OBS module only provides a limited set of bucket management operations; listing buckets requires the obsutil mode.
Solution:
# List all buckets
hcloud obs ls
# Filter buckets in a specific region
hcloud obs ls 2>&1 | grep "cn-south-1"
# Extract bucket name list
hcloud obs ls 2>&1 | awk '/obs:\/\// && /cn-south-1/ {print $1}' | sed 's|obs://||'2. hcloud OBS module has no GetBucketStorageInfo command
Problem: Running hcloud OBS GetBucketStorageInfo returns command not found.
Root cause: The hcloud CLI OBS module may not include all OBS API operations; GetBucketStorageInfo is a bucket extension API not supported by some hcloud versions.
Solution:
Method 1: Use CES capacity metric (recommended for batch queries)
hcloud CES ShowMetricData \
--region=cn-south-1 \
--namespace=SYS.OBS \
--metric_name=capacity_total \
--dim.0=bucket_name,<BucketName> \
--period=86400 \
--filter=average \
--from=<TodayMidnightTimestampMs> \
--to=<CurrentTimestampMs>The returned datapoints[-1].average is the bucket capacity (Bytes).
Method 2: Use obsutil as alternative
# Use obsutil to list objects and get statistics
obsutil ls obs://<BucketName> -limit=0 -sMethod 3: Use OBS REST API directly
# Call OBS REST API via curl to get bucket storage info
# GET /?storageInfo
curl -X GET "https://<BucketName>.obs.<RegionId>.myhuaweicloud.com/?storageInfo" \
-H "Date: $(date -u '+%a, %d %b %Y %H:%M:%S GMT')" \
-H "Authorization: OBS <Signature>"Method 4: Use OBS SDK
from obs import ObsClient
obs_client = ObsClient(...)
resp = obs_client.getBucketStorageInfo(bucketName)
print(f"Size: {resp.body.size}, Objects: {resp.body.objectNumber}")2. hcloud CES ShowMetricData parameter format issue
Problem: CES ShowMetricData dimensions parameter format is incorrect.
Correct format:
--dimensions.0.name=bucket_name \
--dimensions.0.value=my-bucketCommon errors:
# ❌ Incorrect: dimensions index starts from 1
--dimensions.1.name=bucket_name
# ❌ Incorrect: dimension name is incorrect
--dimensions.0.name=bucket
# ❌ Incorrect: missing index
--dimensions.name=bucket_namehcloud CES parameter index starts from 0, not from 1.
3. hcloud credential configuration issues
| Error message | Cause | Solution |
|---|---|---|
No valid credential | AK/SK not configured | Run hcloud configure |
Access denied | AK/SK invalid or expired | Reconfigure credentials |
Invalid region | Region ID incorrect | Use the correct region ID |
Please set ak, sk and endpoint | obsutil credentials not configured | Run hcloud obs config -i=<AK> -k=<SK> -e=obs.<region>.myhuaweicloud.com |
InvalidAccessKeyId | obsutil configured AK/SK is invalid | Re-run hcloud obs config with correct credentials |
⚠️ obsutil credential check process
>
Before any OBS operation, verify that obsutil credentials are available:
```bash
hcloud obs ls -limit=1
```
If the response isPlease set ak, sk and endpoint in the configuration file!orInvalidAccessKeyId,
inform the user of the following example command and have them configure it in their terminal:
>
```
obsutil credentials are not configured. Please run the following command in your terminal to configure (AK/SK can be obtained from the Huawei Cloud console "My Credentials" page):
>
hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.<Region>.myhuaweicloud.com
>
Example (Guangzhou region):
hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.cn-south-1.myhuaweicloud.com
>
Common Endpoints:
cn-north-4 → obs.cn-north-4.myhuaweicloud.com
cn-east-3 → obs.cn-east-3.myhuaweicloud.com
cn-south-1 → obs.cn-south-1.myhuaweicloud.com
cn-southwest-2 → obs.cn-southwest-2.myhuaweicloud.com
>
Retry after configuration is complete.
```
---
obsutil Upload Issues
1. Upload timeout or slow speed
Problem: Upload of large files or many files times out or is very slow.
Solution:
# Increase concurrency
obsutil cp <LocalPath> obs://<BucketName>/<Prefix> -r -p=10
# Decrease concurrency (for unstable networks)
obsutil cp <LocalPath> obs://<BucketName>/<Prefix> -r -p=3
# Adjust part size (for large file scenarios)
obsutil cp <LocalPath> obs://<BucketName>/<Prefix> -threshold=100MB2. Resume after upload interruption
Problem: Network interruption or abnormal program exit during upload.
Solution:
# Use resumable upload (enabled by default)
obsutil cp <LocalPath> obs://<BucketName>/<Prefix> -r -fr
# View resumable upload records
obsutil ls -failed -limit=1003. Upload reports "access denied"
Problem: Upload returns 403 Access Denied.
Root cause investigation:
1. obsutil credentials not configured or invalid
# Check if obsutil credentials are configured: run ls command; if error, not configured
hcloud obs ls -limit=1If not configured, inform the user to run in their terminal:
hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.<Region>.myhuaweicloud.comExample (Guangzhou region):
hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.cn-south-1.myhuaweicloud.comAK/SK can be obtained from the Huawei Cloud console "My Credentials" page. Do not ask the user to provide AK/SK directly in the conversation.
2. Insufficient IAM permissions
- Check if IAM policy includes
obs:object:PutObjectpermission
3. Bucket policy restriction
- Check if bucket policy restricts upload operations
- View via OBS console → Bucket → Access Control → Bucket Policy
4. Bucket ACL restriction
- Check if bucket ACL allows the current account to upload
4. Upload reports "bucket not exist"
Problem: Upload returns 404 Bucket Not Found.
Root cause:
- Bucket name typo (OBS bucket names are globally unique; must match exactly)
- Bucket region does not match the Endpoint configured in obsutil
Solution:
# List buckets first to confirm bucket name and region
obsutil ls -limit=100
# Confirm Endpoint configuration is correct
obsutil config -help---
CES Monitoring Data Issues
1. CES query returns empty data
Problem: CES ShowMetricData returns an empty datapoints array.
Possible causes and solutions:
1. Incorrect bucket name
- Confirm dimensions.0.value uses the correct bucket name
2. No data in time range
- Bucket has no corresponding operations in the time period (e.g., no download traffic, no requests)
- Try expanding the time range to verify
3. CES data collection delay
- CES metric data typically has a 1-5 minute delay
- If querying data from the last few minutes, it may not have been collected yet
4. Incorrect namespace or metric name
- Confirm namespace is
SYS.OBS(notOBSorSYS.OBJECT_STORAGE) - Confirm metric_name is correct (e.g.,
download_bytesnotdownload_flow)
5. period parameter mismatch
- Data granularity must match period
- OBS monitoring metrics default collection period is 5 minutes
- For long-term queries, set period to 86400 (1 day)
2. CES ShowMetricData parameter format errors
Key parameter reference:
| Parameter | Correct Value | Common Error |
|---|---|---|
--namespace | SYS.OBS | OBS, SYS.OBJECT_STORAGE |
--metric_name | download_bytes | downloadBytes, download_flow |
--dimensions.0.name | bucket_name | bucket, bucketName |
--period | 86400 | 86400000 (milliseconds instead of seconds) |
--filter | sum | SUM, total |
--from/--to | Millisecond timestamp (13 digits) | Second timestamp (10 digits) |
3. CES ShowMetricData does not support --User-Agent parameter
Problem: Running hcloud CES ShowMetricData --User-Agent=xxx returns error [USE_ERROR]Invalid parameter:User-Agent.
Root cause: The CES module's ShowMetricData command does not support the --User-Agent parameter. This parameter is only available in some OBS module commands.
Solution: CES query commands must not append the --User-Agent parameter.
4. Month-over-month with last month data being 0
Problem: Last month traffic or request data is 0, making MoM calculation impossible.
Possible causes:
- Bucket was just created last month with no operation data
- CES monitoring was not enabled or data collection did not cover last month
- Time range calculation error
Handling:
- Last month=0 and current month>0: Display "New (last month was 0)"
- Last month=0 and current month=0: Display "N/A"
---
Scheduled Upload Issues
1. Crontab scheduled task not executing
Problem: Crontab is set but the upload script does not execute on schedule.
Troubleshooting steps:
1. Check if crontab is set successfully
crontab -l2. Check if cron service is running
# Linux
systemctl status cron
# macOS
sudo launchctl list | grep cron3. Check script execution permissions
ls -la $HOME/obs-scheduled-upload-<BucketName>.sh
chmod +x $HOME/obs-scheduled-upload-<BucketName>.sh4. Check PATH environment variable
# Crontab has minimal PATH; add to script
# Add at the top of the script:
export PATH=/usr/local/bin:/usr/bin:/bin:$PATH5. View upload log
tail -f $HOME/obs-scheduled-upload-<BucketName>.log2. Crontab executes but upload fails
Problem: Crontab log shows execution but obsutil upload errors.
Common causes:
- obsutil credential file inaccessible in crontab environment
- Network issues
- Insufficient disk space
Solution:
# Use full path to obsutil in the upload script
/usr/local/bin/obsutil cp <LocalDirPath> obs://<BucketName>/<Prefix> -r
# Specify obsutil config file path
obsutil cp <LocalDirPath> obs://<BucketName>/<Prefix> -r -config=/home/user/.obsutilconfig3. Delete scheduled task
# Delete a specific OBS upload scheduled task
crontab -l | grep -v "obs-scheduled-upload-<BucketName>" | crontab -
# Clear all scheduled tasks (use with caution!)
# crontab -r---
Bucket Capacity Query Issues
1. Archived bucket capacity display is incomplete
Problem: GetBucketStorageInfo returns capacity and object count less than actual values.
Root cause: Archived storage class objects need to be restored before they can be accessed; unrestored objects are not counted.
Solution:
- Archived objects must be restored (RestoreObject) before they can be counted
- For accurate archived object statistics, use CES monitoring metrics
cold_storage_bytes/cold_object_count
2. GetBucketStorageInfo performance issues
Problem: Querying capacity for buckets with large numbers of objects (millions+) takes a long time.
Solution:
- Use CES monitoring metrics
standard_storage_bytes/standard_object_countas an alternative (slightly less real-time but better performance) - Set query timeout and retry
---
Month-over-Month Calculation Issues
1. Time range calculation errors
Correct calculation method:
# Current month start time
current_month_start = "$(date +%Y-%m-01)" # e.g., 2026-05-01
# Convert to millisecond timestamp
from_timestamp = $(date -d "$current_month_start" +%s)000 # e.g., 1746057600000
# Current month end time (current time)
to_timestamp = $(date +%s)000
# Last month start time
last_month_start = "$(date -d "$(date +%Y-%m-01) -1 month" +%Y-%m-01)"
# Last month end time (last day of previous month 23:59:59)
last_month_end = "$(date -d "$(date +%Y-%m-01) -1 second" +%Y-%m-%dT23:59:59)"2. Traffic unit conversion
Bytes → KB: / 1024
Bytes → MB: / (1024 * 1024)
Bytes → GB: / (1024 * 1024 * 1024)
Bytes → TB: / (1024 * 1024 * 1024 * 1024)Recommendation: Choose an appropriate display unit based on traffic size:
- < 1 MB → Display KB
- < 1 GB → Display MB
- < 1 TB → Display GB
- >= 1 TB → Display TB
---
Official Documentation
Verification Method - Huawei Cloud OBS Object Storage Management
Table of Contents
- Verify Bucket List Query
- Verify File Upload
- Verify Scheduled Upload
- Verify Traffic Query
- Verify Request Query
- End-to-End Verification Script
---
Verify Bucket List Query
Step 1: List buckets
hcloud obs lsExpected result:
- Returns a bucket list, each bucket containing
Name,Location,CreationDate - If no buckets exist, returns an empty list (normal)
Step 2: Query bucket capacity and object count
hcloud OBS GetBucketStorageInfo \
--region=cn-south-1 \
--bucket=<BucketName>Expected result:
- Returns
size(bytes) andobjectNumber(object count) - size >= 0, objectNumber >= 0
Step 3: Verify output format
Bucket Capacity(GB) Objects
my-bucket-1 125.3 1024
my-bucket-2 0.5 15Verification items:
- ✅ Capacity is in GB, with 1 decimal place
- ✅ Object count is an integer
- ✅ All buckets have been queried
---
Verify File Upload
Step 1: Upload test file
# Create test file
echo "test content" > /tmp/obs-upload-test.txt
# Upload
obsutil cp /tmp/obs-upload-test.txt obs://<BucketName>/test/obs-upload-test.txt -flatExpected result:
- Returns upload success message
- Shows uploaded file size and duration
Step 2: Verify file has been uploaded
obsutil ls obs://<BucketName>/test/ -limit=10Expected result:
- List contains
test/obs-upload-test.txt - File size matches local file
Step 3: Clean up test file
# Delete test object via OBS console, or manually via obsutil
obsutil rm obs://<BucketName>/test/obs-upload-test.txt -flat⚠️ Note: This cleanup step is a necessary operation in the verification process, not a skill feature; it must be executed manually.
---
Verify Scheduled Upload
Step 1: Create upload script
# Create test directory and file
mkdir -p /tmp/obs-scheduled-test
echo "test $(date)" > /tmp/obs-scheduled-test/test.txt
# Create upload script
cat > $HOME/obs-scheduled-upload-test.sh << 'EOF'
#!/bin/bash
export PATH=/usr/local/bin:$PATH
LOG_FILE="$HOME/obs-scheduled-upload-test.log"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting scheduled upload" >> "$LOG_FILE"
obsutil cp /tmp/obs-scheduled-test/ obs://<BucketName>/scheduled-test/ -r >> "$LOG_FILE" 2>&1
EOF
chmod +x $HOME/obs-scheduled-upload-test.shStep 2: Set crontab (every 5 minutes, for testing only)
(crontab -l 2>/dev/null; echo "*/5 * * * * /bin/bash $HOME/obs-scheduled-upload-test.sh") | crontab -Step 3: Verify scheduled task
# Check crontab
crontab -l
# Wait 5 minutes then check log
sleep 310
cat $HOME/obs-scheduled-upload-test.log
# Check files in OBS bucket
obsutil ls obs://<BucketName>/scheduled-test/ -limit=10Step 4: Clean up scheduled task
crontab -l | grep -v "obs-scheduled-upload-test" | crontab -
rm $HOME/obs-scheduled-upload-test.sh $HOME/obs-scheduled-upload-test.log---
Verify Traffic Query
Step 1: Calculate time range
# Current month start timestamp (ms)
FROM_TS=$(($(date -d "$(date +%Y-%m-01)" +%s) * 1000))
# Current timestamp (ms)
TO_TS=$(($(date +%s) * 1000))
# Last month start timestamp (ms)
LAST_MONTH_FROM_TS=$(($(date -d "$(date -d "$(date +%Y-%m-01) -1 month" +%Y-%m-01)" +%s) * 1000))
# Last month end timestamp (ms)
LAST_MONTH_TO_TS=$(($(date -d "$(date +%Y-%m-01) -1 second" +%s) * 1000))Step 2: Query current month external download traffic
hcloud CES ShowMetricData \
--region=cn-south-1 \
--namespace=SYS.OBS \
--metric_name=download_bytes \
--dimensions.0.name=bucket_name \
--dimensions.0.value=<BucketName> \
--period=86400 \
--filter=sum \
--from=$FROM_TS \
--to=$TO_TS \
Expected result:
- Returns datapoints array
- Each datapoint contains timestamp and sum value
Step 3: Query last month external download traffic
hcloud CES ShowMetricData \
--region=cn-south-1 \
--namespace=SYS.OBS \
--metric_name=download_bytes \
--dimensions.0.name=bucket_name \
--dimensions.0.value=<BucketName> \
--period=86400 \
--filter=sum \
--from=$LAST_MONTH_FROM_TS \
--to=$LAST_MONTH_TO_TS \
Step 4: Verify month-over-month calculation
MoM (%) = (Current Month Value - Last Month Value) / Last Month Value × 100%Verification items:
- ✅ Traffic value returned in Bytes, needs to be converted to GB for display
- ✅ MoM percentage rounded to 2 decimal places
- ✅ Special handling when last month value is 0
---
Verify Request Query
Step 1: Query current month total request count
hcloud CES ShowMetricData \
--region=cn-south-1 \
--namespace=SYS.OBS \
--metric_name=request_count \
--dimensions.0.name=bucket_name \
--dimensions.0.value=<BucketName> \
--period=86400 \
--filter=sum \
--from=$FROM_TS \
--to=$TO_TS \
Expected result:
- Returns datapoints array, sum value is the request count
Step 2: Query request count by type
# GET request count
hcloud CES ShowMetricData \
--region=cn-south-1 \
--namespace=SYS.OBS \
--metric_name=get_request_count \
--dimensions.0.name=bucket_name \
--dimensions.0.value=<BucketName> \
--period=86400 \
--filter=sum \
--from=$FROM_TS \
--to=$TO_TS \
# PUT request count
hcloud CES ShowMetricData \
--region=cn-south-1 \
--namespace=SYS.OBS \
--metric_name=put_request_count \
--dimensions.0.name=bucket_name \
--dimensions.0.value=<BucketName> \
--period=86400 \
--filter=sum \
--from=$FROM_TS \
--to=$TO_TS \
Step 3: Verify aggregation
Verification items:
- ✅ request_count >= get_request_count + put_request_count
- ✅ All request counts >= 0
- ✅ MoM calculation is correct
---
End-to-End Verification Script
#!/bin/bash
# OBS management skill end-to-end verification script
REGION="${1:-cn-south-1}"
BUCKET_NAME="${2}"
if [ -z "$BUCKET_NAME" ]; then
echo "Usage: $0 <region> <bucket_name>"
exit 1
fi
echo "=========================================="
echo "OBS Management Skill End-to-End Verification"
echo "Region: $REGION"
echo "Bucket: $BUCKET_NAME"
echo "=========================================="
# 1. Verify hcloud
echo -e "\n[1/6] Verifying hcloud version..."
hcloud version
# 2. Verify obsutil
echo -e "\n[2/6] Verifying obsutil version..."
obsutil version
# 3. Verify bucket list
echo -e "\n[3/6] Verifying bucket list query..."
hcloud obs ls
# 4. Verify bucket capacity
echo -e "\n[4/6] Verifying bucket capacity query..."
hcloud OBS GetBucketStorageInfo \
--region=$REGION \
--bucket=$BUCKET_NAME \
# 5. Verify CES traffic metrics
FROM_TS=$(($(date -d "$(date +%Y-%m-01)" +%s) * 1000))
TO_TS=$(($(date +%s) * 1000))
echo -e "\n[5/6] Verifying CES external download traffic query..."
hcloud CES ShowMetricData \
--region=$REGION \
--namespace=SYS.OBS \
--metric_name=download_bytes \
--dimensions.0.name=bucket_name \
--dimensions.0.value=$BUCKET_NAME \
--period=86400 \
--filter=sum \
--from=$FROM_TS \
--to=$TO_TS \
# 6. Verify CES request metrics
echo -e "\n[6/6] Verifying CES total request count query..."
hcloud CES ShowMetricData \
--region=$REGION \
--namespace=SYS.OBS \
--metric_name=request_count \
--dimensions.0.name=bucket_name \
--dimensions.0.value=$BUCKET_NAME \
--period=86400 \
--filter=sum \
--from=$FROM_TS \
--to=$TO_TS \
echo -e "\n=========================================="
echo "Verification complete!"
echo "=========================================="---
Error Handling
| Error Code | Description | Troubleshooting Command |
|---|---|---|
| 403 | Insufficient permissions | hcloud configure list to check credentials |
| 404 | Bucket does not exist | obsutil ls -limit=100 to list buckets |
| 400 | Invalid request parameters | Check region, bucket name, and other parameters |
| 500 | Internal service error | Retry later or contact Huawei Cloud technical support |
| Empty datapoints | No CES data | Check namespace, metric_name, and time range |