mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #15262 from ioito/hotfix/qx-account-balance
fix(region): account balance
This commit is contained in:
@@ -15,9 +15,13 @@
|
||||
package providerdriver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/util/influxdb"
|
||||
)
|
||||
|
||||
type AliyunCollect struct {
|
||||
@@ -32,6 +36,32 @@ func (self *AliyunCollect) IsSupportMetrics() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *AliyunCollect) CollectAccountMetrics(ctx context.Context, account api.CloudaccountDetail) (influxdb.SMetricData, error) {
|
||||
metric := influxdb.SMetricData{
|
||||
Name: string(cloudprovider.METRIC_RESOURCE_TYPE_CLOUD_ACCOUNT),
|
||||
Timestamp: time.Now(),
|
||||
Tags: []influxdb.SKeyValue{},
|
||||
Metrics: []influxdb.SKeyValue{},
|
||||
}
|
||||
for k, v := range account.GetMetricTags() {
|
||||
metric.Tags = append([]influxdb.SKeyValue{
|
||||
{
|
||||
Key: k,
|
||||
Value: v,
|
||||
},
|
||||
}, metric.Tags...)
|
||||
}
|
||||
for k, v := range account.GetMetricPairs() {
|
||||
metric.Metrics = append([]influxdb.SKeyValue{
|
||||
{
|
||||
Key: k,
|
||||
Value: v,
|
||||
},
|
||||
}, metric.Metrics...)
|
||||
}
|
||||
return metric, nil
|
||||
}
|
||||
|
||||
func (self *AliyunCollect) GetDelayDuration() time.Duration {
|
||||
return time.Minute * 3
|
||||
}
|
||||
|
||||
@@ -43,29 +43,7 @@ func (self *SBaseCollectDriver) IsSupportMetrics() bool {
|
||||
}
|
||||
|
||||
func (self *SBaseCollectDriver) CollectAccountMetrics(ctx context.Context, account api.CloudaccountDetail) (influxdb.SMetricData, error) {
|
||||
metric := influxdb.SMetricData{
|
||||
Name: string(cloudprovider.METRIC_RESOURCE_TYPE_CLOUD_ACCOUNT),
|
||||
Timestamp: time.Now(),
|
||||
Tags: []influxdb.SKeyValue{},
|
||||
Metrics: []influxdb.SKeyValue{},
|
||||
}
|
||||
for k, v := range account.GetMetricTags() {
|
||||
metric.Tags = append([]influxdb.SKeyValue{
|
||||
{
|
||||
Key: k,
|
||||
Value: v,
|
||||
},
|
||||
}, metric.Tags...)
|
||||
}
|
||||
for k, v := range account.GetMetricPairs() {
|
||||
metric.Metrics = append([]influxdb.SKeyValue{
|
||||
{
|
||||
Key: k,
|
||||
Value: v,
|
||||
},
|
||||
}, metric.Metrics...)
|
||||
}
|
||||
return metric, nil
|
||||
return influxdb.SMetricData{}, errors.Wrapf(cloudprovider.ErrNotImplemented, "CollectAccountMetrics")
|
||||
}
|
||||
|
||||
func (self *SBaseCollectDriver) CollectDBInstanceMetrics(ctx context.Context, manager api.CloudproviderDetails, provider cloudprovider.ICloudProvider, res map[string]api.DBInstanceDetails, start, end time.Time) error {
|
||||
|
||||
@@ -47,6 +47,32 @@ func init() {
|
||||
Register(&HuaweiCollect{})
|
||||
}
|
||||
|
||||
func (self *HuaweiCollect) CollectAccountMetrics(ctx context.Context, account api.CloudaccountDetail) (influxdb.SMetricData, error) {
|
||||
metric := influxdb.SMetricData{
|
||||
Name: string(cloudprovider.METRIC_RESOURCE_TYPE_CLOUD_ACCOUNT),
|
||||
Timestamp: time.Now(),
|
||||
Tags: []influxdb.SKeyValue{},
|
||||
Metrics: []influxdb.SKeyValue{},
|
||||
}
|
||||
for k, v := range account.GetMetricTags() {
|
||||
metric.Tags = append([]influxdb.SKeyValue{
|
||||
{
|
||||
Key: k,
|
||||
Value: v,
|
||||
},
|
||||
}, metric.Tags...)
|
||||
}
|
||||
for k, v := range account.GetMetricPairs() {
|
||||
metric.Metrics = append([]influxdb.SKeyValue{
|
||||
{
|
||||
Key: k,
|
||||
Value: v,
|
||||
},
|
||||
}, metric.Metrics...)
|
||||
}
|
||||
return metric, nil
|
||||
}
|
||||
|
||||
func (self *HuaweiCollect) CollectModelartsPoolMetrics(ctx context.Context, manager api.CloudproviderDetails, provider cloudprovider.ICloudProvider, res map[string]api.ModelartsPoolDetails, start, end time.Time) error {
|
||||
metrics := []influxdb.SMetricData{}
|
||||
var wg sync.WaitGroup
|
||||
|
||||
@@ -48,6 +48,32 @@ func init() {
|
||||
Register(&QcloudCollect{})
|
||||
}
|
||||
|
||||
func (self *QcloudCollect) CollectAccountMetrics(ctx context.Context, account api.CloudaccountDetail) (influxdb.SMetricData, error) {
|
||||
metric := influxdb.SMetricData{
|
||||
Name: string(cloudprovider.METRIC_RESOURCE_TYPE_CLOUD_ACCOUNT),
|
||||
Timestamp: time.Now(),
|
||||
Tags: []influxdb.SKeyValue{},
|
||||
Metrics: []influxdb.SKeyValue{},
|
||||
}
|
||||
for k, v := range account.GetMetricTags() {
|
||||
metric.Tags = append([]influxdb.SKeyValue{
|
||||
{
|
||||
Key: k,
|
||||
Value: v,
|
||||
},
|
||||
}, metric.Tags...)
|
||||
}
|
||||
for k, v := range account.GetMetricPairs() {
|
||||
metric.Metrics = append([]influxdb.SKeyValue{
|
||||
{
|
||||
Key: k,
|
||||
Value: v,
|
||||
},
|
||||
}, metric.Metrics...)
|
||||
}
|
||||
return metric, nil
|
||||
}
|
||||
|
||||
func (self *QcloudCollect) CollectServerMetrics(ctx context.Context, manager api.CloudproviderDetails, provider cloudprovider.ICloudProvider, res map[string]api.ServerDetails, start, end time.Time) error {
|
||||
metrics := []influxdb.SMetricData{}
|
||||
regionServers := map[string][]api.ServerDetails{}
|
||||
|
||||
Reference in New Issue
Block a user