diff --git a/server/controller/config/common/config.go b/server/controller/config/common/config.go index 8f8515ee6be..dd06a7c5a32 100644 --- a/server/controller/config/common/config.go +++ b/server/controller/config/common/config.go @@ -27,6 +27,13 @@ type Warrant struct { Timeout int `default:"30" yaml:"timeout"` } +type Manager struct { + Enabled bool `default:"false" yaml:"enabled"` + Host string `default:"manager" yaml:"host"` + Port int `default:"20403" yaml:"port"` + Timeout int `default:"30" yaml:"timeout"` +} + type FPermit struct { Enabled bool `default:"false" yaml:"enabled"` Host string `default:"fpermit" yaml:"host"` diff --git a/server/controller/controller/master.go b/server/controller/controller/master.go index 84b0c90c2e0..9a69421e574 100644 --- a/server/controller/controller/master.go +++ b/server/controller/controller/master.go @@ -29,6 +29,7 @@ import ( "github.com/deepflowio/deepflow/server/controller/http/service" resoureservice "github.com/deepflowio/deepflow/server/controller/http/service/resource" "github.com/deepflowio/deepflow/server/controller/monitor" + "github.com/deepflowio/deepflow/server/controller/monitor/bill" "github.com/deepflowio/deepflow/server/controller/monitor/license" "github.com/deepflowio/deepflow/server/controller/monitor/vtap" "github.com/deepflowio/deepflow/server/controller/prometheus" @@ -96,6 +97,7 @@ func checkAndStartMasterFunctions( vtapCheck := vtap.NewVTapCheck(cfg.MonitorCfg, ctx) vtapRebalanceCheck := vtap.NewRebalanceCheck(cfg.MonitorCfg, ctx) vtapLicenseAllocation := license.NewVTapLicenseAllocation(cfg.MonitorCfg, ctx) + billCheck := bill.NewBillCheck(cfg.BillingMethod, cfg.MonitorCfg, ctx) recorderResource := recorder.GetResource() domainChecker := resoureservice.NewDomainCheck(ctx) prometheus := prometheus.GetSingleton() @@ -151,6 +153,9 @@ func checkAndStartMasterFunctions( vtapLicenseAllocation.Start(sCtx) } + // bill check + billCheck.Start(sCtx) + // 资源数据清理 recorderResource.Cleaners.Start(sCtx) diff --git a/server/controller/monitor/bill/bill.go b/server/controller/monitor/bill/bill.go new file mode 100644 index 00000000000..8d521f4e743 --- /dev/null +++ b/server/controller/monitor/bill/bill.go @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Yunshan Networks + * + * 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 bill + +import ( + "context" + + "github.com/deepflowio/deepflow/server/controller/monitor/config" +) + +type BillCheck struct { + vCtx context.Context + vCancel context.CancelFunc + config config.MonitorConfig +} + +func NewBillCheck(method string, cfg config.MonitorConfig, ctx context.Context) *BillCheck { + vCtx, vCancel := context.WithCancel(ctx) + return &BillCheck{ + vCtx: vCtx, + vCancel: vCancel, + config: cfg, + } +} + +func (b *BillCheck) Start(sCtx context.Context) {} + +func (b *BillCheck) Stop() { + if b.vCancel != nil { + b.vCancel() + } +} diff --git a/server/controller/monitor/bill/go.mod b/server/controller/monitor/bill/go.mod new file mode 100644 index 00000000000..ce09db855ae --- /dev/null +++ b/server/controller/monitor/bill/go.mod @@ -0,0 +1,3 @@ +module github.com/deepflowio/deepflow/server/controller/monitor/bill + +go 1.24 diff --git a/server/controller/monitor/config/config.go b/server/controller/monitor/config/config.go index 851ad171434..44b717324d0 100644 --- a/server/controller/monitor/config/config.go +++ b/server/controller/monitor/config/config.go @@ -25,12 +25,14 @@ type MonitorConfig struct { HealthCheckPort int `default:"30417" yaml:"health_check_port"` HealthCheckHandleChannelLen int `default:"1000" yaml:"health_check_handle_channel_len"` LicenseCheckInterval int `default:"60" yaml:"license_check_interval"` + BillCheckInterval int `default:"3600" yaml:"bill_check_interval"` VTapCheckInterval int `default:"60" yaml:"vtap_check_interval"` ExceptionTimeFrame int `default:"3600" yaml:"exception_time_frame"` AutoRebalanceVTap bool `default:"true" yaml:"auto_rebalance_vtap"` RebalanceCheckInterval int `default:"300" yaml:"rebalance_check_interval"` // unit: second VTapAutoDelete VTapAutoDelete `yaml:"vtap_auto_delete"` Warrant configs.Warrant `yaml:"warrant"` + Manager configs.Manager `yaml:"manager"` IngesterLoadBalancingConfig IngesterLoadBalancingStrategy `yaml:"ingester-load-balancing-strategy"` SyncDefaultORGDataInterval int `default:"10" yaml:"sync_default_org_data_interval"` } diff --git a/server/go.mod b/server/go.mod index ec138a0a42f..6dabf5cd1c7 100644 --- a/server/go.mod +++ b/server/go.mod @@ -16,6 +16,7 @@ replace ( github.com/deepflowio/deepflow/server/controller/http/appender => ./controller/http/appender github.com/deepflowio/deepflow/server/controller/http/service/agentlicense => ./controller/http/service/agentlicense github.com/deepflowio/deepflow/server/controller/http/service/configuration => ./controller/http/service/configuration + github.com/deepflowio/deepflow/server/controller/monitor/bill => ./controller/monitor/bill github.com/deepflowio/deepflow/server/controller/monitor/license => ./controller/monitor/license github.com/deepflowio/deepflow/server/controller/monitor/vtap/version => ./controller/monitor/vtap/version github.com/deepflowio/deepflow/server/controller/native_field => ./controller/native_field @@ -67,6 +68,7 @@ require ( github.com/deepflowio/deepflow/server/controller/genesis/store/sync/redis v0.0.0-00010101000000-000000000000 github.com/deepflowio/deepflow/server/controller/http/appender v0.0.0-00010101000000-000000000000 github.com/deepflowio/deepflow/server/controller/http/service/agentlicense v0.0.0-00010101000000-000000000000 + github.com/deepflowio/deepflow/server/controller/monitor/bill v0.0.0-00010101000000-000000000000 github.com/deepflowio/deepflow/server/controller/monitor/license v0.0.0-00010101000000-000000000000 github.com/deepflowio/deepflow/server/controller/monitor/vtap/version v0.0.0-00010101000000-000000000000 github.com/deepflowio/deepflow/server/controller/native_field v0.0.0-00010101000000-000000000000