From 2b3e7cf0e8ba21e400df4abf7efc00bd709edbe9 Mon Sep 17 00:00:00 2001 From: mikameyer Date: Thu, 4 Feb 2021 11:29:12 +0100 Subject: [PATCH 1/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1eaaa4a..01d4cff 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/inexio/thola)](https://goreportcard.com/report/github.com/inexio/thola) [![GitHub code style](https://img.shields.io/badge/code%20style-uber--go-brightgreen)](https://github.com/uber-go/guide/blob/master/style.md) [![GitHub license](https://img.shields.io/badge/license-BSD-blue.svg)](https://github.com/inexio/thola/blob/main/LICENSE) -![GitHub branch checks state](https://img.shields.io/github/checks-status/inexio/thola/main) +[![GitHub branch checks state](https://img.shields.io/github/checks-status/inexio/thola/main)](https://github.com/inexio/thola/actions) [![GoDoc doc](https://img.shields.io/badge/docs-online-brightgreen)](https://docs.thola.io) ## Description From fb169fa15bc971109f277b460d00441e2bcba071 Mon Sep 17 00:00:00 2001 From: mikameyer Date: Thu, 4 Feb 2021 12:20:47 +0100 Subject: [PATCH 2/9] fix "data race" ;) --- api/request_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/request_handler.go b/api/request_handler.go index c0466ab..f80b5cd 100644 --- a/api/request_handler.go +++ b/api/request_handler.go @@ -586,7 +586,7 @@ func StartAPI() { ctx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - if err = e.Shutdown(ctx); err != nil { + if err := e.Shutdown(ctx); err != nil { log.Fatal().Err(err).Msg("shutting down the server failed") } } From 758544f1a769d465c10988a095385415a911b638 Mon Sep 17 00:00:00 2001 From: mikameyer Date: Sat, 6 Feb 2021 17:11:02 +0100 Subject: [PATCH 3/9] added bulk snmp walks --- core/network/snmp_client.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/network/snmp_client.go b/core/network/snmp_client.go index fe25e4c..84a4f33 100644 --- a/core/network/snmp_client.go +++ b/core/network/snmp_client.go @@ -268,7 +268,14 @@ func (s *SNMPClient) SNMPGet(ctx context.Context, oid ...string) ([]SNMPResponse // SNMPWalk sends a snmpwalk request to the specified oid. func (s *SNMPClient) SNMPWalk(ctx context.Context, oid string) ([]SNMPResponse, error) { s.client.Context = ctx - response, err := s.client.WalkAll(oid) + + var response []gosnmp.SnmpPDU + var err error + if s.client.Version == gosnmp.Version1 { + response, err = s.client.WalkAll(oid) + } else { + response, err = s.client.BulkWalkAll(oid) + } if err != nil { return nil, errors.Wrap(err, "snmpwalk all failed") } From 62bda18c8be7bffc5feee94282b693e89090f01b Mon Sep 17 00:00:00 2001 From: babos77 Date: Mon, 8 Feb 2021 13:06:39 +0100 Subject: [PATCH 4/9] also check system redundancy in check sbc --- core/request/check_sbc_request_process.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/request/check_sbc_request_process.go b/core/request/check_sbc_request_process.go index b770a8f..00f9421 100644 --- a/core/request/check_sbc_request_process.go +++ b/core/request/check_sbc_request_process.go @@ -56,6 +56,15 @@ func (r *CheckSBCRequest) process(ctx context.Context) (Response, error) { } } + if sbc.SystemRedundancy != nil { + err = r.mon.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("system_redundancy", *sbc.LicenseCapacity, "")) + if r.mon.UpdateStatusOnError(err, monitoringplugin.UNKNOWN, "error while adding performance data point", true) { + return &CheckResponse{r.mon.GetInfo()}, nil + } + + r.mon.UpdateStatusIf(*sbc.SystemRedundancy != 2 && *sbc.SystemRedundancy != 3, monitoringplugin.CRITICAL, "system redundancy is critical") + } + for _, agent := range sbc.Agents { if agent.CurrentActiveSessionsInbound != nil { p := monitoringplugin.NewPerformanceDataPoint("current_active_sessions_inbound", *agent.CurrentActiveSessionsInbound, "").SetLabel(agent.Hostname) From 803ecaa0c6a6c9357e1a8ea6af34b299450d2cf5 Mon Sep 17 00:00:00 2001 From: babos77 Date: Mon, 8 Feb 2021 13:46:06 +0100 Subject: [PATCH 5/9] update go-monitoringplugin --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index b934f5e..9474e10 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/google/go-cmp v0.5.4 github.com/gosnmp/gosnmp v1.29.0 github.com/huandu/go-sqlbuilder v1.8.0 - github.com/inexio/go-monitoringplugin v0.0.0-20201117085742-ec06ef4904fe + github.com/inexio/go-monitoringplugin v0.0.0-20210208120438-565e33bbd7ca github.com/jmoiron/sqlx v1.2.0 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect diff --git a/go.sum b/go.sum index a702106..8d95b70 100644 --- a/go.sum +++ b/go.sum @@ -163,6 +163,8 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inexio/go-monitoringplugin v0.0.0-20201117085742-ec06ef4904fe h1:08N/oNUAKUjMFb406F4mcJUZwZsWy9NyKrpauWgGfyU= github.com/inexio/go-monitoringplugin v0.0.0-20201117085742-ec06ef4904fe/go.mod h1:kzHRJGZ2iE/0IElB4NYI38h3h0HM5wqTTH7KyUCjkM8= +github.com/inexio/go-monitoringplugin v0.0.0-20210208120438-565e33bbd7ca h1:l/Xxm7EQoxPGHT3v23UXLC2AuUvh87QRWBz1Vj+lVYI= +github.com/inexio/go-monitoringplugin v0.0.0-20210208120438-565e33bbd7ca/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= From e86cf014c24fb9e14a02e70c0ebfed4072ddd636 Mon Sep 17 00:00:00 2001 From: TheFireMike Date: Mon, 8 Feb 2021 14:10:32 +0100 Subject: [PATCH 6/9] style fix --- api/request_handler.go | 3 ++- go.mod | 2 +- go.sum | 6 ++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/api/request_handler.go b/api/request_handler.go index f80b5cd..1d9a2ac 100644 --- a/api/request_handler.go +++ b/api/request_handler.go @@ -556,6 +556,7 @@ func StartAPI() { // Start server go func() { + var err error if viper.GetString("api.certfile") != "" && viper.GetString("api.keyfile") != "" { err = e.StartTLS(":"+viper.GetString("api.port"), viper.GetString("api.certfile"), viper.GetString("api.keyfile")) } else { @@ -586,7 +587,7 @@ func StartAPI() { ctx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - if err := e.Shutdown(ctx); err != nil { + if err = e.Shutdown(ctx); err != nil { log.Fatal().Err(err).Msg("shutting down the server failed") } } diff --git a/go.mod b/go.mod index 9474e10..e69a5db 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/google/go-cmp v0.5.4 github.com/gosnmp/gosnmp v1.29.0 github.com/huandu/go-sqlbuilder v1.8.0 - github.com/inexio/go-monitoringplugin v0.0.0-20210208120438-565e33bbd7ca + github.com/inexio/go-monitoringplugin v1.0.0 github.com/jmoiron/sqlx v1.2.0 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect diff --git a/go.sum b/go.sum index 8d95b70..8314d90 100644 --- a/go.sum +++ b/go.sum @@ -161,10 +161,8 @@ github.com/huandu/go-sqlbuilder v1.8.0 h1:1KP21dzROt03II0aoX/rD2Y6TX1VCIixSX5mvk github.com/huandu/go-sqlbuilder v1.8.0/go.mod h1:cM38aLPrMXaGxsUkHFh1e2skthPnQRPK7h8//X5LQMc= 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 v0.0.0-20201117085742-ec06ef4904fe h1:08N/oNUAKUjMFb406F4mcJUZwZsWy9NyKrpauWgGfyU= -github.com/inexio/go-monitoringplugin v0.0.0-20201117085742-ec06ef4904fe/go.mod h1:kzHRJGZ2iE/0IElB4NYI38h3h0HM5wqTTH7KyUCjkM8= -github.com/inexio/go-monitoringplugin v0.0.0-20210208120438-565e33bbd7ca h1:l/Xxm7EQoxPGHT3v23UXLC2AuUvh87QRWBz1Vj+lVYI= -github.com/inexio/go-monitoringplugin v0.0.0-20210208120438-565e33bbd7ca/go.mod h1:kzHRJGZ2iE/0IElB4NYI38h3h0HM5wqTTH7KyUCjkM8= +github.com/inexio/go-monitoringplugin v1.0.0 h1:aOGOF+vBEwfQNnzFPWJKFWyY3HwV3zzd1HbUljm3Saw= +github.com/inexio/go-monitoringplugin v1.0.0/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= From 7f37ab78fba30ec0a64395e5afa36546bbc536ad Mon Sep 17 00:00:00 2001 From: babos77 Date: Mon, 8 Feb 2021 14:16:40 +0100 Subject: [PATCH 7/9] sbc in readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 01d4cff..596f839 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Thola currently has three main modes of operation with various subcommands: - `read cpu-load` returns the current cpu load of all CPUs. - `read memory-usage` reads out the current memory usage. - `read ups` outputs the special values of a UPS device. + - `read sbc` reads out sbc specific information. - `check` performs checks that can be used in monitoring systems. Output is by default in check plugin format. - `check identify` compares the device properties with given expectations. - `check snmp` checks SNMP reachability. @@ -46,6 +47,7 @@ Thola currently has three main modes of operation with various subcommands: - `check memory-usage` checks the current memory usage against given thresholds. - `check ups` checks if a UPS device has its main voltage applied and outputs additional performance data like battery capacity or current load, and compares them to optionally given thresholds. - `check thola-server` checks reachability of a Thola API. + - `check sbc` checks an SBC device and outputs metrics for each realm and agent as performance data. More features are coming soon: From 1d6a3c6315d96a98c0043aa36716dd9e8195f478 Mon Sep 17 00:00:00 2001 From: babos77 Date: Mon, 8 Feb 2021 14:17:29 +0100 Subject: [PATCH 8/9] set version to v0.2.0 --- doc/doc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/doc.go b/doc/doc.go index 8518225..8fc061e 100644 --- a/doc/doc.go +++ b/doc/doc.go @@ -27,4 +27,4 @@ // swagger:meta package doc -const Version = "v0.1.4" +const Version = "v0.2.0" From 77f872f2f3e547d91a16e7c2f423e4ffe37b546e Mon Sep 17 00:00:00 2001 From: Mika Meyer <51948405+TheFireMike@users.noreply.github.com> Date: Mon, 8 Feb 2021 14:20:12 +0100 Subject: [PATCH 9/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 596f839..c71bc1a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Thola currently has three main modes of operation with various subcommands: - `read cpu-load` returns the current cpu load of all CPUs. - `read memory-usage` reads out the current memory usage. - `read ups` outputs the special values of a UPS device. - - `read sbc` reads out sbc specific information. + - `read sbc` reads out SBC specific information. - `check` performs checks that can be used in monitoring systems. Output is by default in check plugin format. - `check identify` compares the device properties with given expectations. - `check snmp` checks SNMP reachability.