文档

huawei-cloud-eip-cost-optimizer

试用

Huawei 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 告警", "成本分析", "闲置监控", "操作审计"

它能做什么

Huawei 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 告警", "成本分析", "闲置监控", "操作审计"

技能文档

Huawei Cloud EIP Cost Optimizer

Overview

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

  • Periodic cleanup of idle EIPs to reduce holding costs
  • Cost analysis and optimization recommendations
  • Multi-region unified management
  • Automated monitoring and alerting for idle resources
  • Operation audit logging for compliance

Typical Use Cases:

  • "Help me identify idle EIPs and generate an optimization report"
  • "Generate an EIP cost analysis report to identify high-cost resources"
  • "Set up idle EIP monitoring with automatic alerts via webhook or email"
  • "View EIP distribution and status summary across all regions"
  • "Show audit logs for EIP operations in the last 30 days"
  • "List all EIPs in cn-north-4 with detailed information"

Prerequisites

1. CLI Environment Requirements (MANDATORY)

  • hcloud CLI (KooCLI) v7.0+ — Huawei Cloud command-line tool
  • jq — JSON processor for parsing API responses
  • bc — Arbitrary precision calculator for cost estimation
  • curl — HTTP client for webhook notifications

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 support
  • scripts/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.

2. Authentication Configuration

This skill supports one authentication path via environment variables:

Environment Variables

export HW_ACCESS_KEY=
export HW_SECRET_KEY=
export HW_REGION_NAME=cn-north-4

Note: If you have already configured hcloud configure interactively (entering credentials via prompts, not command-line arguments), the skill will also detect and use those credentials.

Environment Variables:

VariableRequiredDescription
HW_ACCESS_KEYOptionalHuawei Cloud Access Key ID (required only if hcloud configure not set)
HW_SECRET_KEYOptionalHuawei Cloud Secret Access Key (required only if hcloud configure not set)
HW_REGION_NAMEOptionalDefault region (default: cn-north-4)
HW_SECURITY_TOKENOptionalSecurity token for temporary credentials

Security Notes:

  • Never commit credentials to version control
  • Never expose AK/SK values in code, conversation, or commands
  • Never pass AK/SK values as command-line arguments (exposes credentials in shell history and ps aux)
  • Use IAM users with minimal required permissions
  • Enable MFA for sensitive operations
  • Rotate AK/SK regularly
  • Use ./scripts/check_env.sh to validate credentials before running scripts

3. Quick Start

# Step 1: Configure authentication via environment variables
export HW_ACCESS_KEY=
export HW_SECRET_KEY=
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

4. IAM Permission Requirements

Note: This skill is READ-ONLY for EIP resources. It does NOT perform any write operations.

API ActionPermissionPurpose
vpc:publicIps:listList EIPsQuery all EIPs and their status
vpc:publicIps:getGet EIP detailsView individual EIP information

Workflow

Main Steps

  1. Environment Check → Verify hcloud CLI, jq, credentials
  2. EIP Query → List EIPs across regions via hcloud CLI
  3. Idle Analysis → Identify unbound EIPs exceeding idle threshold
  4. Cost Report → Generate HTML/JSON cost analysis report
  5. Monitoring Setup → Configure idle EIP alerts (webhook/email)
  6. Audit Logging → Record operations for compliance

EIP Query Workflow

List EIPs across regions, filter by status, output as JSON/table.

Idle EIP Analysis Workflow

Detect unbound EIPs idle beyond threshold, calculate holding costs, generate optimization report.

Cost Report Workflow

Aggregate EIP cost data, render as HTML or JSON report with savings recommendations.

Idle EIP Monitoring Workflow

Periodically check for idle EIPs, send alerts via webhook or email when detected.

Audit Log Workflow

Record all EIP operations (list/analyze/report/monitor) to audit log file for compliance.

All EIP operations use hcloud CLI commands:

Python SDK Methodhcloud CLI CommandDescription
EipClient.list_publicips()hcloud EIP ListPublicips/v2 --cli-region=List all EIPs
EipClient.show_publicip()hcloud EIP ShowPublicip/v2 --publicip_id=Get EIP details
IamClient.keystone_list_projects()hcloud IAM KeystoneListProjectsList projects

Output format: All commands use --cli-output=json for machine-readable output, parsed by jq.

Core Commands

CommandDescriptionBackend
list_eips.shList and query EIPs across regionshcloud CLI
analyze_idle_eips.shIdentify idle/unbound EIPs with cost analysishcloud CLI
eip_cost_report.shGenerate HTML/JSON cost analysis reportshcloud CLI
monitor_idle_eips.shSet up idle EIP monitoring with alertshcloud CLI
eip_audit_log.shMaintain operation audit logsShell
check_env.shVerify environment prerequisitesShell
config.shLoad configuration and credentialsShell

EIP Query

# 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

Idle EIP Analysis

# 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

Cost Report

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

Idle EIP Monitoring

# 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
bash scripts/monitor_idle_eips.sh --idle-days 7 --webhook https://hooks.example.com/alert

# 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)
bash scripts/monitor_idle_eips.sh --setup-cron

# Remove cron job
bash scripts/monitor_idle_eips.sh --remove-cron

Environment Check

# 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

Operation Audit Logging

# 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
bash scripts/eip_audit_log.sh --action list --log-dir /var/log/eip_audit

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"
}

KooCLI Command Format

# General format
hcloud   --cli-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=

| Feature | Description | Example | |---------|-------------|---------|| | Service name | Uppercase PascalCase | EIP, VPC, IAM | | Operation name | PascalCase with version | ListPublicips/v2, ShowPublicip/v2 | | Region param | --cli-region= | --cli-region=cn-north-4 | | Simple param | --key=value | --publicip_id=xxx | | Output format | --cli-output=json | JSON output for programmatic parsing |

Parameters

Shell Script Parameters

ScriptParameterRequired/OptionalDescriptionDefault
list_eips.sh--regionOptionalRegion(s), comma-separatedHW_REGION_NAME or cn-north-4
list_eips.sh--statusOptionalFilter by status (ACTIVE/DOWN/ERROR)All
analyze_idle_eips.sh--regionOptionalTarget regionHW_REGION_NAME or cn-north-4
analyze_idle_eips.sh--idle-daysOptionalIdle threshold in days0 (all unbound)
analyze_idle_eips.sh--jsonOptionalOutput JSON format reportfalse
eip_cost_report.sh--regionOptionalTarget regionHW_REGION_NAME or cn-north-4
eip_cost_report.sh--formatOptionalOutput format: text/html/jsontext
monitor_idle_eips.sh--regionOptionalTarget regionHW_REGION_NAME or cn-north-4
monitor_idle_eips.sh--idle-daysOptionalIdle threshold in days7
monitor_idle_eips.sh--webhookOptionalWebhook alert URL-
monitor_idle_eips.sh--emailOptionalAlert email address-
monitor_idle_eips.sh--setup-cronOptionalSet up cron monitoring-
monitor_idle_eips.sh--remove-cronOptionalRemove cron monitoring-
check_env.sh--verboseOptionalShow detailed check infofalse
check_env.sh--fixOptionalAuto-fix missing dependenciesfalse
eip_audit_log.sh--actionRequiredOperation type (list/query/analyze/monitor/report)-
eip_audit_log.sh--detailOptionalOperation detail description-
eip_audit_log.sh--exportOptionalExport format: csv/json-
eip_audit_log.sh--log-dirOptionalLog directory path./eip_audit_logs

Environment Variables

VariableRequiredDescriptionDefault
HW_ACCESS_KEYOptional*Huawei Cloud AK (required only if hcloud configure not set)-
HW_SECRET_KEYOptional*Huawei Cloud SK (required only if hcloud configure not set)-
HW_REGION_NAMEOptionalDefault regioncn-north-4
HW_SECURITY_TOKENOptionalTemporary 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.

Output Format

EIP List Output

========================================
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

Cost Report Output

Generated by scripts/eip_cost_report.sh — includes:

  • Summary statistics (total EIPs, idle, active, total bandwidth, costs)
  • Per-EIP detail table with cost estimates
  • Available in text, HTML, and JSON formats

Pricing Model: Bandwidth-based (~3 CNY/Mbps/month + 0.02 CNY/hr IP retain fee for unbound EIPs)

Verification

Environment Compliance Check

# Run full environment check (CLI + tools + API)
bash scripts/check_env.sh

# Exit codes:
#   0 - All checks passed
#   1 - Missing dependencies or API errors

Best Practices

  1. Use Shell Scripts EXCLUSIVELY: All scripts are Shell + hcloud CLI. No Python SDK dependency.
  2. Regular Monitoring: Set up daily cron jobs with monitor_idle_eips.sh --setup-cron to catch idle EIPs early
  3. Cost Reports: Generate weekly cost reports with eip_cost_report.sh --format html to track optimization progress
  4. Audit Logging: Enable audit logging for all EIP operations using eip_audit_log.sh
  5. Multi-Region Management: Use comma-separated regions --region cn-north-4,cn-east-3 for cross-region analysis
  6. Webhook Alerts: Configure webhooks for real-time idle EIP notifications
  7. Environment Validation: Always run check_env.sh first to verify hcloud CLI and dependencies
  8. Idle Days Consistency: Both analyze_idle_eips.sh and monitor_idle_eips.sh use --idle-days parameter with consistent timezone handling

References

DocumentDescription
IAM Permission PoliciesRequired permissions and policy JSON
EIP API GuideEIP API reference (hcloud CLI)
CLI Installation Guidehcloud CLI install, configure, troubleshoot
Verification MethodStep-by-step verification
Acceptance CriteriaProduction readiness acceptance tests

Notes

  • Cost estimates are for reference only — based on cn-north-4 on-demand pricing (bandwidth model: ~3 CNY/Mbps/month + 0.02 CNY/hr IP retain fee). Actual costs may vary by region and billing mode.
  • API does not return charge_mode — scripts cannot distinguish bandwidth vs traffic billing; all estimates use bandwidth model.
  • This skill is READ-ONLY — it analyzes and reports idle EIPs but does NOT release or delete any resources. Manual action in the console is required to release EIPs.
  • EIP release is irreversible — if you choose to release idle EIPs based on the analysis report, the public IP address will be reclaimed and cannot be recovered.
  • AK/SK must never be hardcoded — credentials should only be obtained via environment variables (HW_ACCESS_KEY, HW_SECRET_KEY) or hcloud configure interactive mode (entering via prompts, not command-line arguments).
  • hcloud CLI is the only supported method — all scripts use hcloud CLI (KooCLI) natively.
  • Authentication: Use environment variables (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.
  • Temporary Credentials Supported: This skill supports temporary AK/SK+Token obtained via IAM STS. Set HW_SECURITY_TOKEN when using temporary credentials.
  • Environment Variable Standard: Uses HW_* prefix for consistency with other Huawei Cloud skills.
  • jq is required for all scripts that parse hcloud CLI JSON output.
  • Idle days calculation is timezone-consistent — both analyze and monitor scripts use date command for epoch calculation, eliminating UTC offset issues.
  • Audit log timestamps are timezone-aware — format YYYY-MM-DDTHH:MM:SS+HH:MM (e.g., +08:00), not misleading Z suffix.

Common Pitfalls

PitfallSymptomQuick Fix
hcloud not installedcommand not found: hcloudInstall KooCLI
jq not installedJSON parse errorssudo apt install jq
bc not installedCost calculation errorssudo apt install bc
AK/SK not setAPI 401 / credential errorExport 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 limit429 Too Many RequestsAdd delay between calls

相关技能

Lists Huawei Cloud EIP (Elastic IP, 弹性公网IP) resources — enumerates all EIPs in a region with public IP address, EIP ID, status, bandwidth, associated instance and creation time, using the KooCLI `hcloud EIP ListPublicips` command (primary) or the huaweicloudsdkeip Python SDK (fallback). Provides read-only EIP inventory for network resource auditing, cost review and resource discovery. Use this skill whenever the user mentions EIP list query. Triggers include: list EIPs, EIP list, query EIP, enumerate EIPs, show EIPs, elastic IP list, public IP inventory, 查询弹性公网IP, EIP列表, 弹性公网IP列表, 查看EIP, 列出EIP, 获取EIP列表, 查询EIP, 查询公网IP.

Queries the EIP (Elastic IP, 弹性公网IP) bound to a single Huawei Cloud ECS instance — given an ECS ID or ECS name, returns the associated public IP address, EIP ID, status, bandwidth and binding details, using the KooCLI `hcloud EIP ListPublicips` command (primary, filtered by `vnic.device_id`) or the huaweicloudsdkeip Python SDK (fallback). Provides a read-only per-instance EIP lookup for network troubleshooting, cost review and resource discovery. Use this skill whenever the user wants the EIP of a specific ECS. Triggers include: ECS EIP query, EIP of ECS, find ECS public IP, ECS 的EIP, 查询ECS的弹性公网IP, ECS公网IP, ECS绑定的EIP, 单个ECS的eip, 查询ECS的eip, 查看ECS的弹性IP, ECS外网IP, 获取ECS公网地址.

Queries Huawei Cloud ECS (Elastic Cloud Server) resources in read-only mode. Covers ECS instances, flavors, keypairs, quotas, server groups, block devices, NICs, VNC console, launch templates, recycle bin, scheduled events, and tags. No write operations. Use this skill when the user needs to query ECS instance details, list flavors, check server status, view block devices, or inspect ECS resource attributes. Triggers include: 查询ECS, ECS实例查询, 云服务器查询, 弹性云服务器, ECS规格, ECS配额, 云服务器列表, ECS详情, query ECS, list ECS servers, show server details, ECS flavors, ECS quotas, ECS keypairs, server groups, block devices, ECS inventory, cloud server list, ecs list, ecs query, ecs show.

通过华为云命令行工具 hcloud 调用云监控服务 CES,查询 ECS 实例的 CPU、内存、磁盘与网络指标。

作者 huaweicloud-skills-team6 次安装

Automate batch creation and management of Huawei Cloud CES alarm rules for ECS instances using hcloud CLI v7.2.2+. Use this skill to: (1) batch create alarms with templates (web/database), (2) update SMN notifications, (3) query ECS metrics and alarm lists. Trigger: "ECS alert", "create alert", "list alarms", "CPU alert", "memory alert", "ECS monitoring", "监控告警", "创建告警", "ECS 监控", "告警规则", "查询告警"

作者 huaweicloud-skills-team

面向华为云资源的只读查询能力,用于资源清点、核对与参数发现。

作者 huaweicloud-skills-team6 次安装

huaweicloud-skills-team 的更多技能

浏览全部技能

用自然语言控制华为昇腾 NPU,本地或 SSH 远程执行 npu-smi 命令。

作者 huaweicloud-skills-team7 次安装

在华为云昇腾 910B DevServer 上按单机或双机(16 卡)拓扑部署并测试 LLM、VL、Embedding、Rerank 模型。

作者 huaweicloud-skills-team7 次安装

面向华为云资源的只读查询能力,用于资源清点、核对与参数发现。

作者 huaweicloud-skills-team6 次安装

通过本地 Python SDK 只读查询华为云 IAM 资源(用户、用户组、策略、委托、AK/SK、MFA、安全设置)。

作者 huaweicloud-skills-team6 次安装