Install
openclaw skills install @huaweiclouddev/huawei-cloud-eip-cost-optimizerHuawei Cloud EIP (Elastic IP) cost optimization skill using hcloud CLI (KooCLI). 1. List and query EIPs across regions with detailed status 2. Identify idle/unbound EIPs and generate cost optimization reports 3. Set up idle EIP monitoring with webhook/email alerts 4. Generate HTML/JSON cost analysis reports 5. Maintain operation audit logs for compliance **Read-only analysis only - NO bandwidth adjustment, tag management, or EIP release/deletion**. Triggers include: "EIP cost optimization", "idle EIP analysis", "EIP audit", "cost report", "EIP status query", "EIP list", "EIP monitoring", "EIP alert", "cost analysis", "idle monitoring", "operation audit", "EIP 成本优化", "闲置 EIP 分析", "EIP 审计", "成本报告", "EIP 状态查询", "EIP 查询", "EIP 列表", "EIP 监控", "EIP 告警", "成本分析", "闲置监控", "操作审计"
openclaw skills install @huaweiclouddev/huawei-cloud-eip-cost-optimizerThis skill provides batch management and cost optimization capabilities for Huawei Cloud Elastic Public IPs (EIPs).
Architecture: Shell + hcloud CLI (KooCLI) → EIP Service API → VPC/Bandwidth resources
Related Skills: For broader cost optimization across all resource types (ECS, EVS, OBS, etc.), see the archived huaweicloud-cost-optimizer skill. This skill focuses exclusively on EIP optimization with deeper functionality and 100% hcloud CLI compliance.
Typical Use Cases:
Install hcloud CLI:
# Linux/macOS one-click install
curl -sSL https://hwcloudcli.obs.cn-north-1.myhuaweicloud.com/cli/latest/hcloud_install.sh | bash
# Verify installation
hcloud --version
Install jq, bc, curl:
# Ubuntu/Debian
sudo apt install -y jq bc curl
# CentOS/RHEL
sudo yum install -y jq bc curl
# macOS
brew install jq bc curl
Available Shell Scripts:
scripts/config.sh - Shared configuration (credentials, regions, proxy)scripts/list_eips.sh - List all EIPs in a region (supports filtering and summary)scripts/analyze_idle_eips.sh - Analyze idle EIPs and generate optimization reports (read-only)scripts/eip_cost_report.sh - Generate EIP cost analysis reports (text/HTML/JSON)scripts/monitor_idle_eips.sh - Monitor idle EIPs with webhook/email alerts and cron supportscripts/check_env.sh - Environment check and validation (hcloud CLI + tools + API)scripts/eip_audit_log.sh - Operation audit logging (JSONL + CSV/JSON export)Note: All scripts are READ-ONLY. This skill does NOT perform bandwidth adjustment, tag management, or EIP release/deletion.
This skill supports one authentication path via environment variables:
export HW_ACCESS_KEY=<your-ak>
export HW_SECRET_KEY=<your-sk>
export HW_REGION_NAME=cn-north-4
Note: If you have already configured
hcloud configureinteractively (entering credentials via prompts, not command-line arguments), the skill will also detect and use those credentials.
Environment Variables:
| Variable | Required | Description |
|---|---|---|
HW_ACCESS_KEY | Optional | Huawei Cloud Access Key ID (required only if hcloud configure not set) |
HW_SECRET_KEY | Optional | Huawei Cloud Secret Access Key (required only if hcloud configure not set) |
HW_REGION_NAME | Optional | Default region (default: cn-north-4) |
HW_SECURITY_TOKEN | Optional | Security token for temporary credentials |
Security Notes:
ps aux)./scripts/check_env.sh to validate credentials before running scripts# Step 1: Configure authentication via environment variables
export HW_ACCESS_KEY=<your-ak>
export HW_SECRET_KEY=<your-sk>
export HW_REGION_NAME=cn-north-4
# Step 2: Run environment check
bash scripts/check_env.sh
# Step 3: Run scripts
bash scripts/list_eips.sh --region cn-north-4
bash scripts/analyze_idle_eips.sh --idle-days 7
bash scripts/eip_cost_report.sh --format html
Note: This skill is READ-ONLY for EIP resources. It does NOT perform any write operations.
| API Action | Permission | Purpose |
|---|---|---|
vpc:publicIps:list | List EIPs | Query all EIPs and their status |
vpc:publicIps:get | Get EIP details | View individual EIP information |
List EIPs across regions, filter by status, output as JSON/table.
Detect unbound EIPs idle beyond threshold, calculate holding costs, generate optimization report.
Aggregate EIP cost data, render as HTML or JSON report with savings recommendations.
Periodically check for idle EIPs, send alerts via webhook or email when detected.
All EIP operations (list/analyze/report/monitor) automatically write to the audit log file for compliance. Each script records its own action on exit. Query history with --action query-log --days N.
All EIP operations use hcloud CLI commands:
| Python SDK Method | hcloud CLI Command | Description |
|---|---|---|
EipClient.list_publicips() | hcloud EIP ListPublicips/v2 --cli-region=<region> | List all EIPs |
EipClient.show_publicip() | hcloud EIP ShowPublicip/v2 --publicip_id=<id> | Get EIP details |
IamClient.keystone_list_projects() | hcloud IAM KeystoneListProjects | List projects |
Output format: All commands use --cli-output=json for machine-readable output, parsed by jq.
| Command | Description | Backend |
|---|---|---|
list_eips.sh | List and query EIPs across regions | hcloud CLI |
analyze_idle_eips.sh | Identify idle/unbound EIPs with cost analysis | hcloud CLI |
eip_cost_report.sh | Generate HTML/JSON cost analysis reports | hcloud CLI |
monitor_idle_eips.sh | Set up idle EIP monitoring with alerts | hcloud CLI |
eip_audit_log.sh | Maintain operation audit logs | Shell |
check_env.sh | Verify environment prerequisites | Shell |
config.sh | Load configuration and credentials | Shell |
# List all EIPs in a region
bash scripts/list_eips.sh --region cn-north-4
# List EIPs with status filter
bash scripts/list_eips.sh --region cn-north-4 --status DOWN
# List EIPs across multiple regions
bash scripts/list_eips.sh --region cn-north-4,cn-east-3,cn-south-1
# Analyze idle EIPs (default threshold: 0 days = all unbound)
bash scripts/analyze_idle_eips.sh
# Custom idle threshold (14 days)
bash scripts/analyze_idle_eips.sh --idle-days 14
# Analyze specific region with JSON output
bash scripts/analyze_idle_eips.sh --region cn-north-4 --idle-days 7 --json
# Generate text cost report (default)
bash scripts/eip_cost_report.sh
# Generate HTML report
bash scripts/eip_cost_report.sh --format html
# Generate JSON report
bash scripts/eip_cost_report.sh --format json
# Custom region
bash scripts/eip_cost_report.sh --region cn-east-3 --format html
Cost Model: Bandwidth-based pricing (~3 CNY/Mbps/month for cn-north-4 on-demand) + IP retain fee (~0.02 CNY/hour for unbound EIPs). API does not return charge_mode, so all estimates use bandwidth billing model.
# Monitor idle EIPs (default threshold: 7 days)
bash scripts/monitor_idle_eips.sh
# Custom threshold
bash scripts/monitor_idle_eips.sh --idle-days 14
# Monitor with webhook alert (only DingTalk/WeCom/Slack HTTPS URLs are allowed)
bash scripts/monitor_idle_eips.sh --idle-days 7 --webhook "https://oapi.dingtalk.com/robot/send?access_token=YOUR_ACCESS_TOKEN"
# Monitor with email alert
bash scripts/monitor_idle_eips.sh --idle-days 7 --email admin@example.com
# Set up daily cron job (9:00 AM) - REQUIRES webhook or email, otherwise it's rejected.
# The cron line embeds the alert parameters so scheduled runs actually notify.
bash scripts/monitor_idle_eips.sh --region cn-north-4 --idle-days 7 --setup-cron \
--webhook "https://oapi.dingtalk.com/robot/send?access_token=YOUR_ACCESS_TOKEN"
# Remove cron job
bash scripts/monitor_idle_eips.sh --remove-cron
# Full environment validation (CLI + tools + API)
bash scripts/check_env.sh
# Verbose mode (show versions)
bash scripts/check_env.sh --verbose
# Auto-fix missing dependencies
bash scripts/check_env.sh --fix
# Log an EIP list operation
bash scripts/eip_audit_log.sh --action list --detail "Queried all EIPs"
# Log an analyze operation
bash scripts/eip_audit_log.sh --action analyze --detail "Idle EIP analysis for cn-north-4"
# Export audit logs to CSV
bash scripts/eip_audit_log.sh --action list --export csv
# Export audit logs to JSON
bash scripts/eip_audit_log.sh --action list --export json
# Custom log directory (must NOT be a system dir; will be created if missing)
bash scripts/eip_audit_log.sh --action list --log-dir ~/eip_audit_logs
# Query audit history for the last 30 days
bash scripts/eip_audit_log.sh --action query-log --days 30
# Query audit history for a specific action type
bash scripts/eip_audit_log.sh --action query-log --days 7
Audit Log Entry Format (JSONL, timezone-aware timestamps):
{
"timestamp": "2026-07-16T10:30:00+08:00",
"region": "cn-north-4",
"action": "list",
"detail": "Queried all EIPs",
"user": "root"
}
# General format
hcloud <Service> <Operation> --cli-region=<region> --param1=value1 --param2=value2
# EIP list example
hcloud EIP ListPublicips/v2 --cli-region=cn-north-4
# EIP show detail
hcloud EIP ShowPublicip/v2 --cli-region=cn-north-4 --publicip_id=<id>
| Feature | Description | Example |
|---------|-------------|---------||
| Service name | Uppercase PascalCase | EIP, VPC, IAM |
| Operation name | PascalCase with version | ListPublicips/v2, ShowPublicip/v2 |
| Region param | --cli-region=<value> | --cli-region=cn-north-4 |
| Simple param | --key=value | --publicip_id=xxx |
| Output format | --cli-output=json | JSON output for programmatic parsing |
| Script | Parameter | Required/Optional | Description | Default |
|---|---|---|---|---|
list_eips.sh | --region | Optional | Region(s), comma-separated | HW_REGION_NAME or cn-north-4 |
list_eips.sh | --status | Optional | Filter by status (ACTIVE/DOWN/ERROR) | All |
analyze_idle_eips.sh | --region | Optional | Target region | HW_REGION_NAME or cn-north-4 |
analyze_idle_eips.sh | --idle-days | Optional | Idle threshold in days | 0 (all unbound) |
analyze_idle_eips.sh | --json | Optional | Output JSON format report | false |
eip_cost_report.sh | --region | Optional | Target region | HW_REGION_NAME or cn-north-4 |
eip_cost_report.sh | --format | Optional | Output format: text/html/json | text |
monitor_idle_eips.sh | --region | Optional | Target region | HW_REGION_NAME or cn-north-4 |
monitor_idle_eips.sh | --idle-days | Optional | Idle threshold in days | 7 |
monitor_idle_eips.sh | --webhook | Optional | Webhook alert URL | - |
monitor_idle_eips.sh | --email | Optional | Alert email address | - |
monitor_idle_eips.sh | --setup-cron | Optional | Set up cron monitoring | - |
monitor_idle_eips.sh | --remove-cron | Optional | Remove cron monitoring | - |
check_env.sh | --verbose | Optional | Show detailed check info | false |
check_env.sh | --fix | Optional | Auto-fix missing dependencies | false |
eip_audit_log.sh | --action | Required | Operation type (list/query/analyze/monitor/report) | - |
eip_audit_log.sh | --detail | Optional | Operation detail description | - |
eip_audit_log.sh | --export | Optional | Export format: csv/json | - |
eip_audit_log.sh | --log-dir | Optional | Log directory path | ./eip_audit_logs |
| Variable | Required | Description | Default |
|---|---|---|---|
HW_ACCESS_KEY | Optional* | Huawei Cloud AK (required only if hcloud configure not set) | - |
HW_SECRET_KEY | Optional* | Huawei Cloud SK (required only if hcloud configure not set) | - |
HW_REGION_NAME | Optional | Default region | cn-north-4 |
HW_SECURITY_TOKEN | Optional | Temporary credential token | - |
*When hcloud configure is already set up, HW_ACCESS_KEY and HW_SECRET_KEY are not needed. Environment variables take precedence when both are configured.
========================================
Huawei Cloud EIP List (Region: cn-north-4)
========================================
EIP ID: eip-xxx1, IP: 123.45.67.89, BW: 5 Mbps, Status: BOUND (ECS: ecs-xxx)
EIP ID: eip-xxx2, IP: 98.76.54.32, BW: 10 Mbps, Status: UNBOUND ⚠️
========================================
Total: 2 EIPs, Idle: 1
Generated by scripts/eip_cost_report.sh — includes:
Pricing Model: Bandwidth-based (~3 CNY/Mbps/month + 0.02 CNY/hr IP retain fee for unbound EIPs)
# Run full environment check (CLI + tools + API)
bash scripts/check_env.sh
# Exit codes:
# 0 - All checks passed
# 1 - Missing dependencies or API errors
monitor_idle_eips.sh --setup-cron to catch idle EIPs earlyeip_cost_report.sh --format html to track optimization progresseip_audit_log.shlist_eips.sh supports comma-separated regions --region cn-north-4,cn-east-3 for cross-region listing. Note: analyze_idle_eips.sh, eip_cost_report.sh, and monitor_idle_eips.sh process a single region each (run once per region for multi-region analysis).check_env.sh first to verify hcloud CLI and dependenciesanalyze_idle_eips.sh and monitor_idle_eips.sh use --idle-days parameter with consistent timezone handling| Document | Description |
|---|---|
| IAM Permission Policies | Required permissions and policy JSON |
| EIP API Guide | EIP API reference (hcloud CLI) |
| CLI Installation Guide | hcloud CLI install, configure, troubleshoot |
| Verification Method | Step-by-step verification |
| Acceptance Criteria | Production readiness acceptance tests |
HW_ACCESS_KEY, HW_SECRET_KEY) or hcloud configure interactive mode (entering via prompts, not command-line arguments).HW_ACCESS_KEY, HW_SECRET_KEY) as the primary method. If hcloud configure is already set up interactively, the skill will detect and use those credentials. Never pass credentials as command-line arguments.HW_SECURITY_TOKEN when using temporary credentials.HW_* prefix for consistency with other Huawei Cloud skills.date command for epoch calculation, eliminating UTC offset issues.YYYY-MM-DDTHH:MM:SS+HH:MM (e.g., +08:00), not misleading Z suffix.| Pitfall | Symptom | Quick Fix |
|---|---|---|
| hcloud not installed | command not found: hcloud | Install KooCLI |
| jq not installed | JSON parse errors | sudo apt install jq |
| bc not installed | Cost calculation errors | sudo apt install bc |
| AK/SK not set | API 401 / credential error | Export HW_ACCESS_KEY/HW_SECRET_KEY or configure hcloud interactively |
| Wrong region | ❌ API 返回异常 | Use valid region ID (e.g., cn-north-4) |
| Invalid format | ❌ 不支持的格式 | Use text/html/json for --format |
| API rate limit | 429 Too Many Requests | Add delay between calls |