fix(monitor): remove useless code (#19896)

This commit is contained in:
屈轩
2024-04-08 11:54:05 +08:00
committed by GitHub
parent fb213114f7
commit 4b9b468f0e
6 changed files with 34 additions and 296 deletions
+14
View File
@@ -161,3 +161,17 @@ type MetricFieldDetail struct {
Unit string `json:"unit"`
Id string `json:"id"`
}
type InfluxMeasurement struct {
apis.Meta
Database string
Measurement string
MeasurementDisplayName string
ResType string
Score int
TagKey []string
TagValue map[string][]string
FieldKey []string
FieldDescriptions map[string]MetricFieldDetail
Unit []string
}
-85
View File
@@ -1,85 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitor
const (
SUGGEST_ALERT_READY = "ready"
SUGGEST_ALERT_START_DELETE = "start_delete"
SUGGEST_ALERT_DELETE_FAIL = "delete_fail"
SUGGEST_ALERT_DELETING = "deleting"
)
type SuggestDriverType string
type SuggestDriverAction string
const (
EIP_UNUSED SuggestDriverType = "EIP_UNUSED"
DISK_UNUSED SuggestDriverType = "DISK_UNUSED"
LB_UNUSED SuggestDriverType = "LB_UNUSED"
SNAPSHOT_UNUSED SuggestDriverType = "SNAPSHOT_UNUSED"
INSTANCE_SNAPSHOT_UNUSED SuggestDriverType = "INSTANCE_SNAPSHOT_UNUSED"
SCALE_DOWN SuggestDriverType = "SCALE_DOWN"
SCALE_UP SuggestDriverType = "SCALE_UP"
SECGROUPRULEINSERVER_ALLIN SuggestDriverType = "SECGROUPRULEINSERVER_ALLIN"
REDIS_UNREASONABLE SuggestDriverType = "REDIS_UNREASONABLE"
RDS_UNREASONABLE SuggestDriverType = "RDS_UNREASONABLE"
OSS_UNREASONABLE SuggestDriverType = "OSS_UNREASONABLE"
OSS_SEC_ACL SuggestDriverType = "OSS_SEC_ACL"
DELETE_DRIVER_ACTION SuggestDriverAction = "DELETE"
SCALE_DOWN_DRIVER_ACTION SuggestDriverAction = "SCALE_DOWN"
SECGROUPRULEINSERVER_DRIVER_ACTION SuggestDriverAction = "MODIFY_RULE"
REDIS_UNREASONABLE_DRIVER_ACTION SuggestDriverAction = "REASONABLE"
OSS_SEC_ACL_DRIVER_ACTION SuggestDriverAction = "MODIFY_ACL"
)
type MonitorSuggest string
type MonitorResourceType string
const (
EIP_MONITOR_RES_TYPE = MonitorResourceType("eip")
DISK_MONITOR_RES_TYPE = MonitorResourceType("disk")
LB_MONITOR_RES_TYPE = MonitorResourceType("loadbalancer")
SCALE_MONTITOR_RES_TYPE = MonitorResourceType("server")
SNAPSHOT_MONITOR_RES_TYPE = MonitorResourceType("snapshot")
INSTANCE_SNAPSHOT_MONITOR_RES_TYPE = MonitorResourceType("instance_snapshot")
SECGROUPRULEINSERVER_MONITOR_RES_TYPE = MonitorResourceType("server")
REDIS_UNREASONABLE_MONITOR_RES_TYPE = MonitorResourceType("redis")
RDS_UNREASONABLE_MONITOR_RES_TYPE = MonitorResourceType("rds")
OSS_UNREASONABLE_MONITOR_RES_TYPE = MonitorResourceType("oss")
OSS_SEC_ACL_MONITOR_RES_TYPE = MonitorResourceType("oss")
)
const (
EIP_MONITOR_SUGGEST = MonitorSuggest("release unused EIP")
DISK_MONITOR_SUGGEST = MonitorSuggest("release unused Disk")
LB_MONITOR_SUGGEST = MonitorSuggest("release unused LB")
SCALE_DOWN_MONITOR_SUGGEST = MonitorSuggest("adjust machine configuration")
SECGROUPRULEINSERVER_MONITOR_SUGGEST = MonitorSuggest("adjust secgroup rule")
OSS_SEC_ACL_MONITOR_SUGGEST = MonitorSuggest("adjust oss acl")
)
const (
LB_UNUSED_NLISTENER = "no listener"
LB_UNUSED_NBCGROUP = "no backend servergroup"
LB_UNUSED_NBC = "no backend server"
)
const (
SECGROUPRULEINSERVER_CIDR = "0.0.0.0/0"
SECGROUPRULEINSERVER_FILTER_PROTOCOL = "icmp"
)
-15
View File
@@ -1,15 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitor
-75
View File
@@ -1,75 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitor
import (
"yunion.io/x/onecloud/pkg/apis"
)
const (
METRIC_TAG = "TAG"
METRIC_FIELD = "FIELD"
METRIC_VM_ID = "vm_id"
METRIC_OSS_ID = "oss_id"
METRIC_RDS_ID = "rds_id"
METRIC_REDIS_ID = "redis_id"
)
var PROPERTY_TYPE = []string{"databases", "measurements", "metric-measurement"}
var METRIC_ATTRI = []string{METRIC_TAG, METRIC_FIELD}
type InfluxMeasurement struct {
apis.Meta
Database string
Measurement string
MeasurementDisplayName string
ResType string
Score int
TagKey []string
TagValue map[string][]string
FieldKey []string
FieldDescriptions map[string]MetricFieldDetail
Unit []string
}
type EIPUnused struct {
}
type DiskUnused struct {
}
type LBUnused struct {
}
type ScaleRule []Scale
type Scale struct {
Database string `json:"database"`
Measurement string `json:"measurement"`
//rule operator rule [and|or]
Operator string `json:"operator"`
Field string `json:"field"`
EvalType string `json:"eval_type"`
Threshold float64 `json:"threshold"`
Tag string `json:"tag"`
TagVal string `json:"tag_val"`
}
type ScaleEvalMatch struct {
EvalMatch
ResourceId map[string]string `json:"resource_id"`
}
-69
View File
@@ -1,69 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitor
import (
"yunion.io/x/onecloud/pkg/apis"
)
type SuggestSysRuleConfigSupportTypes struct {
Types []SuggestDriverType `json:"types"`
ResourceTypes []string `json:"resource_types"`
}
type SuggestSysRuleConfigCreateInput struct {
apis.StandaloneResourceCreateInput
apis.ScopedResourceCreateInput
// Type is suggestsysrule driver type
Type *SuggestDriverType `json:"type"`
// RuleId is SSuggestSysRule model object id
// RuleId *string `json:"rule_id"`
// ResourceType is suggestsysrule driver resource type
ResourceType *MonitorResourceType `json:"resource_type"`
// ResourceId is suggest alert result resource id
ResourceId *string `json:"resource_id"`
// IgnoreAlert means whether or not show SSuggestSysAlert results for current scope
IgnoreAlert bool `json:"ignore_alert"`
}
type SuggestSysRuleConfigUpdateInput struct {
apis.Meta
// IgnoreAlert means whether or not show SSuggestSysAlert results for current scope
IgnoreAlert *bool `json:"ignore_alert"`
}
type SuggestSysRuleConfigDetails struct {
apis.StandaloneResourceDetails
apis.ScopedResourceBaseInfo
RuleId string `json:"rule_id"`
Rule string `json:"rule"`
RuleEnabled bool `json:"rule_enabled"`
ResName string `json:"res_name"`
}
type SuggestSysRuleConfigListInput struct {
apis.StandaloneResourceListInput
apis.ScopedResourceBaseListInput
Type *SuggestDriverType `json:"type"`
ResourceType *MonitorResourceType `json:"resource_type"`
IgnoreAlert *bool `json:"ignore_alert"`
}
type SuggestSysRuleConfigTypeInfo struct {
Name string `json:"name"`
}
+20 -52
View File
@@ -18,11 +18,10 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/apihelper"
"yunion.io/x/onecloud/pkg/apis"
compute_api "yunion.io/x/onecloud/pkg/apis/compute"
keystone_api "yunion.io/x/onecloud/pkg/apis/identity"
"yunion.io/x/onecloud/pkg/apis/monitor"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
compute_models "yunion.io/x/onecloud/pkg/compute/models"
keystone_models "yunion.io/x/onecloud/pkg/keystone/models"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/modules/identity"
@@ -59,89 +58,58 @@ type (
Projects map[string]*SProject
)
// +onecloud:swagger-gen-ignore
type Details struct {
//com_apis.CloudproviderDetails
//Host string
HostId string
Zone string
zoneId string
zoneExtId string
Cloudregion string
CloudregionId string
Tenant string
TenantId string
Brand string
DomainId string
ProjectDomain string
Ips string
Account string
apis.MetadataResourceInfo
}
// +onecloud:swagger-gen-ignore
type Guest struct {
compute_models.SGuest
Details
// VIP
Vip string `json:"vip"`
// VIP's eip
VipEip string `json:"vip_eip"`
// 浮动IP
Eip string `json:"eip"`
// 浮动IP类型
EipMode string `json:"eip_mode"`
db.SModelBase
compute_api.ServerDetails
}
// +onecloud:swagger-gen-ignore
type Host struct {
Id string
compute_models.SHost
Details
db.SModelBase
compute_api.HostDetails
}
// +onecloud:swagger-gen-ignore
type SRds struct {
compute_models.SDBInstance
Details
db.SModelBase
compute_api.DBInstanceDetails
}
// +onecloud:swagger-gen-ignore
type SRedis struct {
compute_models.SElasticcache
Details
db.SModelBase
compute_api.ElasticcacheDetails
}
// +onecloud:swagger-gen-ignore
type SOss struct {
compute_models.SBucket
Details
db.SModelBase
compute_api.BucketDetails
}
// +onecloud:swagger-gen-ignore
type SStorage struct {
Id string
compute_models.SStorage
Details
db.SModelBase
compute_api.StorageDetails
}
// +onecloud:swagger-gen-ignore
type SAccount struct {
Id string
compute_models.SCloudaccount
Details
db.SModelBase
compute_api.CloudaccountDetail
}
// +onecloud:swagger-gen-ignore
type SDomain struct {
Id string
keystone_models.SDomain
db.SModelBase
keystone_api.DomainDetails
}
// +onecloud:swagger-gen-ignore
type SProject struct {
Id string
keystone_models.SProject
db.SModelBase
keystone_api.ProjectDetails
}
func (s Servers) ModelManager() modulebase.IBaseManager {