icinga

Icinga2 API client in Go
git clone https://git.olowe.co/icinga
Log | Files | Refs | README | LICENSE

commit dca9442c1f7da187028aaaf66f2ebf7c34d6a863
parent e35b73d5e39c5601f8db91e5dc8fc38642d1dea4
Author: Oliver Lowe <o@olowe.co>
Date:   Wed,  2 Feb 2022 15:28:46 +1100

Catch all HostStates and ServiceStates

This is closer to the Icinga spec, anything greater than 2 or 3 is unknown.

Diffstat:
Mhost.go | 8+++-----
Mservice.go | 8+++-----
2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/host.go b/host.go @@ -29,16 +29,14 @@ const ( HostUnreachable ) -func (s HostState) String() string { - switch s { +func (state HostState) String() string { + switch state { case HostUp: return "HostUp" case HostDown: return "HostDown" - case HostUnreachable: - return "HostUnreachable" } - return "unhandled host state" + return "HostUnreachable" } func (h Host) name() string { diff --git a/service.go b/service.go @@ -35,18 +35,16 @@ const ( ServiceUnknown ) -func (s ServiceState) String() string { - switch s { +func (state ServiceState) String() string { + switch state { case ServiceOK: return "ServiceOK" case ServiceWarning: return "ServiceWarning" case ServiceCritical: return "ServiceCritical" - case ServiceUnknown: - return "ServiceUnknown" } - return "unhandled service state" + return "ServiceUnknown" } func (s Service) MarshalJSON() ([]byte, error) {