Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add synced config to Icinga 2 module #117

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.54
version: v1.56.2
17 changes: 13 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,20 @@ linters:
- tagliatelle
- varnamelen
- wrapcheck
- golint # deprecated
- nosnakecase # deprecated
- scopelint # deprecated
- ifshort # deprecated
- interfacer # deprecated
- structcheck # deprecated
- maligned # deprecated
- varcheck # deprecated
- deadcode # deprecated
- goconst # not needed in our case
- perfsprint # not needed in our case
linters-settings:
funlen:
ignore-comments: true
lines: 75
estif:
min-complexity: 4
maligned:
suggest-new: true
nestif:
min-complexity: 5
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/tools v0.19.0 // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
1 change: 1 addition & 0 deletions internal/obfuscate/obfuscate.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func (o *Obfuscator) ProcessReader(r io.Reader) (count uint, out bytes.Buffer, e
ending = string(r) + ending
return true
}

return false
})

Expand Down
19 changes: 11 additions & 8 deletions modules/icinga2/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ModuleName = "icinga2"

var files = []string{
"/etc/icinga2",
"/var/lib/icinga2/api/packages/_api/active-stage",
}

var pluginFiles = []string{
Expand All @@ -35,14 +36,16 @@ var detailedFiles = []string{
}

var commands = map[string][]string{
"version.txt": {"icinga2", "-V"},
"config-check.txt": {"icinga2", "daemon", "-C"},
"objects-zones.txt": {"icinga2", "object", "list", "--type", "Zone"},
"objects-endpoints.txt": {"icinga2", "object", "list", "--type", "Endpoint"},
"variables.txt": {"icinga2", "variable", "list"},
"features.txt": {"icinga2", "feature", "list"},
"user-icinga.txt": {"id", "icinga"},
"user-nagios.txt": {"id", "nagios"},
"version.txt": {"icinga2", "-V"},
"config-check.txt": {"icinga2", "daemon", "-C"},
"objects-zones.txt": {"icinga2", "object", "list", "--type", "Zone"},
"objects-endpoints.txt": {"icinga2", "object", "list", "--type", "Endpoint"},
"variables.txt": {"icinga2", "variable", "list"},
"features.txt": {"icinga2", "feature", "list"},
"user-icinga.txt": {"id", "icinga"},
"user-nagios.txt": {"id", "nagios"},
"icinga2-api-stage-directories.txt": {"ls", "-ld", "/var/lib/icinga2/api/packages/_api/*/"},
"director-api-stage-directories.txt": {"ls", "-ld", "/var/lib/icinga2/api/packages/director/*/"},
}

var detailedCommands = map[string][]string{
Expand Down
8 changes: 8 additions & 0 deletions modules/icingadirector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const (
InstallationPath = "/usr/share/icingaweb2/modules/director"
)

var files = []string{
"/var/lib/icinga2/api/packages/director/active-stage",
}

var commands = map[string][]string{
"health.txt": {"icingacli", "director", "health"},
"user-icingadirector.txt": {"id", "icingadirector"},
Expand Down Expand Up @@ -47,6 +51,10 @@ func Collect(c *collection.Collection) {

// TODO: more infos on modules, GIT details

for _, file := range files {
c.AddFiles(ModuleName, file)
}

for name, cmd := range commands {
c.AddCommandOutput(filepath.Join(ModuleName, name), cmd[0], cmd[1:]...)
}
Expand Down