Skip to content

Commit

Permalink
Merge pull request #14 from NETWAYS/chore/cleanup
Browse files Browse the repository at this point in the history
Repository Cleanup and Normalization
  • Loading branch information
martialblog authored Aug 23, 2024
2 parents 6c55664 + cb71137 commit 343b02b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 68 deletions.
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@v6
with:
version: v1.51
version: v1.54
15 changes: 12 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ before:
hooks:
- go mod download
builds:
- id: netways-ido-cleanup
binary: netways-ido-cleanup
env:
- env:
- CGO_ENABLED=0
goarch:
- amd64
Expand All @@ -18,7 +16,18 @@ builds:
-X main.commit={{.Commit}}
-X main.date={{.CommitDate}}
release:
draft: true
github:
owner: NETWAYS
name: netways-ido-cleanup
archives:
- format: binary
name_template: >-
{{ .ProjectName }}_{{ .Tag }}_
{{- if eq .Os "linux" }}Linux{{ end }}
{{- if eq .Os "windows" }}Windows{{ end }}
{{- if eq .Os "darwin" }}Darwin{{ end }}
{{- if eq .Arch "amd64" }}_x86_64{{ end }}
checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.PHONY: test coverage lint vet

build:
export CGO_ENABLED=0; go build
lint:
go fmt $(go list ./... | grep -v /vendor/)
vet:
go vet $(go list ./... | grep -v /vendor/)
test:
go test -v -cover ./...
coverage:
go test -v -cover -coverprofile=coverage.out ./... &&\
go tool cover -html=coverage.out -o coverage.html
24 changes: 7 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
In larger installations of Icinga 2, [IDO DB cleanup] can become a challenge. Those cleanup queries are scheduled in
between any other INSERT or UPDATE query.

This can cause 2 problems:
This can cause two problems:
- Regular updates are deferred when cleanup is running
- Not all tables are indexed correctly, so cleanup can take longer

Expand Down Expand Up @@ -72,19 +72,19 @@ Usage of ido-cleanup:

```
$ ido-cleanup --once
INFO[0000] starting ido-cleanup
INFO[0000] starting ido-cleanup
INFO[0000] deleted rows oldest="2019-03-01 11:26:44 +0000 UTC" rows=10000 table=commenthistory took=72.647379ms
INFO[0000] deleted rows oldest="2019-01-21 19:35:14 +0000 UTC" rows=6129 table=contactnotifications took=76.247963ms
INFO[0000] deleted rows oldest="2019-02-06 09:42:08 +0000 UTC" rows=209 table=downtimehistory took=3.992535ms
INFO[0000] deleted rows oldest="2019-04-23 07:29:36 +0000 UTC" rows=60 table=eventhandlers took=6.685573ms
INFO[0000] deleted rows oldest="2019-01-21 19:35:14 +0000 UTC" rows=6212 table=notifications took=84.653149ms
INFO[0000] deleted rows oldest="2019-01-20 10:16:30 +0000 UTC" rows=10000 table=statehistory took=135.619702ms
INFO[0000] stopping after one cleanup
INFO[0000] stopping after one cleanup
```

## Missing indices

Not all tables are indexed in a way to support fast deletions.
Not all tables are indexed in a way to support fast deletions.

Please add those indexes to ensure speedy queries.

Expand All @@ -95,19 +95,9 @@ CREATE INDEX idx_contactnotifications_cleanup on icinga_contactnotifications (in

See [Icinga/icinga2#7753](https://github.com/Icinga/icinga2/issues/7753).

## License
# License

Copyright (C) 2021 [NETWAYS GmbH](mailto:[email protected])

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
This library is distributed under the GPL-3.0 license found in the [LICENSE](./LICENSE)
file.
45 changes: 0 additions & 45 deletions docker-compose.yml

This file was deleted.

2 changes: 0 additions & 2 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package main

import "fmt"

// nolint: gochecknoglobals
var (
// These get filled at build time with the proper vaules
version = "development"
commit = "HEAD"
date = "latest"
)

//goland:noinspection GoBoolExpressions
func buildVersion() string {
result := version

Expand Down

0 comments on commit 343b02b

Please sign in to comment.