options.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package options
  15. import (
  16. common_options "yunion.io/x/onecloud/pkg/cloudcommon/options"
  17. )
  18. type CloudMonOptions struct {
  19. common_options.CommonOptions
  20. PingProbeOptions
  21. ResourcesSyncInterval int64 `help:"Increment Sync Interval unit:minute" default:"10"`
  22. CollectMetricInterval int64 `help:"Increment Sync Interval unit:minute" default:"6"`
  23. SkipMetricPullProviders string `help:"Skip indicate provider metric pull" default:""`
  24. InfluxDatabase string `help:"influxdb database name, default telegraf" default:"telegraf"`
  25. DisableServiceMetric bool `help:"disable service metric collect"`
  26. CollectServiceMetricIntervalMinute int64 `help:"Collect Service metirc Interval unit:minute" default:"1"`
  27. HistoryMetricPullDays int `help:"pull history metrics" default:"-1"`
  28. SupportAzureTableStorageMetric bool `help:"support collect azure memory and disk usage metric, there may be additional charges" default:"false"`
  29. CloudAccountCollectMetricsBatchCount int `help:"Cloud Account Collect Metrics Batch Count" default:"10"`
  30. CloudResourceCollectMetricsBatchCount int `help:"Cloud Resource Collect Metrics BatchC ount" default:"40"`
  31. OracleCloudResourceCollectMetricsBatchCount int `help:"OracleCloud Resource Collect Metrics BatchC ount" default:"1"`
  32. StatusProbeIntervalMinutes int `help:"Status Probe Interval unit:minute" default:"15"`
  33. StatusProbeModels []string `help:"Status Probe Models" default:"compute-servers,compute-hosts"`
  34. EnableStatusProbe bool `help:"Enable Status Probe" default:"false"`
  35. EnableStatusProbeDebug bool `help:"Enable Status Probe Debug" default:"false"`
  36. BucketProbeIntervalMinutes int `help:"Bucket Probe Interval unit:minute" default:"15"`
  37. EnableBucketProbe bool `help:"Enable Bucket Probe" default:"false"`
  38. EnableBucketProbeDebug bool `help:"Enable Bucket Probe Debug" default:"false"`
  39. BucketProbeTestKey string `help:"Bucket Probe Test Key" default:"bucket_performance_test_object"`
  40. BucketProbeTestSizeMb int `help:"Bucket Probe Test Size" default:"4"`
  41. }
  42. type PingProbeOptions struct {
  43. Debug bool `help:"debug"`
  44. ProbeCount int `help:"probe count, default is 3" default:"3"`
  45. TimeoutSecond int `help:"probe timeout in second, default is 1 second" default:"1"`
  46. DisablePingProbe bool `help:"enable ping probe" default:"true"`
  47. PingProbIntervalHours int64 `help:"PingProb Interval unit:hour" default:"6"`
  48. PingReserveIPTimeoutHours int `help:"expire hours to reserve the probed IP, default 0, never expire" default:"0"`
  49. }
  50. var (
  51. Options CloudMonOptions
  52. )
  53. func OnOptionsChange(oldO, newO interface{}) bool {
  54. oldOpts := oldO.(*CloudMonOptions)
  55. newOpts := newO.(*CloudMonOptions)
  56. changed := false
  57. if common_options.OnCommonOptionsChange(&oldOpts.CommonOptions, &newOpts.CommonOptions) {
  58. changed = true
  59. }
  60. if oldOpts.DisablePingProbe != newOpts.DisablePingProbe {
  61. if !oldOpts.IsSlaveNode {
  62. changed = true
  63. }
  64. }
  65. if oldOpts.ResourcesSyncInterval != newOpts.ResourcesSyncInterval {
  66. changed = true
  67. }
  68. if oldOpts.CollectMetricInterval != newOpts.CollectMetricInterval {
  69. changed = true
  70. }
  71. if oldOpts.CollectServiceMetricIntervalMinute != newOpts.CollectServiceMetricIntervalMinute {
  72. changed = true
  73. }
  74. return changed
  75. }