feat: nbi
This commit is contained in:
31
lib/config/alarm_relation_rules.go
Normal file
31
lib/config/alarm_relation_rules.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type DerivedRule struct {
|
||||
ParentCode int `yaml:"parentCode"`
|
||||
ChildCode int `yaml:"childCode"`
|
||||
}
|
||||
type RelatedRule struct {
|
||||
Codes []int `yaml:"codes"`
|
||||
NeType string `yaml:"neType"`
|
||||
TimeWindow int `yaml:"timeWindow"`
|
||||
}
|
||||
type AlarmRelationRules struct {
|
||||
Derived []DerivedRule `yaml:"derived"`
|
||||
Related []RelatedRule `yaml:"related"`
|
||||
}
|
||||
|
||||
var RelationRules AlarmRelationRules
|
||||
|
||||
func LoadAlarmRelationRules(path string) error {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return yaml.Unmarshal(data, &RelationRules)
|
||||
}
|
||||
@@ -180,7 +180,11 @@ type AlarmConfig struct {
|
||||
SignName string `yaml:"signName"`
|
||||
TemplateCode string `yaml:"templateCode"`
|
||||
} `yaml:"smsForward"`
|
||||
SMProxy string `yaml:"smProxy"`
|
||||
SMProxy string `yaml:"smProxy"`
|
||||
RelatedRules struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
File string `yaml:"file"`
|
||||
} `yaml:"relatedRules"`
|
||||
}
|
||||
|
||||
type MMLParam struct {
|
||||
@@ -271,6 +275,11 @@ func ReadConfig(configFile string) {
|
||||
yamlConfig = YamlConfigInfo.ConfigLines
|
||||
|
||||
ReadOriginalConfig(configFile)
|
||||
|
||||
// load alarm relation rules
|
||||
if yamlConfig.Alarm.RelatedRules.Enabled {
|
||||
LoadAlarmRelationRules(yamlConfig.Alarm.RelatedRules.File)
|
||||
}
|
||||
}
|
||||
|
||||
func ReadOriginalConfig(configFile string) {
|
||||
|
||||
Reference in New Issue
Block a user