Skip to content

Commit

Permalink
Merge pull request #73 from inexio/pre-release
Browse files Browse the repository at this point in the history
Pre release
  • Loading branch information
TheFireMike authored Sep 10, 2021
2 parents 7417f1f + 65f9c2c commit 632a7c8
Show file tree
Hide file tree
Showing 11 changed files with 2,615 additions and 2,627 deletions.
6 changes: 0 additions & 6 deletions cmd/check_interface_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ func init() {
checkCMD.AddCommand(checkInterfaceMetricsCMD)

checkInterfaceMetricsCMD.Flags().Bool("print-interfaces", false, "Print interfaces to plugin output")
checkInterfaceMetricsCMD.Flags().Bool("print-interfaces-csv", false, "Print interfaces to plugin output as CSV")
checkInterfaceMetricsCMD.Flags().Bool("snmp-gets-instead-of-walk", false, "Use SNMP Gets instead of Walks")
checkInterfaceMetricsCMD.Flags().String("ifDescr-regex", "", "Apply a regex on the ifDescr of the interfaces. Use it together with the 'ifDescr-regex-replace' flag")
checkInterfaceMetricsCMD.Flags().String("ifDescr-regex-replace", "", "Apply a regex on the ifDescr of the interfaces. Use it together with the 'ifDescr-regex' flag")
Expand All @@ -30,10 +29,6 @@ var checkInterfaceMetricsCMD = &cobra.Command{
if err != nil {
log.Fatal().Err(err).Msg("print-interfaces needs to be a boolean")
}
printInterfacesCSV, err := cmd.Flags().GetBool("print-interfaces-csv")
if err != nil {
log.Fatal().Err(err).Msg("print-interfaces-csv needs to be a boolean")
}
snmpGetsInsteadOfWalk, err := cmd.Flags().GetBool("snmp-gets-instead-of-walk")
if err != nil {
log.Fatal().Err(err).Msg("snmp-gets-instead-of-walk needs to be a boolean")
Expand Down Expand Up @@ -63,7 +58,6 @@ var checkInterfaceMetricsCMD = &cobra.Command{
r := request.CheckInterfaceMetricsRequest{
CheckDeviceRequest: getCheckDeviceRequest(args[0]),
PrintInterfaces: printInterfaces,
PrintInterfacesCSV: printInterfacesCSV,
IfDescrRegex: utility.IfThenElse(cmd.Flags().Changed("ifDescr-regex"), &ifDescrRegex, nullString).(*string),
IfDescrRegexReplace: utility.IfThenElse(cmd.Flags().Changed("ifDescr-regex-replace"), &ifDescrRegexReplace, nullString).(*string),
IfTypeFilter: ifTypeFilter,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/gomodule/redigo v1.8.4
github.com/google/go-cmp v0.5.4
github.com/gosnmp/gosnmp v1.30.0
github.com/inexio/go-monitoringplugin v1.0.8
github.com/inexio/go-monitoringplugin v1.0.10
github.com/jmoiron/sqlx v1.2.0
github.com/labstack/echo/v4 v4.2.1
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/J
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inexio/go-monitoringplugin v1.0.8 h1:MpfLgxrXzQNz6uYYph+I/voatFQ0g4VBDeO/6ghZtDs=
github.com/inexio/go-monitoringplugin v1.0.8/go.mod h1:kzHRJGZ2iE/0IElB4NYI38h3h0HM5wqTTH7KyUCjkM8=
github.com/inexio/go-monitoringplugin v1.0.10 h1:mUGPvmalnB06NwgwZSbyvGLpvqZLU+Eyzj40zSGh9J4=
github.com/inexio/go-monitoringplugin v1.0.10/go.mod h1:kzHRJGZ2iE/0IElB4NYI38h3h0HM5wqTTH7KyUCjkM8=
github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
Expand Down
1 change: 0 additions & 1 deletion internal/request/check_interface_metrics_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
// swagger:model
type CheckInterfaceMetricsRequest struct {
PrintInterfaces bool `yaml:"print_interfaces" json:"print_interfaces" xml:"print_interfaces"`
PrintInterfacesCSV bool `yaml:"print_interfaces_csv" json:"print_interfaces_csv" xml:"print_interfaces_csv"`
IfDescrRegex *string `yaml:"ifDescr_regex" json:"ifDescr_regex" xml:"ifDescr_regex"`
ifDescrRegex *regexp.Regexp
IfDescrRegexReplace *string `yaml:"ifDescr_regex_replace" json:"ifDescr_regex_replace" xml:"ifDescr_regex_replace"`
Expand Down
8 changes: 1 addition & 7 deletions internal/request/check_interface_metrics_request_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,7 @@ func (r *CheckInterfaceMetricsRequest) process(ctx context.Context) (Response, e
interfaceOutput = append(interfaceOutput, currentOutput)
}
if len(interfaceOutput) > 0 {
var output []byte
if r.PrintInterfacesCSV {
output, err = parser.Parse(interfaceOutput, "csv")

} else {
output, err = parser.Parse(interfaceOutput, "json")
}
output, err := parser.Parse(interfaceOutput, "csv")
if r.mon.UpdateStatusOnError(err, monitoringplugin.UNKNOWN, "error while marshalling output", true) {
r.mon.PrintPerformanceData(false)
return &CheckResponse{r.mon.GetInfo()}, nil
Expand Down
1 change: 1 addition & 0 deletions internal/request/check_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type CheckRequest struct {

func (r *CheckRequest) init() {
r.mon = monitoringplugin.NewResponse("checked")
_ = r.mon.SetInvalidCharacterBehavior(monitoringplugin.InvalidCharacterReplaceWithErrorAndSetUNKNOWN, "")
r.mon.PrintPerformanceData(r.PrintPerformanceData)
r.mon.SetPerformanceDataJSONLabel(r.JSONMetrics)
}
Expand Down
Loading

0 comments on commit 632a7c8

Please sign in to comment.