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

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

级别: 论坛粉丝
发帖
1227
云币
2325
kaVYe)~  
SDK使用手册 2hT H  
前置条件: A{Q~@1  
需要安装有python2.7版本 cQh=Mri]  
安装pip g'V,K\TG  
如果已有pip或者使用其他方案,可忽略此步骤。 DkBVk+  
如何安装pip fwaM;YN_  
命令行工具 CLI,如果已安装,请略过: Zh_ P  
M:w]g`LKl  
  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
XU$\.g p-  
命令行工具 CLI 安装说明 IO?6F@(  
 34~[dY  
安装cms-python-sdk的依赖: 6dYUMqQ  
n/IDq$/P  
  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
*1_A$14 l  
code示例: \K(# r=  
  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
t8-LPq  
[ 此帖被反向一觉在2017-10-31 14:08重新编辑 ]
发表主题 回复主题
« 返回列表上一主题下一主题

限100 字节
如果您提交过一次失败了,可以用”恢复数据”来恢复帖子内容
 
验证问题: 16 + 54 = ?
上一个 下一个
      ×
      全新阿里云开发者社区, 去探索开发者的新世界吧!
      一站式的体验,更多的精彩!
      通过下面领域大门,一起探索新的技术世界吧~ (点击图标进入)