chore: rename project

This commit is contained in:
Emmanuel BENOîT 2024-07-19 14:55:23 +02:00
parent 09d39b2271
commit 9a1144d112
Signed by: Emmanuel BENOîT
SSH key fingerprint: SHA256:l7PFUUF5TCDsvYeQC9OnTNz08dFY7Fvf4Hv3neIqYpg
12 changed files with 61 additions and 47 deletions

View file

@ -23,7 +23,7 @@ jobs:
with: with:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
- name: Build plugins - name: Build plugins for all architectures
run: | run: |
make build-cross make build-cross

View file

@ -1,4 +1,4 @@
BINNAME = go-monitoring BINNAME = gomonop
BINDIR = $(CURDIR)/bin BINDIR = $(CURDIR)/bin
TARGETS = linux/amd64 linux/386 linux/arm linux/arm64 TARGETS = linux/amd64 linux/386 linux/arm linux/arm64
@ -17,10 +17,10 @@ BINARY_VERSION ?= $(GIT_TAG)
LDFLAGS += -w -s LDFLAGS += -w -s
ifneq ($(BINARY_VERSION),) ifneq ($(BINARY_VERSION),)
LDFLAGS += -X nocternity.net/go-monitoring/pkg/version.version=${BINARY_VERSION} LDFLAGS += -X nocternity.net/gomonop/pkg/version.version=${BINARY_VERSION}
endif endif
LDFLAGS += -X nocternity.net/go-monitoring/pkg/version.commit=${GIT_COMMIT} LDFLAGS += -X nocternity.net/gomonop/pkg/version.commit=${GIT_COMMIT}
LDFLAGS += -X nocternity.net/go-monitoring/pkg/version.status=${GIT_STATUS} LDFLAGS += -X nocternity.net/gomonop/pkg/version.status=${GIT_STATUS}
.PHONY: all .PHONY: all
@ -33,15 +33,15 @@ build: build-target symlink
.PHONY: symlink .PHONY: symlink
symlink: symlink:
@ln -sf $(BINDIR)/$(GOOS)/$(GOARCH)/$(BINNAME) $(BINDIR)/$(BINNAME) @ln -sf $(BINDIR)/$(GOOS)-$(GOARCH)/$(BINNAME) $(BINDIR)/$(BINNAME)
.PHONY: build-target .PHONY: build-target
build-target: LDFLAGS += -X nocternity.net/go-monitoring/pkg/version.target=${GOOS}/${GOARCH} build-target: LDFLAGS += -X nocternity.net/gomonop/pkg/version.target=${GOOS}/${GOARCH}
build-target: $(BINDIR)/$(GOOS)/$(GOARCH)/$(BINNAME) build-target: $(BINDIR)/$(GOOS)-$(GOARCH)/$(BINNAME)
$(BINDIR)/$(GOOS)/$(GOARCH)/$(BINNAME): $(SRC) $(BINDIR)/$(GOOS)-$(GOARCH)/$(BINNAME): $(SRC)
@mkdir -p $(BINDIR)/$(GOOS)/$(GOARCH) @mkdir -p $(BINDIR)/$(GOOS)-$(GOARCH)
@CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o $(BINDIR)/$(GOOS)/$(GOARCH)/$(BINNAME) . @CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o $(BINDIR)/$(GOOS)-$(GOARCH)/$(BINNAME) .
.PHONY: test .PHONY: test
test: build test: build

View file

@ -1,16 +1,13 @@
Various monitoring plugins in golang gomonop - Various monitoring plugins in golang
===================================== ==============================================
This repository is meant to host various monitoring plugins for Nagios (or This project is a collection of various monitoring plugins (such as Nagios,
Centreon, or Icinga) written in golang. I will update it as I rewrite my old Centreon, or Icinga) written in golang. All plugins are available through a
shell-based scripts or write new ones. single executable, `gomonop`. The actual plugin can be selected either
by creating a symlink to the main executable with the appropriate name or by
calling the executable directly with the first argument being the name of the
plugin.
Building
---------
Running the `build.sh` bash script will build the plugins for both the `amd64`
and `386` architectures. It will create a `bin/` directory with
architecture-specific subdirectories.
Plugins Plugins
-------- --------
@ -48,4 +45,17 @@ supports the following command-line flags:
* `-r name`/`--rs-hostname name`: the host name or address of the reference * `-r name`/`--rs-hostname name`: the host name or address of the reference
server. server.
* `-p port`/`--rs-port port`: the port to use on the reference server * `-p port`/`--rs-port port`: the port to use on the reference server
(defaults to 53). (defaults to 53).
Building from source
--------------------
The plugin can be built for the current host OS and architecture using
`make build`. The actual executable will be created under the `bin` directory,
in a subdirectory named after the host OS and architecture (e.g.
`bin/linux-amd64`). The executable will be named `gomonop`, and a
symlink to the executable for the host OS and architecture will be created
under the `bin` directory.
It is possible to build for other architectures using `make build-cross`.

View file

@ -1,4 +1,4 @@
package sslcert // import nocternity.net/go-monitoring/cmd/sslcert package sslcert // import nocternity.net/gomonop/cmd/sslcert
import ( import (
"bufio" "bufio"
@ -12,9 +12,9 @@ import (
"strings" "strings"
"time" "time"
"nocternity.net/go-monitoring/pkg/perfdata" "nocternity.net/gomonop/pkg/perfdata"
"nocternity.net/go-monitoring/pkg/plugin" "nocternity.net/gomonop/pkg/plugin"
"nocternity.net/go-monitoring/pkg/program" "nocternity.net/gomonop/pkg/program"
"github.com/karrick/golf" "github.com/karrick/golf"
) )

View file

@ -1,4 +1,4 @@
package zoneserial // import nocternity.net/go-monitoring/cmd/zoneserial package zoneserial // import nocternity.net/gomonop/cmd/zoneserial
import ( import (
"fmt" "fmt"
@ -8,9 +8,9 @@ import (
"strings" "strings"
"time" "time"
"nocternity.net/go-monitoring/pkg/perfdata" "nocternity.net/gomonop/pkg/perfdata"
"nocternity.net/go-monitoring/pkg/plugin" "nocternity.net/gomonop/pkg/plugin"
"nocternity.net/go-monitoring/pkg/program" "nocternity.net/gomonop/pkg/program"
"github.com/karrick/golf" "github.com/karrick/golf"
"github.com/miekg/dns" "github.com/miekg/dns"

2
go.mod
View file

@ -1,4 +1,4 @@
module nocternity.net/go-monitoring module nocternity.net/gomonop
go 1.22 go 1.22

22
main.go
View file

@ -5,10 +5,10 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"nocternity.net/go-monitoring/cmd/sslcert" "nocternity.net/gomonop/cmd/sslcert"
"nocternity.net/go-monitoring/cmd/zoneserial" "nocternity.net/gomonop/cmd/zoneserial"
"nocternity.net/go-monitoring/pkg/program" "nocternity.net/gomonop/pkg/program"
"nocternity.net/go-monitoring/pkg/version" "nocternity.net/gomonop/pkg/version"
) )
var ( var (
@ -30,15 +30,19 @@ func main() {
if builder, ok := programs[ownName]; ok { if builder, ok := programs[ownName]; ok {
program = builder() program = builder()
} else if len(os.Args) < 2 { } else if len(os.Args) < 2 {
exitError("Syntax: %s <program> [arguments]\n %s programs", os.Args[0], os.Args[0]) exitError(
} else if os.Args[1] == "programs" { ""+
fmt.Println("Available programs:") "Syntax: %s <program> [arguments]\n"+
" %s --programs|-p\n"+
" %s --version|-v",
os.Args[0], os.Args[0], os.Args[0])
} else if os.Args[1] == "--programs" || os.Args[1] == "-p" {
for name := range programs { for name := range programs {
fmt.Printf(" %s\n", name) fmt.Println(name)
} }
os.Exit(0) os.Exit(0)
} else if os.Args[1] == "--version" || os.Args[1] == "-v" { } else if os.Args[1] == "--version" || os.Args[1] == "-v" {
fmt.Printf("%s %s\n", ownName, version.Version()) fmt.Printf("gomonop %s\n", version.Version())
os.Exit(0) os.Exit(0)
} else if builder, ok := programs[os.Args[1]]; ok { } else if builder, ok := programs[os.Args[1]]; ok {

View file

@ -1,6 +1,6 @@
// Package `perfdata` provides representations for a monitoring plugin's // Package `perfdata` provides representations for a monitoring plugin's
// performance data. // performance data.
package perfdata // import nocternity.net/go-monitoring/pkg/perfdata package perfdata // import nocternity.net/gomonop/pkg/perfdata
import ( import (
"fmt" "fmt"

View file

@ -1,4 +1,4 @@
package perfdata // import nocternity.net/go-monitoring/pkg/perfdata package perfdata // import nocternity.net/gomonop/pkg/perfdata
import ( import (
"fmt" "fmt"

View file

@ -1,6 +1,6 @@
// Package plugin implements a helper that can be used to implement a Nagios, // Package plugin implements a helper that can be used to implement a Nagios,
// Centreon, Icinga... service monitoring plugin. // Centreon, Icinga... service monitoring plugin.
package plugin // import nocternity.net/go-monitoring/pkg/perfdata package plugin // import nocternity.net/gomonop/pkg/perfdata
import ( import (
"container/list" "container/list"
@ -8,7 +8,7 @@ import (
"os" "os"
"strings" "strings"
"nocternity.net/go-monitoring/pkg/perfdata" "nocternity.net/gomonop/pkg/perfdata"
) )
// Status represents the return status of the monitoring plugin. The // Status represents the return status of the monitoring plugin. The

View file

@ -1,4 +1,4 @@
package program // import nocternity.net/go-monitoring/pkg/program package program // import nocternity.net/gomonop/pkg/program
type Program interface { type Program interface {
CheckArguments() bool CheckArguments() bool

View file

@ -1,4 +1,4 @@
package version // import nocternity.net/go-monitoring/pkg/version package version // import nocternity.net/gomonop/pkg/version
import "fmt" import "fmt"