5 func (s Service) name() string {
9 func (s Service) path() string {
10 return "/objects/services/" + s.Name
13 // Service represents a Service object.
15 Name string `json:"__name"`
18 StateType StateType `json:"state_type"`
19 CheckCommand string `json:"check_command"`
20 DisplayName string `json:"display_name"`
21 LastCheckResult CheckResult `json:"last_check_result"`
24 type CheckResult struct {
31 ServiceOK ServiceState = 0 + iota
37 func (s ServiceState) String() string {
42 return "ServiceWarning"
44 return "ServiceCritical"
46 return "ServiceUnknown"
48 return "unhandled service state"
51 func (s Service) MarshalJSON() ([]byte, error) {
52 attrs := make(map[string]interface{})
53 if len(s.Groups) > 0 {
54 attrs["groups"] = s.Groups
56 attrs["check_command"] = s.CheckCommand
57 attrs["display_name"] = s.DisplayName
59 Attrs map[string]interface{} `json:"attrs"`
61 return json.Marshal(jservice)