Skip to content

Commit

Permalink
Remove metrics, can be access via the /metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
elfranne committed Nov 27, 2023
1 parent dd9555e commit 02760c3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/elfranne/sensu-etcd-check
go 1.19

require (
github.com/Showmax/go-fqdn v1.0.0
github.com/sensu/core/v2 v2.19.0
github.com/sensu/sensu-plugin-sdk v0.18.0
go.etcd.io/etcd/client/v3 v3.5.10
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Showmax/go-fqdn v1.0.0 h1:0rG5IbmVliNT5O19Mfuvna9LL7zlHyRfsSvBPZmF9tM=
github.com/Showmax/go-fqdn v1.0.0/go.mod h1:SfrFBzmDCtCGrnHhoDjuvFnKsWjEQX/Q9ARZvOrJAko=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
Expand Down
28 changes: 2 additions & 26 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"time"

"github.com/Showmax/go-fqdn"
corev2 "github.com/sensu/core/v2"
"github.com/sensu/sensu-plugin-sdk/sensu"
clientv3 "go.etcd.io/etcd/client/v3"
Expand All @@ -16,7 +15,6 @@ type Config struct {
sensu.PluginConfig
Url []string
Size int64
Scheme string
}

var (
Expand All @@ -43,13 +41,6 @@ var (
Usage: "Maximum aatabase Size",
Value: &plugin.Size,
},
&sensu.PluginConfigOption[string]{
Path: "scheme",
Argument: "scheme",
Shorthand: "s",
Usage: "Scheme to prepend metric",
Value: &plugin.Scheme,
},
}
)

Expand All @@ -62,18 +53,6 @@ func checkArgs(event *corev2.Event) (int, error) {
return sensu.CheckStateOK, nil
}

func GetScheme() string {
if len(plugin.Scheme) > 0 {
return plugin.Scheme
} else {
realfqdn, err := fqdn.FqdnHostname()
if err != nil {
fmt.Printf("failed to get FQDN: %s", err)
}
return realfqdn
}
}

func executeCheck(event *corev2.Event) (int, error) {

cli, err := clientv3.New(clientv3.Config{
Expand All @@ -92,13 +71,10 @@ func executeCheck(event *corev2.Event) (int, error) {
return sensu.CheckStateCritical, nil
}

// print metrics
fmt.Printf("etcd_dbsize{hostname=\"%s\"} %d %d\n", GetScheme(), status.DbSize, time.Now().Unix())

if status.DbSize > plugin.Size {
fmt.Printf("# Database exeeding set limit (%d): %d\n", plugin.Size, status.DbSize)
fmt.Printf("Database exeeding set limit (%d): %d\n", plugin.Size, status.DbSize)
return sensu.CheckStateCritical, nil
}

fmt.Printf("Database is within size limit (%d): %d\n", plugin.Size, status.DbSize)
return sensu.CheckStateOK, nil
}

0 comments on commit 02760c3

Please sign in to comment.