阿里云
阿里云多端小程序中小企业获客首选
发表主题 回复主题
  • 1140阅读
  • 0回复

[云安全技术和产品专区 ]云监控PythonSDK使用手册

级别: 论坛粉丝
发帖
1227
云币
2325
KX^!t3l6  
SDK使用手册 Htm;N2$d  
前置条件: 1]wo    
需要安装有python2.7版本 wlEmy.)H  
安装pip V2B: DIpr  
如果已有pip或者使用其他方案,可忽略此步骤。 [NU@A>H  
如何安装pip rNl%I@G  
命令行工具 CLI,如果已安装,请略过: ai]KH7  
qir8RPW  
  1. [backcolor=transparent]pip install aliyuncli
  2. [backcolor=transparent]pip install [backcolor=transparent]-[backcolor=transparent]Iv[backcolor=transparent] aliyun[backcolor=transparent]-[backcolor=transparent]python[backcolor=transparent]-[backcolor=transparent]sdk[backcolor=transparent]-[backcolor=transparent]cms[backcolor=transparent]==[backcolor=transparent]5.0[backcolor=transparent].[backcolor=transparent]0
  3. [backcolor=transparent]aliyuncli configure
M!b-;{;'  
命令行工具 CLI 安装说明 ] ]lN[J  
b ~C^cM  
安装cms-python-sdk的依赖: C5^9D  
;XI=Y"h{%  
  1. [backcolor=transparent]pip install aliyun[backcolor=transparent]-[backcolor=transparent]python[backcolor=transparent]-[backcolor=transparent]sdk[backcolor=transparent]-[backcolor=transparent]core
  2. [backcolor=transparent]pip install aliyun[backcolor=transparent]-[backcolor=transparent]python[backcolor=transparent]-[backcolor=transparent]sdk[backcolor=transparent]-[backcolor=transparent]cms
Ol)M0u  
code示例: e8U6D+jY  
  1. [backcolor=transparent]from[backcolor=transparent] aliyunsdkcore [backcolor=transparent]import[backcolor=transparent] client
  2. [backcolor=transparent]from[backcolor=transparent] aliyunsdkcms[backcolor=transparent].[backcolor=transparent]request[backcolor=transparent].[backcolor=transparent]v20170301 [backcolor=transparent]import[backcolor=transparent] [backcolor=transparent]QueryMetricListRequest
  3. [backcolor=transparent]import[backcolor=transparent] time
  4. [backcolor=transparent]clt [backcolor=transparent]=[backcolor=transparent] client[backcolor=transparent].[backcolor=transparent]AcsClient[backcolor=transparent]([backcolor=transparent]'your_access_key'[backcolor=transparent],[backcolor=transparent]'your_access_secret'[backcolor=transparent],[backcolor=transparent]'your_region_id'[backcolor=transparent])
  5. [backcolor=transparent]request [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]QueryMetricListRequest[backcolor=transparent].[backcolor=transparent]QueryMetricListRequest[backcolor=transparent]()
  6. [backcolor=transparent]request[backcolor=transparent].[backcolor=transparent]set_accept_format[backcolor=transparent]([backcolor=transparent]'json'[backcolor=transparent])
  7. [backcolor=transparent]request[backcolor=transparent].[backcolor=transparent]set_Project[backcolor=transparent]([backcolor=transparent]'acs_ecs_dashboard'[backcolor=transparent])
  8. [backcolor=transparent]request[backcolor=transparent].[backcolor=transparent]set_Metric[backcolor=transparent]([backcolor=transparent]'CPUUtilization'[backcolor=transparent])
  9. [backcolor=transparent]start_time [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]"2016-10-25 10:00:00"
  10. [backcolor=transparent]timestamp_start [backcolor=transparent]=[backcolor=transparent] int[backcolor=transparent]([backcolor=transparent]time[backcolor=transparent].[backcolor=transparent]mktime[backcolor=transparent]([backcolor=transparent]time[backcolor=transparent].[backcolor=transparent]strptime[backcolor=transparent]([backcolor=transparent]start_time[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"%Y-%m-%d %H:%M:%S"[backcolor=transparent])))[backcolor=transparent] [backcolor=transparent]*[backcolor=transparent] [backcolor=transparent]1000
  11. [backcolor=transparent]request[backcolor=transparent].[backcolor=transparent]set_StartTime[backcolor=transparent]([backcolor=transparent]timestamp_start[backcolor=transparent])
  12. [backcolor=transparent]request[backcolor=transparent].[backcolor=transparent]set_Dimensions[backcolor=transparent]([backcolor=transparent]"{'instanceId':'i-94g5hc378'}"[backcolor=transparent])
  13. [backcolor=transparent]request[backcolor=transparent].[backcolor=transparent]set_Period[backcolor=transparent]([backcolor=transparent]'60'[backcolor=transparent])
  14. [backcolor=transparent]result [backcolor=transparent]=[backcolor=transparent] clt[backcolor=transparent].[backcolor=transparent]do_action_with_exception[backcolor=transparent]([backcolor=transparent]request[backcolor=transparent])
  15. [backcolor=transparent]print[backcolor=transparent] result
av>Ff6w)Y  
[ 此帖被反向一觉在2017-10-31 14:08重新编辑 ]
发表主题 回复主题
« 返回列表上一主题下一主题

限100 字节
如果您在写长篇帖子又不马上发表,建议存为草稿
 
验证问题: 52 - 43 = ?
上一个 下一个
      ×
      全新阿里云开发者社区, 去探索开发者的新世界吧!
      一站式的体验,更多的精彩!
      通过下面领域大门,一起探索新的技术世界吧~ (点击图标进入)