fix: add parameter dataCoding and serverNumber to alarm SMS forward

This commit is contained in:
2024-09-20 11:03:43 +08:00
parent 9e71a35cd7
commit e9e5822d6c
6 changed files with 98 additions and 81 deletions

View File

@@ -150,6 +150,16 @@ type DbConfig struct {
Backup string `yaml:"backup"`
}
//type codingType int
const (
// Short message data coding type
CODING_UCS2 int = iota
CODING_ASCII
CODING_LATIN1
CODING_NODEF
)
type AlarmConfig struct {
SplitEventAlarm bool `yaml:"splitEventAlarm"`
//ForwardAlarm bool `yaml:"forwardAlarm"`
@@ -164,12 +174,14 @@ type AlarmConfig struct {
TLSSkipVerify bool `yaml:"tlsSkipVerify" json:"tlsSkipVerify"`
} `yaml:"alarmEmailForward"`
SMSCForward struct {
Enable bool `yaml:"enable" json:"enable"`
MobileList string `yaml:"mobileList" json:"mobileList"`
SMSCAddr string `yaml:"smscAddr" json:"smscAddr"`
SystemID string `yaml:"systemID" json:"systemID"`
Password string `yaml:"password" json:"password"`
SystemType string `yaml:"systemType" json:"systemType"`
Enable bool `yaml:"enable" json:"enable"`
MobileList string `yaml:"mobileList" json:"mobileList"`
SMSCAddr string `yaml:"smscAddr" json:"smscAddr"`
SystemID string `yaml:"systemID" json:"systemID"`
Password string `yaml:"password" json:"password"`
SystemType string `yaml:"systemType" json:"systemType"`
DataCoding int `yaml:"dataCoding" json:"dataCoding"`
ServiceNumber string `yaml:"serviceNumber" json:"serviceNumber"`
} `yaml:"alarmSMSForward"`
SMS struct {
ApiURL string `yaml:"apiURL"`
@@ -304,7 +316,19 @@ func WriteOrignalConfig(configFile string, paramName string, paramData map[strin
for j := i + 1; j < len(lines); j++ {
if strings.Contains(lines[j], k+":") {
index := strings.Index(lines[j], k)
lines[j] = lines[j][:index] + fmt.Sprintf("%s: %v", k, v)
// Determine the type of v
switch v := v.(type) {
case string:
lines[j] = lines[j][:index] + fmt.Sprintf("%s: \"%s\"", k, v)
// case int:
// lines[j] = lines[j][:index] + fmt.Sprintf("%s: %d", k, v)
// case float64:
// lines[j] = lines[j][:index] + fmt.Sprintf("%s: %f", k, v)
case bool:
lines[j] = lines[j][:index] + fmt.Sprintf("%s: %t", k, v)
default:
lines[j] = lines[j][:index] + fmt.Sprintf("%s: %v", k, v)
}
break
}
}

View File

@@ -126,6 +126,7 @@ omc:
# TLS Skip verify: true/false
# email/sms
# smProxy: sms(Short Message Service)/smsc(SMS Centre)
# dataCoding: 0:UCS2, 1:ASCII, 2:LATIN1
alarm:
alarmEmailForward:
enable: true
@@ -142,6 +143,8 @@ alarm:
systemID: "omc"
password: "omc123"
systemType: "UTRAN"
dataCoding: 0
serviceNumber: "OMC"
sms:
apiURL: http://smsc.xxx.com/
accessKeyID: xxxx