feat: add the check_output_matches
plugin (#5)
This PR adds the `check_output_matches` plugin, which can be used to count regexp or substring matches from either text files or command outputs and determine the final status based on the amount of matches that were found. Reviewed-on: #5 Co-authored-by: Emmanuel BENOÎT <tseeker@nocternity.net> Co-committed-by: Emmanuel BENOÎT <tseeker@nocternity.net>
This commit is contained in:
parent
9fac656cdf
commit
c46c9d76d9
22 changed files with 1063 additions and 55 deletions
pkg/status
21
pkg/status/status.go
Normal file
21
pkg/status/status.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
// The status package contains the datatype that corresponds to monitoring
|
||||
// plugin status values.
|
||||
package status // import nocternity.net/gomonop/pkg/status
|
||||
|
||||
// Status represents the return status of the monitoring plugin. The
|
||||
// corresponding integer value will be used as the program's exit code,
|
||||
// to be interpreted by the monitoring system.
|
||||
type Status int
|
||||
|
||||
// Plugin exit statuses.
|
||||
const (
|
||||
StatusOK Status = iota
|
||||
StatusWarning
|
||||
StatusCritical
|
||||
StatusUnknown
|
||||
)
|
||||
|
||||
// String representations of the plugin statuses.
|
||||
func (s Status) String() string {
|
||||
return [...]string{"OK", "WARNING", "ERROR", "UNKNOWN"}[s]
|
||||
}
|
26
pkg/status/status_test.go
Normal file
26
pkg/status/status_test.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package status // import nocternity.net/gomonop/pkg/status
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestStatusDefaultOK(t *testing.T) {
|
||||
var s Status
|
||||
assert.Equal(t, StatusOK, s)
|
||||
}
|
||||
|
||||
func TestStatusToString(t *testing.T) {
|
||||
assert.Equal(t, "OK", StatusOK.String())
|
||||
assert.Equal(t, "WARNING", StatusWarning.String())
|
||||
assert.Equal(t, "ERROR", StatusCritical.String())
|
||||
assert.Equal(t, "UNKNOWN", StatusUnknown.String())
|
||||
}
|
||||
|
||||
func TestStatusToInt(t *testing.T) {
|
||||
assert.Equal(t, 0, int(StatusOK))
|
||||
assert.Equal(t, 1, int(StatusWarning))
|
||||
assert.Equal(t, 2, int(StatusCritical))
|
||||
assert.Equal(t, 3, int(StatusUnknown))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue