mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #13652 from zhaoxiangchun/fix/zxc-master
fix(cloudmon): 3.9 release add Usage pull func
This commit is contained in:
@@ -51,6 +51,7 @@ const (
|
||||
ALERT_RECORD MonType = "alertRecord"
|
||||
|
||||
PING_PROBE MonType = "ping_probe"
|
||||
USAGE MonType = "usage"
|
||||
|
||||
K8S MonType = "k8s"
|
||||
K8S_DEPLOY = MonType(K8S_MODULE_DEPLOY)
|
||||
@@ -81,7 +82,8 @@ var (
|
||||
|
||||
ResMonTypeList = []string{string(SERVER), string(HOST), string(REDIS), string(RDS), string(OSS),
|
||||
string(ELB), string(K8S)}
|
||||
CustomizeMonTypeList = []string{string(CLOUDACCOUNT), string(STORAGE), string(ALERT_RECORD), string(PING_PROBE)}
|
||||
CustomizeMonTypeList = []string{string(CLOUDACCOUNT), string(STORAGE), string(ALERT_RECORD), string(PING_PROBE),
|
||||
string(USAGE)}
|
||||
)
|
||||
|
||||
var OtherVmTags = map[string]string{
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudmon/collectors/common"
|
||||
"yunion.io/x/onecloud/pkg/cloudmon/options"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
|
||||
@@ -38,6 +39,39 @@ var measureMent string = "usage"
|
||||
|
||||
func init() {
|
||||
shellutils.R(&options.ReportOptions{}, "report-usage", "Report Usage", reportUsage)
|
||||
factory := UsageColectorFactory{}
|
||||
common.RegisterFactory(&factory)
|
||||
}
|
||||
|
||||
type UsageColectorFactory struct {
|
||||
common.CommonReportFactory
|
||||
}
|
||||
|
||||
func (p UsageColectorFactory) NewCloudReport(provider *common.SProvider, session *mcclient.ClientSession, args *options.ReportOptions, operatorType string) common.ICloudReport {
|
||||
return &SUsageColectorReport{
|
||||
common.CloudReportBase{
|
||||
SProvider: nil,
|
||||
Session: session,
|
||||
Args: args,
|
||||
Operator: string(common.USAGE),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (p UsageColectorFactory) GetId() string {
|
||||
return string(common.USAGE)
|
||||
}
|
||||
|
||||
type SUsageColectorReport struct {
|
||||
common.CloudReportBase
|
||||
}
|
||||
|
||||
func (self *SUsageColectorReport) Report() error {
|
||||
err := reportUsage(self.Session, self.Args)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "usageCollector err")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func reportUsage(session *mcclient.ClientSession, args *options.ReportOptions) error {
|
||||
|
||||
Reference in New Issue
Block a user