Skip to content

Commit e26ecbc

Browse files
authored
Merge pull request #1 from NETWAYS/chore/release-prep
Preparations for Release
2 parents ad47c40 + aa9336e commit e26ecbc

File tree

12 files changed

+30
-60
lines changed

12 files changed

+30
-60
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Go
2020
uses: actions/setup-go@v4
2121
with:
22-
go-version: 1.20
22+
go-version: 1.21
2323

2424
- name: Test
2525
run: go test -v ./...

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ jobs:
1616

1717
- name: golangci-lint
1818
uses: golangci/golangci-lint-action@v3
19+
with:
20+
version: v1.54

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ linters:
1616
- forbidigo
1717
- gci
1818
- lll
19+
- godot
1920
- gofumpt
2021
- gochecknoinits
2122
- gochecknoglobals

cmd/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/NETWAYS/go-check"
1616
)
1717

18+
// Central Configuration for CLI
1819
type Config struct {
1920
BasicAuth string
2021
Hostname string
@@ -85,6 +86,7 @@ func (c *Config) NewClient() *client.Client {
8586
return client.NewClient(u.String(), c.Token, c.Organization, rt)
8687
}
8788

89+
// Central timeout configuration for anything that needs it
8890
func (c *Config) timeoutContext() (context.Context, func()) {
8991
return context.WithTimeout(context.Background(), 10*time.Second)
9092
}

cmd/health.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ API translation:
5252
err error
5353
)
5454

55+
// Uses the major version to determine which API to call.
56+
// Can be extended in the future.
5557
switch apiversion.MajorVersion {
5658
case 1:
5759
health, err = checkV2Health(c.URL, c.Token, c.Client)
@@ -65,6 +67,7 @@ API translation:
6567
check.ExitError(err)
6668
}
6769

70+
// Is this flexible enough? Might be better to use strings.Contains.
6871
switch health {
6972
case "pass":
7073
rc = 0

cmd/query.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ var queryCmd = &cobra.Command{
195195
check.ExitError(versionErr)
196196
}
197197

198+
// Uses the major version to determine which API to call.
199+
// Can be extended in the future.
198200
switch apiversion.MajorVersion {
199201
case 2:
200202
queryFluxV2(fluxQuery, c.URL, c.Organization, c.Token, c.Client)

contrib/icinga2-commands.conf

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ object CheckCommand "influxdb" {
2727
order = 1
2828
description = "Timeout for the check"
2929
}
30-
"--tls" = {
30+
"--secure" = {
3131
set_if = "$influxdb_tls$"
3232
order = 1
33-
description = "Use secure connection"
33+
description = "Use a HTTPS connection"
3434
}
3535
"--insecure" = {
3636
set_if = "$influxdb_insecure$"
3737
order = 1
38-
description = "Allow use of self signed certificates when using SSL"
38+
description = "Skip the verification of the TLS certificate"
3939
}
4040
"--token" = {
4141
value = "$influxdb_token$"
4242
required = true
4343
order = 1
44-
description = "The token which allows access to the API"
44+
description = "Token for server authentication"
4545
}
4646
"--org" = {
4747
value = "$influxdb_org$"
@@ -57,59 +57,22 @@ object CheckCommand "influxdb" {
5757
set_if = {{ macro("$influxdb_query$") == true }}
5858
description = "The bucket where time series data is stored"
5959
}
60-
"--start" = {
61-
value = "$influxdb_start$"
62-
order = 4
63-
description = "Specifies a start time range for your query"
64-
}
65-
"--end" = {
66-
value = "$influxdb_end$"
67-
order = 4
68-
description = "Specifies the end of a time range for your query"
69-
}
70-
"--measurement" = {
71-
value = "$influxdb_measurement$"
72-
order = 5
73-
description = "The data stored in the associated fields, e.g. 'disk'"
74-
}
75-
"--field" = {
76-
value = "$influxdb_field$"
77-
order = 6
78-
description = "The key-value pair that records metadata and the actual data value"
79-
}
80-
"--filter" = {
81-
value = "$influxdb_filter$"
82-
order = 7
83-
repeat_key = true
84-
description = "Add a key=value filter to the query, e.g. 'hostname=example.com'"
85-
}
86-
"--raw-filter" = {
87-
value = "$influxdb_raw_filter$"
88-
order = 8
89-
repeat_key = true
90-
description = "A fully customizable filter which will be added to the query."
91-
}
92-
"--aggregation" = {
93-
value = "$influxdb_aggregation$"
94-
order = 9
95-
description = "Function that returns an aggregated value across a set of points"
96-
}
97-
"--raw-query" = {
98-
value = "$influxdb_raw_query$"
99-
description = "An InfluxQL query which will be performed. Note: Only ONE value result will be evaluated"
100-
}
101-
"--value-by-key" = {
60+
"--flux-query" = {
61+
value = "$influxdb_flux_query$"
62+
description = "Flux script as string"
63+
}
64+
"--flux-file" = {
65+
value = "$influxdb_flux_string$"
66+
description = "Path to flux file"
67+
}
68+
"--perfdata-label-by-key" = {
10269
value = "$influxdb_value_by_key$"
10370
description = "Sets the label for the perfdata of the given column key for the record"
10471
}
10572
"--perfdata-label" = {
10673
value = "$influxdb_perfdata_label$"
10774
description = "Sets as custom label for the perfdata"
10875
}
109-
"--verbose" = {
110-
set_if = "$influxdb_verbose$"
111-
description = "Display verbose output"
112-
}
11376
"--critical" = {
11477
value = "$influxdb_critical$"
11578
description = "The critical threshold for a value"

contrib/icinga2-service-example.conf

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ apply Service "influx_query" {
77
vars.influxdb_token = "example_token"
88
vars.influxdb_bucket = "example_bucket"
99
vars.influxdb_org = "example_org"
10-
vars.influxdb_start = "-48h"
11-
vars.influxdb_measurement = "example_measurement"
12-
vars.influxdb_field = "value"
13-
vars.influxdb_filter = [ "metric=example_metric" ]
14-
vars.influxdb_raw_filter = [ "group(columns: [\"hostname\"], mode: \"by\")", "aggregateWindow(every: 30m, fn: sum)" ]
15-
vars.influxdb_aggregation = "last"
16-
vars.influxdb_value_by_key = "hostname"
10+
vars.influxdb_flux_query = "flux..."
1711
vars.influxdb_insecure = true
1812
vars.influxdb_critical = 100
1913
vars.influxdb_warning = 50

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/NETWAYS/check_influxdb
22

3-
go 1.20
3+
go 1.21
44

55
require (
66
github.com/NETWAYS/go-check v0.5.0

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu
2020
github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y=
2121
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
2222
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
23+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
2324
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
2425
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
2526
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=

0 commit comments

Comments
 (0)