checkers

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 3 Imported by: 326

README

checkers

Build Status Coverage Status Apache License Version 2.0 GoDev

Description

checkers is utility for writing check plugins.

Synopsis

chr := checkers.Ok("command ok!")
chr.Exit()

CONTRIBUTION

  1. Fork (https://github.com/mackerelio/checkers/fork)
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create new Pull Request

License

Copyright 2015 Hatena Co., Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Overview

Package checkers is utility for checker commands

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse deprecated added in v0.1.0

func Parse(src string) (map[Status]Status, error)

Parse parses a string of the form <status>=<status>. <status> is one of:

  • ok
  • warning
  • critical
  • unknown

You can specify multiple key-value pairs separated by commas.

Deprecated: use ParseStatusMap instead.

func ParseStatusMap added in v0.2.0

func ParseStatusMap(src string) (map[Status]Status, error)

ParseStatusMap parses a string of the form <status>=<status>. <status> is one of:

  • ok
  • warning
  • critical
  • unknown

You can specify multiple key-value pairs separated by commas.

Types

type Checker

type Checker struct {
	Name    string
	Status  Status
	Message string
}

Checker is utility struct for check script

func Critical

func Critical(msg string) *Checker

Critical exiting with CRITICAL status

func NewChecker

func NewChecker(st Status, msg string) *Checker

NewChecker returns new Checker

func Ok

func Ok(msg string) *Checker

Ok exiting with OK status

func Unknown

func Unknown(msg string) *Checker

Unknown exiting with UNKNOWN status

func Warning

func Warning(msg string) *Checker

Warning exiting with WARNING status

func (*Checker) Exit

func (ckr *Checker) Exit()

Exit with message

func (*Checker) ExitStatusAs added in v0.1.0

func (ckr *Checker) ExitStatusAs(maps map[Status]Status)

func (*Checker) String

func (ckr *Checker) String() string

type Status

type Status int

Status declare the result of the checker command

const (
	OK Status = iota
	WARNING
	CRITICAL
	UNKNOWN
)

Statuses

func (Status) String

func (st Status) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL