mod_monitor_resource.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 monitor
  15. import (
  16. "yunion.io/x/onecloud/pkg/mcclient/modulebase"
  17. "yunion.io/x/onecloud/pkg/mcclient/modules"
  18. )
  19. var (
  20. MonitorResourceManager *SMonitorResourceManager
  21. MonitorResourceAlertManager *SMonitorResourceAlertManager
  22. )
  23. type SMonitorResourceManager struct {
  24. *modulebase.ResourceManager
  25. }
  26. type SMonitorResourceAlertManager struct {
  27. *modulebase.JointResourceManager
  28. }
  29. func init() {
  30. MonitorResourceManager = NewMonitorResourceManager()
  31. MonitorResourceAlertManager = newAlertResourceAlertManager()
  32. modules.Register(MonitorResourceManager)
  33. modules.Register(MonitorResourceAlertManager)
  34. }
  35. func NewMonitorResourceManager() *SMonitorResourceManager {
  36. man := modules.NewMonitorV2Manager("monitorresource", "monitorresources",
  37. []string{"id", "name", "res_type", "res_id", "alert_state", "status", "data"},
  38. []string{})
  39. return &SMonitorResourceManager{
  40. ResourceManager: &man,
  41. }
  42. }
  43. func newAlertResourceAlertManager() *SMonitorResourceAlertManager {
  44. man := modules.NewJointMonitorV2Manager("monitorresourcealert", "monitorresourcealerts",
  45. []string{"monitor_resource_id", "alert_count", "alert_id", "res_name", "res_type", "metric", "alert_name", "alert_state", "send_state", "level",
  46. "trigger_time", "data"},
  47. []string{},
  48. MonitorResourceManager, CommonAlerts)
  49. return &SMonitorResourceAlertManager{&man}
  50. }