add traceback
parent
a51247af87
commit
2e17c5e15a
|
@ -14,7 +14,7 @@ from alibabacloud_rds20140815 import models as rds_20140815_models
|
|||
from alibabacloud_r_kvstore20150101 import models as r_kvstore_20150101_models
|
||||
from alibabacloud_r_kvstore20150101.client import Client as R_kvstore20150101Client
|
||||
|
||||
import sys,datetime,hashlib,math
|
||||
import sys,datetime,hashlib,math,traceback
|
||||
from units import consul_kv,consul_svc
|
||||
from units.cloud import sync_ecs,sync_rds,sync_redis,notify
|
||||
from units.config_log import *
|
||||
|
@ -54,7 +54,7 @@ def exp(account,collect_days,notify_days,notify_amount):
|
|||
else:
|
||||
logger.error(f'查询失败,Code:{amount_response.body.code}, 信息:{amount_response.body.message}, requestId:{amount_response.body.request_id}')
|
||||
except Exception as e:
|
||||
logger.error(f'==ERROR=={e}')
|
||||
logger.error(f'==ERROR=={e}\n{traceback.format_exc()}')
|
||||
raise
|
||||
query_available_instances_request = bss_open_api_20171214_models.QueryAvailableInstancesRequest(renew_status='ManualRenewal',end_time_start=now,end_time_end=collect)
|
||||
runtime = util_models.RuntimeOptions()
|
||||
|
@ -63,7 +63,7 @@ def exp(account,collect_days,notify_days,notify_amount):
|
|||
exp_list = exp.body.to_map()['Data']['InstanceList']
|
||||
except Exception as e:
|
||||
#exp_list = []
|
||||
logger.error(f'==ERROR=={e}')
|
||||
logger.error(f'==ERROR=={e}\n{traceback.format_exc()}')
|
||||
raise
|
||||
exp_dict = {}
|
||||
isnotify_list = consul_kv.get_keys_list(f'ConsulManager/exp/isnotify/alicloud/{account}')
|
||||
|
@ -114,7 +114,7 @@ def group(account):
|
|||
logger.info(f'【JOB】===>alicloud_group {account} {data}')
|
||||
except TeaException as e:
|
||||
emsg = e.message.split('. ',1)[0]
|
||||
logger.error(f"【code:】{e.code}\n【message:】{emsg}")
|
||||
logger.error(f"【code:】{e.code}\n【message:】{emsg}\n{traceback.format_exc()}")
|
||||
data = consul_kv.get_value(f'ConsulManager/record/jobs/alicloud/{account}/group')
|
||||
if data == {}:
|
||||
data = {'count':'无','update':f'失败{e.code}','status':50000,'msg':emsg}
|
||||
|
@ -123,6 +123,7 @@ def group(account):
|
|||
data['msg'] = emsg
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/alicloud/{account}/group', data)
|
||||
except Exception as e:
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(e)}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/alicloud/{account}/group', data)
|
||||
|
||||
|
@ -168,7 +169,7 @@ def ecs(account,region,isextip=False):
|
|||
logger.info(f'【JOB】===>alicloud_ecs {account} {region} {data}')
|
||||
except TeaException as e:
|
||||
emsg = e.message.split('. ',1)[0]
|
||||
logger.error(f"【code:】{e.code}\n【message:】{emsg}")
|
||||
logger.error(f"【code:】{e.code}\n【message:】{emsg}\n{traceback.format_exc()}")
|
||||
data = consul_kv.get_value(f'ConsulManager/record/jobs/alicloud/{account}/ecs/{region}')
|
||||
if data == {}:
|
||||
data = {'count':'无','update':f'失败{e.code}','status':50000,'msg':emsg}
|
||||
|
@ -177,6 +178,7 @@ def ecs(account,region,isextip=False):
|
|||
data['msg'] = emsg
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/alicloud/{account}/ecs/{region}', data)
|
||||
except Exception as e:
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(e)}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/alicloud/{account}/ecs/{region}', data)
|
||||
|
||||
|
@ -229,7 +231,7 @@ def redis(account,region):
|
|||
logger.info(f'【JOB】===>alicloud_redis {account} {region} {data}')
|
||||
except TeaException as e:
|
||||
emsg = e.message.split('. ',1)[0]
|
||||
logger.error(f"【code:】{e.code}\n【message:】{e.message}")
|
||||
logger.error(f"【code:】{e.code}\n【message:】{e.message}\n{traceback.format_exc()}")
|
||||
data = consul_kv.get_value(f'ConsulManager/record/jobs/alicloud/{account}/redis/{region}')
|
||||
if data == {}:
|
||||
data = {'count':'无','update':f'失败{e.code}','status':50000,'msg':emsg}
|
||||
|
@ -238,7 +240,7 @@ def redis(account,region):
|
|||
data['msg'] = emsg
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/alicloud/{account}/redis/{region}', data)
|
||||
except Exception as e:
|
||||
logger.error(str(e))
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(e)}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/alicloud/{account}/redis/{region}', data)
|
||||
|
||||
|
@ -298,7 +300,7 @@ def rds(account,region):
|
|||
for k,v in rds_plus.items():
|
||||
rds_dict[k].update(v)
|
||||
except Exception as e:
|
||||
logger.error('DescribeDBInstancesAsCsvRequest ERROR' + str(e))
|
||||
logger.error('DescribeDBInstancesAsCsvRequest ERROR' + f'{e}\n{traceback.format_exc()}')
|
||||
|
||||
count = len(rds_dict)
|
||||
off,on = sync_rds.w2consul('alicloud',account,region,rds_dict)
|
||||
|
@ -307,7 +309,7 @@ def rds(account,region):
|
|||
logger.info(f'【JOB】===>alicloud_rds {account} {region} {data}')
|
||||
except TeaException as e:
|
||||
emsg = e.message.split('. ',1)[0]
|
||||
logger.error(f"【code:】{e.code}\n【message:】{e.message}")
|
||||
logger.error(f"【code:】{e.code}\n【message:】{e.message}\n{traceback.format_exc()}")
|
||||
data = consul_kv.get_value(f'ConsulManager/record/jobs/alicloud/{account}/rds/{region}')
|
||||
if data == {}:
|
||||
data = {'count':'无','update':f'失败{e.code}','status':50000,'msg':emsg}
|
||||
|
@ -316,6 +318,6 @@ def rds(account,region):
|
|||
data['msg'] = emsg
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/alicloud/{account}/rds/{region}', data)
|
||||
except Exception as e:
|
||||
logger.error(str(e))
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(e)}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/alicloud/{account}/rds/{region}', data)
|
||||
|
|
|
@ -10,7 +10,7 @@ from huaweicloudsdkdcs.v2 import *
|
|||
from huaweicloudsdkdcs.v2.region.dcs_region import DcsRegion
|
||||
from huaweicloudsdkrds.v3 import *
|
||||
from huaweicloudsdkrds.v3.region.rds_region import RdsRegion
|
||||
import sys,datetime,hashlib
|
||||
import sys,datetime,hashlib,traceback
|
||||
from units import consul_kv
|
||||
from units.cloud import sync_ecs
|
||||
from units.cloud import sync_rds
|
||||
|
@ -94,7 +94,7 @@ def exp(account,collect_days,notify_days,notify_amount):
|
|||
logger.error(e.status_code)
|
||||
logger.error(e.request_id)
|
||||
logger.error(e.error_code)
|
||||
logger.error(e.error_msg)
|
||||
logger.error(f'{e.error_msg}\n{traceback.format_exc()}')
|
||||
|
||||
def group(account):
|
||||
ak,sk = consul_kv.get_aksk('huaweicloud',account)
|
||||
|
@ -119,7 +119,7 @@ def group(account):
|
|||
logger.error(e.status_code)
|
||||
logger.error(e.request_id)
|
||||
logger.error(e.error_code)
|
||||
logger.error(e.error_msg)
|
||||
logger.error(f'{e.error_msg}\n{traceback.format_exc()}')
|
||||
data = consul_kv.get_value(f'ConsulManager/record/jobs/huaweicloud/{account}/group')
|
||||
if data == {}:
|
||||
data = {'count':'无','update':f'失败{e.status_code}','status':50000,'msg':e.error_msg}
|
||||
|
@ -128,6 +128,7 @@ def group(account):
|
|||
data['msg'] = e.error_msg
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/huaweicloud/{account}/group', data)
|
||||
except Exception as e:
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(e)}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/huaweicloud/{account}/group', data)
|
||||
|
||||
|
@ -163,7 +164,7 @@ def ecs(account,region,isextip=False):
|
|||
logger.error(e.status_code)
|
||||
logger.error(e.request_id)
|
||||
logger.error(e.error_code)
|
||||
logger.error(e.error_msg)
|
||||
logger.error(f'{e.error_msg}\n{traceback.format_exc()}')
|
||||
data = consul_kv.get_value(f'ConsulManager/record/jobs/huaweicloud/{account}/ecs/{region}')
|
||||
if data == {}:
|
||||
data = {'count':'无','update':f'失败{e.status_code}','status':50000,'on':0,'off':0,'msg':e.error_msg}
|
||||
|
@ -172,6 +173,7 @@ def ecs(account,region,isextip=False):
|
|||
data['msg'] = e.error_msg
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/huaweicloud/{account}/ecs/{region}', data)
|
||||
except Exception as e:
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(e)}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/huaweicloud/{account}/ecs/{region}', data)
|
||||
|
||||
|
@ -214,7 +216,7 @@ def rds(account,region):
|
|||
logger.error(e.status_code)
|
||||
logger.error(e.request_id)
|
||||
logger.error(e.error_code)
|
||||
logger.error(e.error_msg)
|
||||
logger.error(f'{e.error_msg}\n{traceback.format_exc()}')
|
||||
data = consul_kv.get_value(f'ConsulManager/record/jobs/huaweicloud/{account}/rds/{region}')
|
||||
if data == {}:
|
||||
data = {'count':'无','update':f'失败{e.status_code}','status':50000,'on':0,'off':0,'msg':e.error_msg}
|
||||
|
@ -223,6 +225,7 @@ def rds(account,region):
|
|||
data['msg'] = e.error_msg
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/huaweicloud/{account}/rds/{region}', data)
|
||||
except Exception as e:
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(e)}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/huaweicloud/{account}/rds/{region}', data)
|
||||
|
||||
|
@ -263,7 +266,7 @@ def redis(account,region):
|
|||
logger.error(e.status_code)
|
||||
logger.error(e.request_id)
|
||||
logger.error(e.error_code)
|
||||
logger.error(e.error_msg)
|
||||
logger.error(f'{e.error_msg}\n{traceback.format_exc()}')
|
||||
data = consul_kv.get_value(f'ConsulManager/record/jobs/huaweicloud/{account}/redis/{region}')
|
||||
if data == {}:
|
||||
data = {'count':'无','update':f'失败{e.status_code}','status':50000,'on':0,'off':0,'msg':e.error_msg}
|
||||
|
@ -272,6 +275,7 @@ def redis(account,region):
|
|||
data['msg'] = e.error_msg
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/huaweicloud/{account}/redis/{region}', data)
|
||||
except Exception as e:
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(e)}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/huaweicloud/{account}/redis/{region}', data)
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import json
|
||||
from tencentcloud.common import credential
|
||||
from tencentcloud.common.profile.client_profile import ClientProfile
|
||||
from tencentcloud.common.profile.http_profile import HttpProfile
|
||||
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
|
||||
|
||||
import sys,datetime,hashlib
|
||||
import sys,datetime,hashlib,json,traceback
|
||||
#sys.path.append("..")
|
||||
#import consul_kv,sync_ecs
|
||||
from units import consul_kv
|
||||
|
@ -76,8 +75,8 @@ def exp(account,collect_days,notify_days,notify_amount):
|
|||
title = '腾讯云余额不足通知'
|
||||
md = content
|
||||
notify.feishu(feishuwh,title,md,isatall)
|
||||
except TencentCloudSDKException as err:
|
||||
logger.error(f'{err}')
|
||||
except TencentCloudSDKException as e:
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
|
||||
def group(account):
|
||||
from tencentcloud.dcdb.v20180411 import dcdb_client, models
|
||||
|
@ -102,7 +101,7 @@ def group(account):
|
|||
consul_kv.put_kv(f'ConsulManager/record/jobs/tencent_cloud/{account}/group', data)
|
||||
logger.info(f'【JOB】===>tencent_cloud_group {account} {data}')
|
||||
except TencentCloudSDKException as err:
|
||||
logger.error(f'{err}')
|
||||
logger.error(f'{err}\n{traceback.format_exc()}')
|
||||
data = consul_kv.get_value(f'ConsulManager/record/jobs/tencent_cloud/{account}/group')
|
||||
if data == {}:
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(err)}
|
||||
|
@ -111,6 +110,7 @@ def group(account):
|
|||
data['msg'] = str(err)
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/tencent_cloud/{account}/group', data)
|
||||
except Exception as e:
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(e)}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/tencent_cloud/{account}/group', data)
|
||||
|
||||
|
@ -152,7 +152,7 @@ def ecs(account,region,isextip=False):
|
|||
consul_kv.put_kv(f'ConsulManager/record/jobs/tencent_cloud/{account}/ecs/{region}', data)
|
||||
logger.info(f'【JOB】===>tencent_cloud_ecs {account} {region} {data}')
|
||||
except TencentCloudSDKException as err:
|
||||
logger.error(f'{err}')
|
||||
logger.error(f'{err}\n{traceback.format_exc()}')
|
||||
data = consul_kv.get_value(f'ConsulManager/record/jobs/tencent_cloud/{account}/ecs/{region}')
|
||||
if data == {}:
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(err)}
|
||||
|
@ -161,6 +161,7 @@ def ecs(account,region,isextip=False):
|
|||
data['msg'] = str(err)
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/tencent_cloud/{account}/ecs/{region}', data)
|
||||
except Exception as e:
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(e)}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/tencent_cloud/{account}/ecs/{region}', data)
|
||||
|
||||
|
@ -203,7 +204,7 @@ def rds(account,region):
|
|||
consul_kv.put_kv(f'ConsulManager/record/jobs/tencent_cloud/{account}/rds/{region}', data)
|
||||
logger.info(f'【JOB】===>tencent_cloud_rds {account} {region} {data}')
|
||||
except TencentCloudSDKException as err:
|
||||
logger.error(f'{err}')
|
||||
logger.error(f'{err}\n{traceback.format_exc()}')
|
||||
data = consul_kv.get_value(f'ConsulManager/record/jobs/tencent_cloud/{account}/rds/{region}')
|
||||
if data == {}:
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(err)}
|
||||
|
@ -212,6 +213,7 @@ def rds(account,region):
|
|||
data['msg'] = str(err)
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/tencent_cloud/{account}/rds/{region}', data)
|
||||
except Exception as e:
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(e)}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/tencent_cloud/{account}/rds/{region}', data)
|
||||
|
||||
|
@ -252,7 +254,7 @@ def redis(account,region):
|
|||
consul_kv.put_kv(f'ConsulManager/record/jobs/tencent_cloud/{account}/redis/{region}', data)
|
||||
logger.info(f'【JOB】===>tencent_cloud_redis {account} {region} {data}')
|
||||
except TencentCloudSDKException as err:
|
||||
logger.error(f'{err}')
|
||||
logger.error(f'{err}\n{traceback.format_exc()}')
|
||||
data = consul_kv.get_value(f'ConsulManager/record/jobs/tencent_cloud/{account}/redis/{region}')
|
||||
if data == {}:
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(err)}
|
||||
|
@ -261,5 +263,6 @@ def redis(account,region):
|
|||
data['msg'] = str(err)
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/tencent_cloud/{account}/redis/{region}', data)
|
||||
except Exception as e:
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
data = {'count':'无','update':f'失败','status':50000,'msg':str(e)}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jobs/tencent_cloud/{account}/redis/{region}', data)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import requests,json,re
|
||||
import requests,json,re,traceback
|
||||
from config import consul_token,consul_url
|
||||
from units.config_log import *
|
||||
|
||||
|
@ -94,7 +94,8 @@ def add_instance(instance_dict):
|
|||
try:
|
||||
metaJson = json.loads(instance_dict['metaInfo']['metaJson'])
|
||||
instance_dict['meta'] = metaJson
|
||||
except:
|
||||
except Exception as e:
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
return {"code": 50000, "data": "Meta必须JSON字符串格式!"}
|
||||
if isCheck:
|
||||
ctype = instance_dict['checkInfo']['ctype']
|
||||
|
|
|
@ -5,10 +5,11 @@ from units.config_log import *
|
|||
#创建node
|
||||
def create_node(jms_url,headers,now,node_id,cloud,account):
|
||||
node_url = f"{jms_url}/api/v1/assets/nodes/{node_id}/children/"
|
||||
logger.debug(f'{node_url}==>{headers}')
|
||||
jms_node_list = requests.request("GET", node_url, headers=headers).json()
|
||||
if type(jms_node_list) == dict:
|
||||
detail = jms_node_list.get('detail','ERROR')
|
||||
logger.info(f' 【JMS】{detail}')
|
||||
detail = jms_node_list.get('detail','未知ERROR')
|
||||
logger.error(f' 【JMS】{detail}\n{node_url}==>{headers}')
|
||||
data = {'count': '失败','update':now,'status':50000,'msg':f'同步资源失败!{detail}'}
|
||||
consul_kv.put_kv(f'ConsulManager/record/jms/{cloud}/{account}', data)
|
||||
cloud_group_dict = consul_kv.get_value(f'ConsulManager/assets/{cloud}/group/{account}')
|
||||
|
@ -16,7 +17,7 @@ def create_node(jms_url,headers,now,node_id,cloud,account):
|
|||
for k,v in cloud_group_dict.items():
|
||||
if v not in [i['value'] for i in jms_node_list]:
|
||||
response = requests.request("POST", node_url, headers=headers, data = json.dumps({'value': v}))
|
||||
logger.info(f' 【JMS】新增组===>{v}{response.status_code}')
|
||||
logger.debug(f' 【JMS】新增组===>{v},{response.status_code}')
|
||||
reget_node_list = requests.request("GET", node_url, headers=headers).json()
|
||||
new_node_dict = {i['value']:i['id'] for i in reget_node_list}
|
||||
return new_node_dict
|
||||
|
@ -32,7 +33,7 @@ def update_jms_ecs(jms_url,headers,new_node_dict,node_id,cloud,account,ecs_info,
|
|||
del_ecs_list = [v['id'] for k,v in jms_ecs_dict.items() if k not in [i['ip'] for i in ecs_dict.values()]]
|
||||
for del_ecs in del_ecs_list:
|
||||
response = requests.request("DELETE", f'{ecs_url}{del_ecs}/', headers=headers)
|
||||
logger.info(f' 【JMS】删除主机:{del_ecs}{response.status_code}')
|
||||
logger.info(f' 【JMS】删除主机:{del_ecs},{response.status_code}')
|
||||
|
||||
#增加/更新缺少的主机
|
||||
for k,v in ecs_dict.items():
|
||||
|
@ -67,12 +68,12 @@ def update_jms_ecs(jms_url,headers,new_node_dict,node_id,cloud,account,ecs_info,
|
|||
jms_group = '无' if jms_ecs_dict[ip]['node'].split('/')[-1] == '未分组' else jms_ecs_dict[ip]['node'].split('/')[-1]
|
||||
if jms_ecs_dict[ip]['name'] != iname or jms_group != v['ent']:
|
||||
response = requests.request("PUT", f"{ecs_url}{jms_ecs_dict[ip]['id']}/", headers=headers, data = json.dumps(payload))
|
||||
logger.info(f" 【JMS】update:主机名:{response.json()['hostname']}{response.status_code}")
|
||||
logger.info(f" 【JMS】update:主机名:{response.json()['hostname']},{response.status_code}")
|
||||
else:
|
||||
response = requests.request("POST", ecs_url, headers=headers, data = json.dumps(payload))
|
||||
logger.info(f" 【JMS】add:主机名:{iname} {ip}【{response.json()['hostname']},{response.status_code}】")
|
||||
except Exception as e:
|
||||
logger.error(f'【update_jms ERROR】{e}')
|
||||
logger.error(f'【update_jms ERROR】{e}\n{traceback.format_exc()}')
|
||||
logger.error(f'{response.json()}')
|
||||
return ecs_ip_dict
|
||||
|
||||
|
@ -106,7 +107,7 @@ def del_node(jms_url,headers,now,node_id,cloud,account):
|
|||
else:
|
||||
del_node_url = f"{jms_url}/api/v1/assets/nodes/{i['meta']['data']['id']}/"
|
||||
response = requests.request("DELETE", del_node_url, headers=headers)
|
||||
logger.info(" 【JMS】删除空组===>{i['name']},{response.status_code}")
|
||||
logger.debug(f" 【JMS】删除空组===>{i['name']},{response.status_code}")
|
||||
ecs_count_url = f"{jms_url}/api/v1/assets/assets/?node={node_id}&limit=1&offset=1"
|
||||
ecs_count = requests.request("GET", ecs_count_url, headers=headers).json()['count']
|
||||
data = {'count':ecs_count,'update':now,'status':20000,'msg':f'同步资源成功!总数:{ecs_count}'}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import json
|
||||
import json,traceback
|
||||
from tencentcloud.common import credential
|
||||
from tencentcloud.common.profile.client_profile import ClientProfile
|
||||
from tencentcloud.common.profile.http_profile import HttpProfile
|
||||
|
@ -39,7 +39,7 @@ def exporter(vendor,account,region):
|
|||
prom_metric_name = metric_name_dict[i][0].split()[2]
|
||||
metric_name_dict[i].append(f'{prom_metric_name}{{iid="{iid}"}} {float(value)} {ts}')
|
||||
except Exception as e:
|
||||
logger.error(f"【redis_tencent:prom-metrics-ERROR】{e}")
|
||||
logger.error(f"【redis_tencent:prom-metrics-ERROR】{e}\n{traceback.format_exc()}")
|
||||
prom_metric_list = []
|
||||
for x in metric_name_dict.values():
|
||||
prom_metric_list = prom_metric_list + x
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/python3
|
||||
import requests, json
|
||||
import requests, json, traceback
|
||||
import xlrd,re,sys
|
||||
sys.path.append("..")
|
||||
from config import consul_token,consul_url
|
||||
|
@ -65,7 +65,7 @@ def importconsul(row,imptype):
|
|||
"check": {"tcp": instance,"interval": "60s"}
|
||||
}
|
||||
except Exception as e:
|
||||
logger.error(f"【import】导入失败,{e}")
|
||||
logger.error(f"【import】导入失败,{e}\n{traceback.format_exc()}")
|
||||
return {"code": 50000, "data": f"导入内容格式异常!{row}"}
|
||||
headers = {'X-Consul-Token': consul_token}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from flask import Blueprint
|
||||
from flask_restful import reqparse, Resource, Api
|
||||
import sys
|
||||
import sys,traceback
|
||||
sys.path.append("..")
|
||||
from units import token_auth,blackbox_manager
|
||||
from werkzeug.datastructures import FileStorage
|
||||
|
@ -27,7 +27,7 @@ class Upload(Resource):
|
|||
try:
|
||||
return upload.read_execl(file.read(),'blackbox')
|
||||
except Exception as e:
|
||||
logger.error(f"【blackbox】导入失败,{e}")
|
||||
logger.error(f"【blackbox】导入失败,{e}\n{traceback.format_exc()}")
|
||||
return {"code": 50000, "data": f"导入失败!"}
|
||||
|
||||
class GetAllList(Resource):
|
||||
|
|
|
@ -3,7 +3,7 @@ from flask_restful import reqparse, Resource, Api
|
|||
from flask_apscheduler import APScheduler
|
||||
from units import token_auth,consul_kv,myaes
|
||||
from config import vendors
|
||||
import json
|
||||
import json,traceback
|
||||
from .jobs import deljob,addjob,runjob,getjob
|
||||
from units.config_log import *
|
||||
blueprint = Blueprint('jms',__name__)
|
||||
|
@ -106,7 +106,7 @@ class Jms(Resource):
|
|||
custom_ecs_dict = json.loads(custom_ecs_info)
|
||||
consul_kv.put_kv('ConsulManager/jms/custom_ecs_info',custom_ecs_dict)
|
||||
except Exception as e:
|
||||
logger.error(f'{e}')
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
return {'code': 50000, 'data': 'Json解析错误,请检查!'}
|
||||
else:
|
||||
consul_kv.put_kv('ConsulManager/jms/custom_ecs_info',{})
|
||||
|
@ -140,7 +140,13 @@ class Jms(Resource):
|
|||
jms_job_args = [vendor,account]
|
||||
|
||||
addjob(jms_job_id,jms_job_func,jms_job_args,interval)
|
||||
runjob(jms_job_id)
|
||||
try:
|
||||
runjob(jms_job_id)
|
||||
except Exception as e:
|
||||
deljob(jms_job_id)
|
||||
logger.error(f'{e}\n{traceback.format_exc()}\n【{vendor}/{account}】同步功能开启失败!')
|
||||
return {'code': 50000, 'data': f'【{vendor}/{account}】同步功能开启失败,请查看后端日志!'}
|
||||
|
||||
jms_job_dict = {'id':jms_job_id,'func':jms_job_func,'args':jms_job_args,'minutes':interval,
|
||||
'trigger': 'interval','replace_existing': True}
|
||||
consul_kv.put_kv(f'ConsulManager/jms/jobs/{vendor}/{account}',jms_job_dict)
|
||||
|
|
|
@ -3,6 +3,7 @@ from flask_restful import reqparse, Resource, Api
|
|||
from flask_apscheduler import APScheduler
|
||||
#import sys
|
||||
#sys.path.append("..")
|
||||
import traceback
|
||||
from units import token_auth,consul_kv,gen_config,consul_svc
|
||||
from units.config_log import *
|
||||
blueprint = Blueprint('nodes',__name__)
|
||||
|
@ -97,7 +98,7 @@ class Nodes(Resource):
|
|||
consul_svc.add_sid(sid_dict)
|
||||
return {'code': 20000, 'data': '自定义实例信息修改成功!'}
|
||||
except Exception as e:
|
||||
logger.error(f'{e}')
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
return {'code': 50000, "data": '提交自定义实例信息格式错误!'}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from flask import Blueprint
|
||||
from flask_restful import reqparse, Resource, Api
|
||||
from flask_apscheduler import APScheduler
|
||||
import traceback
|
||||
#import sys
|
||||
#sys.path.append("..")
|
||||
from units import token_auth,consul_kv,gen_config,consul_svc
|
||||
|
@ -86,7 +87,7 @@ class Rds(Resource):
|
|||
consul_svc.add_sid(sid_dict)
|
||||
return {'code': 20000, 'data': '自定义实例信息修改成功!'}
|
||||
except Exception as e:
|
||||
logger.error(f'{e}')
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
return {'code': 50000, "data": '提交自定义实例信息格式错误!'}
|
||||
|
||||
api.add_resource(Rds, '/api/rds/<stype>')
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from flask import Blueprint
|
||||
from flask_restful import reqparse, Resource, Api
|
||||
from flask_apscheduler import APScheduler
|
||||
import traceback
|
||||
#import sys
|
||||
#sys.path.append("..")
|
||||
from units import token_auth,consul_kv,gen_config,consul_svc
|
||||
|
@ -86,7 +87,7 @@ class Redis(Resource):
|
|||
consul_svc.add_sid(sid_dict)
|
||||
return {'code': 20000, 'data': '自定义实例信息修改成功!'}
|
||||
except Exception as e:
|
||||
logger.error(f'{e}')
|
||||
logger.error(f'{e}\n{traceback.format_exc()}')
|
||||
return {'code': 50000, "data": '提交自定义实例信息格式错误!'}
|
||||
|
||||
api.add_resource(Redis, '/api/redis/<stype>')
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from flask import Blueprint
|
||||
from flask_restful import reqparse, Resource, Api
|
||||
import sys
|
||||
import sys,traceback
|
||||
sys.path.append("..")
|
||||
from units import token_auth,selfnode_manager
|
||||
from werkzeug.datastructures import FileStorage
|
||||
|
@ -29,7 +29,7 @@ class Upload(Resource):
|
|||
try:
|
||||
return upload.read_execl(file.read(),'selfnode')
|
||||
except Exception as e:
|
||||
logger.error(f"【selfnode】导入失败,{e}")
|
||||
logger.error(f"【selfnode】导入失败,{e}\n{traceback.format_exc()}")
|
||||
return {"code": 50000, "data": f"导入失败!"}
|
||||
|
||||
class GetAllList(Resource):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from flask import Blueprint
|
||||
from flask_restful import reqparse, Resource, Api
|
||||
import sys
|
||||
import sys,traceback
|
||||
sys.path.append("..")
|
||||
from units import token_auth,selfrds_manager
|
||||
from werkzeug.datastructures import FileStorage
|
||||
|
@ -29,7 +29,7 @@ class Upload(Resource):
|
|||
try:
|
||||
return upload.read_execl(file.read(),'selfrds')
|
||||
except Exception as e:
|
||||
logger.error(f"【selfrds】导入失败,{e}")
|
||||
logger.error(f"【selfrds】导入失败,{e}\n{traceback.format_exc()}")
|
||||
return {"code": 50000, "data": f"导入失败!"}
|
||||
|
||||
class GetAllList(Resource):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from flask import Blueprint
|
||||
from flask_restful import reqparse, Resource, Api
|
||||
import sys
|
||||
import sys,traceback
|
||||
sys.path.append("..")
|
||||
from units import token_auth,selfredis_manager
|
||||
from werkzeug.datastructures import FileStorage
|
||||
|
@ -29,7 +29,7 @@ class Upload(Resource):
|
|||
try:
|
||||
return upload.read_execl(file.read(),'selfredis')
|
||||
except Exception as e:
|
||||
logger.error(f"【selfredis】导入失败,{e}")
|
||||
logger.error(f"【selfredis】导入失败,{e}\n{traceback.format_exc()}")
|
||||
return {"code": 50000, "data": f"导入失败!"}
|
||||
|
||||
class GetAllList(Resource):
|
||||
|
|
|
@ -46,7 +46,7 @@ Object.keys(filters).forEach(key => {
|
|||
})
|
||||
|
||||
Vue.config.productionTip = false
|
||||
Vue.prototype.VER = 'v0.12.1'
|
||||
Vue.prototype.VER = 'v0.12.2'
|
||||
|
||||
new Vue({
|
||||
el: '#app',
|
||||
|
|
Loading…
Reference in New Issue