GetDiskUsedData
Monitor disk partition usage for Alibaba Cloud ECS instances to optimize storage allocation and identify resource bottlenecks.
Instructions
获取磁盘分区使用量指标数据
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| InstanceIds | Yes | AlibabaCloud ECS instance ID List | |
| RegionId | No | AlibabaCloud region ID | cn-hangzhou |
Implementation Reference
- Handler function for the 'CMS_GetDiskUsedData' tool. It fetches disk used metrics data from Alibaba Cloud CMS using the _get_cms_metric_data helper. Includes Pydantic Fields for input schema validation and descriptions.@tools.append def CMS_GetDiskUsedData( InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'), RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou') ): """获取磁盘分区使用量指标数据""" return _get_cms_metric_data(RegionId, InstanceIds, 'diskusage_used')
- src/alibaba_cloud_ops_mcp_server/server.py:84-85 (registration)Registration of all CMS tools (including CMS_GetDiskUsedData) into the FastMCP server by iterating over cms_tools.tools and calling mcp.tool(tool).for tool in cms_tools.tools: mcp.tool(tool)
- Core helper function that queries Alibaba Cloud CMS for metric data (used by CMS_GetDiskUsedData with metric 'diskusage_used'). Creates client, builds dimensions, calls describe_metric_last API, and returns datapoints.def _get_cms_metric_data(region_id: str, instance_ids: List[str], metric_name: str): client = create_client(region_id) dimesion = [] for instance_id in instance_ids: dimesion.append({ 'instanceId': instance_id }) describe_metric_last_request = cms_20190101_models.DescribeMetricLastRequest( namespace='acs_ecs_dashboard', metric_name=metric_name, dimensions=json.dumps(dimesion), ) describe_metric_last_resp = client.describe_metric_last(describe_metric_last_request) logger.info(f'CMS Tools response: {describe_metric_last_resp.body}') return describe_metric_last_resp.body.datapoints
- Helper function to create the Alibaba Cloud CMS client configured for the metrics endpoint in the specified region.def create_client(region_id: str) -> cms20190101Client: config = create_config() config.endpoint = f'metrics.{region_id}.aliyuncs.com' return cms20190101Client(config)