backup and alarm
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# level: /trace/debug/info/error/warn/error/fatal, default: debug
|
||||
# duration: saved days, default is 30 days
|
||||
logger:
|
||||
file: d:/omc.git/goprojects/ems.agt/crontask/log/crontask.log
|
||||
file: d:/local.git/be.ems/crontask/log/crontask.log
|
||||
level: trace
|
||||
duration: 24
|
||||
count: 10
|
||||
@@ -27,7 +27,7 @@ database:
|
||||
host: 127.0.0.1
|
||||
port: 33066
|
||||
name: omc_db
|
||||
backup: d:/omc.git/goprojects/ems.agt/restagent/database
|
||||
backup: d:/local.git/be.ems/restagent/database
|
||||
|
||||
# northbound interface, cm/pm
|
||||
nbi:
|
||||
|
||||
@@ -61,7 +61,21 @@ tasks:
|
||||
params: SQL=select+*+into+outfile+'%s'+fields+terminated+by+','+escaped+by+''+optionally+enclosed+by+''+lines+terminated+by+'\n'+from+(select+'op_id','account_name','op_ip','subsys_tag','op_type','op_content','op_result','begin_time','end_time','vnf_flag','log_time'+union+select+op_id,account_name,op_ip,subsys_tag,op_type,op_content,op_result,begin_time,end_time,vnf_flag,log_time+from+operation_log)+b
|
||||
interval: 1
|
||||
unit: Days
|
||||
at: 00:25:00
|
||||
at: 00:26:00
|
||||
do: TaskDBBackupCSVGetBySQL
|
||||
- name: Backup security log
|
||||
uri: /api/rest/databaseManagement/v1/omc_db/security_log
|
||||
params: SQL=select+*+into+outfile+'%s'+fields+terminated+by+','+escaped+by+''+optionally+enclosed+by+''+lines+terminated+by+'\n'+from+(select+'id','account_name','account_type','op_ip','op_type','op_content','op_result','op_time'+union+select+id,account_name,account_type,op_ip,op_type,op_content,op_result,op_time+from+security_log)+b
|
||||
interval: 1
|
||||
unit: Days
|
||||
at: 00:28:00
|
||||
do: TaskDBBackupCSVGetBySQL
|
||||
- name: Backup alarm log
|
||||
uri: /api/rest/databaseManagement/v1/omc_db/alarm_log
|
||||
params: SQL=select+*+into+outfile+'%s'+fields+terminated+by+','+escaped+by+''+optionally+enclosed+by+''+lines+terminated+by+'\n'+from+(select+'id','ne_type','ne_id','alarm_seq','alarm_id','alarm_code','alarm_status','event_time','log_time'+union+select+id,ne_type,ne_id,alarm_seq,alarm_id,alarm_code,alarm_status,event_time,log_time+from+alarm_log)+b
|
||||
interval: 1
|
||||
unit: Days
|
||||
at: 00:30:00
|
||||
do: TaskDBBackupCSVGetBySQL
|
||||
- name: handshake to NF
|
||||
status: Active
|
||||
|
||||
@@ -126,7 +126,7 @@ func (t *TaskFunc) GenNFXmlFile(neType string) error {
|
||||
case "UserLabel":
|
||||
v = ne.NeName
|
||||
case "VendorName":
|
||||
v = "Ruijie Network"
|
||||
v = "RJ"
|
||||
case "SwVersion":
|
||||
v = global.Version
|
||||
case "PatchInfo":
|
||||
|
||||
@@ -24,7 +24,7 @@ ALTER TABLE `omc_db`.`permission`
|
||||
ADD COLUMN IF NOT EXISTS `management` varchar(32) NULL DEFAULT '*' AFTER `method`;
|
||||
|
||||
ALTER TABLE `omc_db`.`permission`
|
||||
CHANGE COLUMN `create_at` `created_at` datetime NULL DEFAULT current_timestamp AFTER `description`,
|
||||
CHANGE COLUMN IF EXISTS `create_at` `created_at` datetime NULL DEFAULT current_timestamp AFTER `description`,
|
||||
MODIFY COLUMN `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '*' AFTER `permission_name`,
|
||||
MODIFY COLUMN `management` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '*' AFTER `method`,
|
||||
MODIFY COLUMN `element` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '*' AFTER `management`,
|
||||
@@ -35,3 +35,7 @@ ADD COLUMN IF NOT EXISTS `deleted_at` datetime NULL AFTER `updated_at`;
|
||||
ALTER TABLE `omc_db`.`permission`
|
||||
DROP INDEX IF EXISTS `permission_name`,
|
||||
ADD UNIQUE INDEX `permission_name`(`permission_name`) USING BTREE;
|
||||
|
||||
ALTER TABLE `omc_db`.`ne_software`
|
||||
DROP COLUMN IF EXISTS `patch_time`,
|
||||
ADD COLUMN IF NOT EXISTS `patch_time` datetime NULL AFTER `update_time`;
|
||||
@@ -235,12 +235,15 @@ func PostAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
//services.ResponseInternalServerError500ProcessError(w, err)
|
||||
//return
|
||||
}
|
||||
log.Debug("valueJson:", valueJson)
|
||||
session := xEngine.NewSession()
|
||||
defer session.Close()
|
||||
log.Trace("valueJson:", valueJson)
|
||||
// session := xEngine.NewSession()
|
||||
// defer session.Close()
|
||||
var activeAlarmNum int = 0
|
||||
for _, alarmData := range *alarmArray {
|
||||
log.Debug("alarmData:", alarmData)
|
||||
|
||||
session := xEngine.NewSession()
|
||||
defer session.Close()
|
||||
if alarmData.AlarmStatus == AlarmStatusClear {
|
||||
alarmData.ClearType = ClearTypeAutoClear
|
||||
alarmData.ClearTime.Valid = true
|
||||
@@ -267,7 +270,7 @@ func PostAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
log.Debug("alarmData:", alarmData)
|
||||
log.Trace("alarmData:", alarmData)
|
||||
var currentSeq string
|
||||
var seq int
|
||||
has, err := xEngine.Table("alarm").
|
||||
@@ -325,6 +328,7 @@ func PostAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
session.Commit()
|
||||
// for alarm forward time format
|
||||
alarmData.EventTime = eventTime
|
||||
} else {
|
||||
@@ -350,11 +354,12 @@ func PostAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
log.Error("Failed to get alarm:", err)
|
||||
continue
|
||||
}
|
||||
log.Debugf("neType=%s, neId=%s, currentSeq=%s", alarmData.NeType, alarmData.NeId, currentSeq)
|
||||
log.Debugf("neType=%s, neId=%s, currentSeq=%s activeAlarmNum=%d",
|
||||
alarmData.NeType, alarmData.NeId, currentSeq, activeAlarmNum)
|
||||
|
||||
if has == true {
|
||||
seq, _ := strconv.Atoi(currentSeq)
|
||||
alarmData.AlarmSeq = seq + activeAlarmNum
|
||||
alarmData.AlarmSeq = seq + 1
|
||||
if alarmData.AlarmSeq > global.MaxInt32Number {
|
||||
alarmData.AlarmSeq = AlarmSeqBeginNumber
|
||||
}
|
||||
@@ -420,12 +425,13 @@ func PostAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
alarmLog.AlarmCode = alarmData.AlarmCode
|
||||
alarmLog.AlarmStatus = alarmData.AlarmStatus
|
||||
alarmLog.EventTime = eventTime
|
||||
log.Debug("alarmLog:", alarmLog)
|
||||
log.Trace("alarmLog:", alarmLog)
|
||||
|
||||
affected, err = session.Insert(alarmLog)
|
||||
if err != nil && affected <= 0 {
|
||||
log.Error("Failed to insert alarm_log:", err)
|
||||
}
|
||||
session.Commit()
|
||||
}
|
||||
if config.GetYamlConfig().Alarm.ForwardAlarm {
|
||||
if err = AlarmEmailForward(&alarmData); err != nil {
|
||||
@@ -437,7 +443,6 @@ func PostAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
session.Commit()
|
||||
services.ResponseStatusOK200Null(w)
|
||||
}
|
||||
|
||||
@@ -487,11 +492,14 @@ func GetAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
//services.ResponseInternalServerError500ProcessError(w, err)
|
||||
continue
|
||||
}
|
||||
session := xEngine.NewSession()
|
||||
defer session.Close()
|
||||
// session := xEngine.NewSession()
|
||||
// defer session.Close()
|
||||
var activeAlarmNum int = 0
|
||||
for _, alarmData := range *alarmArray {
|
||||
log.Debug("alarmData:", alarmData)
|
||||
|
||||
session := xEngine.NewSession()
|
||||
defer session.Close()
|
||||
// todo: clear alarm ....
|
||||
if alarmData.AlarmStatus == AlarmStatusClear {
|
||||
exist, err := session.Table("alarm").
|
||||
@@ -571,7 +579,7 @@ func GetAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
session.Commit()
|
||||
// for alarm forward time format
|
||||
alarmData.EventTime = eventTime
|
||||
} else {
|
||||
@@ -597,11 +605,12 @@ func GetAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
log.Error("Failed to get alarm:", err)
|
||||
continue
|
||||
}
|
||||
log.Debugf("neType=%s, neId=%s, currentSeq=%s", alarmData.NeType, alarmData.NeId, currentSeq)
|
||||
log.Debugf("neType=%s, neId=%s, currentSeq=%s, activeAlarmNum=%d",
|
||||
alarmData.NeType, alarmData.NeId, currentSeq, activeAlarmNum)
|
||||
|
||||
if has == true {
|
||||
seq, _ := strconv.Atoi(currentSeq)
|
||||
alarmData.AlarmSeq = seq + activeAlarmNum
|
||||
alarmData.AlarmSeq = seq + 1
|
||||
if alarmData.AlarmSeq > global.MaxInt32Number {
|
||||
alarmData.AlarmSeq = AlarmSeqBeginNumber
|
||||
}
|
||||
@@ -646,7 +655,7 @@ func GetAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
if IsNeedToAckAlarm(valueJson, &alarmData) == true {
|
||||
SetAlarmAckInfo(valueJson, &alarmData)
|
||||
}
|
||||
log.Debug("alarmData:", alarmData)
|
||||
log.Trace("alarmData:", alarmData)
|
||||
affected, err := session.Insert(alarmData)
|
||||
if err == nil && affected > 0 {
|
||||
alarmLog := new(AlarmLog)
|
||||
|
||||
@@ -129,7 +129,7 @@ func CheckLocalRmUID(rmUIDs []string) string {
|
||||
}
|
||||
|
||||
func NBIGetNRMFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
log.Debug("NorthGetNRMFromNF processing... ")
|
||||
log.Debug("NBIGetNRMFromNF processing... ")
|
||||
|
||||
// response 414-4 uri too long ? (optional)
|
||||
// todo ... ?
|
||||
@@ -220,19 +220,9 @@ func NBIGetNRMFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
services.ResponseRequestURITooLong414NRMNumExceed(w, config.GetYamlConfig().Params.RmUIDMaxNum)
|
||||
return
|
||||
}
|
||||
/*
|
||||
// response 400-1
|
||||
// check rmUID is valid
|
||||
// todo ...
|
||||
invalidRmUIDs := CheckValidRmUID(rmUIDValues)
|
||||
if len(invalidRmUIDs) != 0 {
|
||||
log.Debug("rmUID is invalid")
|
||||
services.ResponseBadRequest400RmUIDsIsInvalid(w, invalidRmUIDs)
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
var response *resty.Response
|
||||
// respMsg := make(map[string]interface{})
|
||||
respMsg := make(map[string]interface{})
|
||||
for _, rmUID := range rmUIDValues {
|
||||
neInfo, err := dborm.XormGetNeInfoByRmUID(neType, rmUID)
|
||||
if err != nil {
|
||||
@@ -255,16 +245,14 @@ func NBIGetNRMFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
services.ResponseInternalServerError500NFConnectRefused(w)
|
||||
return
|
||||
}
|
||||
/*
|
||||
switch response.StatusCode() {
|
||||
case http.StatusOK, http.StatusAccepted, http.StatusNoContent, http.StatusCreated:
|
||||
respMsg["data"] = response
|
||||
default:
|
||||
if response != nil {
|
||||
services.TransportResponse(w, response.StatusCode(), response.Body())
|
||||
}
|
||||
switch response.StatusCode() {
|
||||
case http.StatusOK, http.StatusAccepted, http.StatusNoContent, http.StatusCreated:
|
||||
respMsg["data"] = response
|
||||
default:
|
||||
if response != nil {
|
||||
services.TransportResponse(w, response.StatusCode(), response.Body())
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
services.TransportResponse(w, response.StatusCode(), response.Body())
|
||||
|
||||
Binary file not shown.
@@ -3,7 +3,7 @@
|
||||
# duration: rotation time with xx hours, example: 1/12/24 hours
|
||||
# count: rotation count of log, default is 30 rotation
|
||||
logger:
|
||||
file: d:/omc.git/goprojects/ems.agt/sshsvc/log/sshsvc.log
|
||||
file: d:/local.git/be.ems/sshsvc/log/sshsvc.log
|
||||
level: trace
|
||||
duration: 24
|
||||
count: 30
|
||||
@@ -13,7 +13,7 @@ logger:
|
||||
# count: rotation count of log, default is 30 rotation
|
||||
# level: cmd/ret log cmd/log cmd & result
|
||||
logmml:
|
||||
file: d:/omc.git/goprojects/ems.agt/sshsvc/mmllog/omcmml.log
|
||||
file: d:/local.git/be.ems/sshsvc/mmllog/omcmml.log
|
||||
duration: 24
|
||||
count: 30
|
||||
level: ret
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
home="/home/simon"
|
||||
project="goprojects"
|
||||
Home=/home/simon
|
||||
GitLocalRoot=${Home}/local.git
|
||||
EmsBEDir=${GitLocalRoot}/be.ems
|
||||
user="root"
|
||||
password="1000omc@kp!"
|
||||
host="192.168.2.119"
|
||||
port="33066"
|
||||
dbname="omc_db"
|
||||
dumpdbdir=${home}/${project}/ems.agt/tools/misc
|
||||
insdir=${home}/${project}/ems.agt/database/install
|
||||
upgdir=${home}/${project}/ems.agt/database/upgrade
|
||||
dumpdbdir=${EmsBEDir}/tools/misc
|
||||
insdir=${EmsBEDir}/database/install
|
||||
upgdir=${EmsBEDir}/database/upgrade
|
||||
tables_c=tables_c.lst
|
||||
tables_s=tables_s.lst
|
||||
|
||||
|
||||
@@ -13,3 +13,4 @@ param_config
|
||||
title_info
|
||||
trace_info
|
||||
user_menu
|
||||
permission
|
||||
|
||||
Reference in New Issue
Block a user