From fd3eeeca661ee7bbfa3bda7d684c853d088b0ae4 Mon Sep 17 00:00:00 2001 From: "StarsL.cn" Date: Thu, 3 Nov 2022 15:36:31 +0800 Subject: [PATCH] fix exp bug --- flask-consul/units/cloud/alicloud.py | 11 +++++------ vue-consul/src/views/node-exporter/exp.vue | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/flask-consul/units/cloud/alicloud.py b/flask-consul/units/cloud/alicloud.py index ca304c4..b54cf75 100644 --- a/flask-consul/units/cloud/alicloud.py +++ b/flask-consul/units/cloud/alicloud.py @@ -26,6 +26,10 @@ def exp(account,collect_days,notify_days,notify_amount): config = open_api_models.Config(access_key_id=ak,access_key_secret=sk) config.endpoint = f'business.aliyuncs.com' client = BssOpenApi20171214Client(config) + exp_config = consul_kv.get_value('ConsulManager/exp/config') + wecomwh = exp_config.get('wecomwh','') + dingdingwh = exp_config.get('dingdingwh','') + feishuwh = exp_config.get('feishuwh','') try: amount_response = client.query_account_balance() if amount_response.body.success: @@ -50,8 +54,7 @@ def exp(account,collect_days,notify_days,notify_amount): except Exception as e: print('==ERROR==',e,flush=True) raise - query_available_instances_request = bss_open_api_20171214_models.QueryAvailableInstancesRequest( - renew_status='ManualRenewal',end_time_start=now,end_time_end=collect) + 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() try: exp = client.query_available_instances_with_options(query_available_instances_request, runtime) @@ -75,10 +78,6 @@ def exp(account,collect_days,notify_days,notify_amount): if (endtime - datetime.datetime.now()).days < notify_days and notify_id not in isnotify_list: notify_dict[i['InstanceID']] = exp_dict[i['InstanceID']] consul_kv.put_kv(f'ConsulManager/exp/lists/alicloud/{account}/exp', exp_dict) - exp_config = consul_kv.get_value('ConsulManager/exp/config') - wecomwh = exp_config.get('wecomwh','') - dingdingwh = exp_config.get('dingdingwh','') - feishuwh = exp_config.get('feishuwh','') if notify_dict != {}: msg = [f'### 阿里云账号 {account}:\n### 以下资源到期日小于 {notify_days} 天:'] for k,v in notify_dict.items(): diff --git a/vue-consul/src/views/node-exporter/exp.vue b/vue-consul/src/views/node-exporter/exp.vue index dd7af03..0d4c665 100644 --- a/vue-consul/src/views/node-exporter/exp.vue +++ b/vue-consul/src/views/node-exporter/exp.vue @@ -20,7 +20,7 @@
  • 开启采集:每小时会自动采集一次余额与到期资源信息。
  • -
  • 开启通知:当余额或到期资源低于设定时,会立刻推送通知。
  • +
  • 开启通知:每次采集后检测到余额或到期资源低于设定时,会推送通知。
  • @@ -82,7 +82,7 @@ - +