def sapce_status(request): instance_name = request.POST.get('instance_name') # 通过实例名称获取关联的rds实例id instance_info = AliyunRdsConfig.objects.get( instance__instance_name=instance_name) # 调用aliyun接口获取进程数据 space_info = Aliyun().RequestServiceOfCloudDBA( instance_info.rds_dbinstanceid, 'GetSpaceStatForTables', { "Language": "zh", "OrderType": "Data" }) # 提取进程列表 space_list = json.loads(space_info)['ListData'] if space_list: space_list = json.loads(space_list) else: space_list = [] result = {'status': 0, 'msg': 'ok', 'rows': space_list} # 返回查询结果 return result
# -*- coding: UTF-8 -*- import simplejson as json import datetime from common.utils.aliyun_sdk import Aliyun from .models import AliyunRdsConfig aliyun = Aliyun() # 获取SQL慢日志统计 def slowquery_review(request): instance_name = request.POST.get('instance_name') DBName = request.POST.get('db_name') StartTime = request.POST.get('StartTime') EndTime = request.POST.get('EndTime') limit = request.POST.get('limit') offset = request.POST.get('offset') # 计算页数 PageNumber = (int(offset) + int(limit)) / int(limit) values = {"PageSize": int(limit), "PageNumber": int(PageNumber)} # DBName非必传 if DBName: values['DBName'] = DBName # UTC时间转化成阿里云需求的时间格式 StartTime = '%sZ' % StartTime EndTime = '%sZ' % EndTime