From 0ccd6a5a706312a5ef61e6928cf25420b46b2d75 Mon Sep 17 00:00:00 2001 From: HeeJin Lee Date: Fri, 6 Oct 2023 10:10:45 +0900 Subject: [PATCH] Apply SDK changes for AlertTypes in sdk.CallResponse --- plugins/cpu_monitor/main.go | 18 ++++++++---------- plugins/disk_monitor/main.go | 18 ++++++++---------- plugins/mem_monitor/main.go | 18 ++++++++---------- plugins/net_monitor/main.go | 9 ++++----- 4 files changed, 28 insertions(+), 35 deletions(-) diff --git a/plugins/cpu_monitor/main.go b/plugins/cpu_monitor/main.go index 4dd8057..94a5a49 100644 --- a/plugins/cpu_monitor/main.go +++ b/plugins/cpu_monitor/main.go @@ -58,11 +58,10 @@ func pluginFeature(info, option map[string]*structpb.Value) (sdk.CallResponse, e percent, err := cpu.Percent(defaultDuration*time.Second, false) if err != nil { ret := sdk.CallResponse{ - FuncName: info["execute_method"].GetStringValue(), - Message: "failed to get cpu usage", - Severity: pluginpb.SEVERITY_CRITICAL, - State: pluginpb.STATE_FAILURE, - AlertTypes: []pluginpb.ALERT_TYPE{pluginpb.ALERT_TYPE_DISCORD}, + FuncName: info["execute_method"].GetStringValue(), + Message: "failed to get cpu usage", + Severity: pluginpb.SEVERITY_CRITICAL, + State: pluginpb.STATE_FAILURE, } return ret, err @@ -88,11 +87,10 @@ func pluginFeature(info, option map[string]*structpb.Value) (sdk.CallResponse, e } ret := sdk.CallResponse{ - FuncName: info["execute_method"].GetStringValue(), - Message: message, - Severity: severity, - State: state, - AlertTypes: []pluginpb.ALERT_TYPE{pluginpb.ALERT_TYPE_DISCORD}, + FuncName: info["execute_method"].GetStringValue(), + Message: message, + Severity: severity, + State: state, } return ret, nil diff --git a/plugins/disk_monitor/main.go b/plugins/disk_monitor/main.go index 3907c55..d1a7235 100644 --- a/plugins/disk_monitor/main.go +++ b/plugins/disk_monitor/main.go @@ -87,11 +87,10 @@ func pluginFeature(info, option map[string]*structpb.Value) (sdk.CallResponse, e if err != nil { message = fmt.Sprint("failed to get disk usage on ", path) ret := sdk.CallResponse{ - FuncName: info["execute_method"].GetStringValue(), - Message: message, - Severity: pluginpb.SEVERITY_CRITICAL, - State: pluginpb.STATE_FAILURE, - AlertTypes: []pluginpb.ALERT_TYPE{pluginpb.ALERT_TYPE_DISCORD}, + FuncName: info["execute_method"].GetStringValue(), + Message: message, + Severity: pluginpb.SEVERITY_CRITICAL, + State: pluginpb.STATE_FAILURE, } return ret, err @@ -133,11 +132,10 @@ func pluginFeature(info, option map[string]*structpb.Value) (sdk.CallResponse, e log.Debug().Str("module", "plugin").Msgf("severity : %s, state : %s, message : %s", severity.String(), state.String(), message) ret := sdk.CallResponse{ - FuncName: info["execute_method"].GetStringValue(), - Message: message, - Severity: severity, - State: state, - AlertTypes: []pluginpb.ALERT_TYPE{pluginpb.ALERT_TYPE_DISCORD}, + FuncName: info["execute_method"].GetStringValue(), + Message: message, + Severity: severity, + State: state, } return ret, nil diff --git a/plugins/mem_monitor/main.go b/plugins/mem_monitor/main.go index 5685839..fbe6997 100644 --- a/plugins/mem_monitor/main.go +++ b/plugins/mem_monitor/main.go @@ -56,11 +56,10 @@ func pluginFeature(info, option map[string]*structpb.Value) (sdk.CallResponse, e v, err := mem.VirtualMemory() if err != nil { ret := sdk.CallResponse{ - FuncName: info["execute_method"].GetStringValue(), - Message: "failed to get memory usage", - Severity: pluginpb.SEVERITY_CRITICAL, - State: pluginpb.STATE_FAILURE, - AlertTypes: []pluginpb.ALERT_TYPE{pluginpb.ALERT_TYPE_DISCORD}, + FuncName: info["execute_method"].GetStringValue(), + Message: "failed to get memory usage", + Severity: pluginpb.SEVERITY_CRITICAL, + State: pluginpb.STATE_FAILURE, } return ret, err @@ -83,11 +82,10 @@ func pluginFeature(info, option map[string]*structpb.Value) (sdk.CallResponse, e } ret := sdk.CallResponse{ - FuncName: info["execute_method"].GetStringValue(), - Message: message, - Severity: severity, - State: state, - AlertTypes: []pluginpb.ALERT_TYPE{pluginpb.ALERT_TYPE_DISCORD}, + FuncName: info["execute_method"].GetStringValue(), + Message: message, + Severity: severity, + State: state, } return ret, nil diff --git a/plugins/net_monitor/main.go b/plugins/net_monitor/main.go index ee67138..48fd60b 100644 --- a/plugins/net_monitor/main.go +++ b/plugins/net_monitor/main.go @@ -198,11 +198,10 @@ func pluginFeature(info, option map[string]*structpb.Value) (sdk.CallResponse, e } ret := sdk.CallResponse{ - FuncName: info["execute_method"].GetStringValue(), - Message: message, - Severity: severityToSend, - State: state, - AlertTypes: []pluginpb.ALERT_TYPE{pluginpb.ALERT_TYPE_DISCORD}, + FuncName: info["execute_method"].GetStringValue(), + Message: message, + Severity: severityToSend, + State: state, } return ret, nil