Emmanuel BENOîT
78af496fe9
This PR refactors most of the internals to make them easier to test (and also because the names didn't make sense). It adds unit tests for all internal components. Reviewed-on: #2 Co-authored-by: Emmanuel BENOÎT <tseeker@nocternity.net> Co-committed-by: Emmanuel BENOÎT <tseeker@nocternity.net>
25 lines
584 B
Go
25 lines
584 B
Go
package perfdata // import nocternity.net/gomonop/pkg/perfdata
|
|
|
|
import (
|
|
"regexp"
|
|
)
|
|
|
|
// Flags indicating which elements of performance data have been set.
|
|
type perfDataBits int
|
|
|
|
const (
|
|
PDatWarn perfDataBits = 1 << iota
|
|
PDatCrit
|
|
PDatMin
|
|
PDatMax
|
|
)
|
|
|
|
// Regexps used to check values and ranges in performance data records.
|
|
var (
|
|
// Common value check regexp.
|
|
vcRegexp = `^-?(0(\.\d*)?|[1-9]\d*(\.\d*)?|\.\d+)$`
|
|
// Compiled value check regexp.
|
|
valueCheck = regexp.MustCompile(vcRegexp)
|
|
// Compiled range min value check.
|
|
rangeMinCheck = regexp.MustCompile(vcRegexp + `|^~$`)
|
|
)
|