1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
package datadog
type HostActionResp struct {
Action string `json:"action"`
Hostname string `json:"hostname"`
Message string `json:"message,omitempty"`
}
type HostActionMute struct {
Message *string `json:"message,omitempty"`
EndTime *string `json:"end,omitempty"`
Override *bool `json:"override,omitempty"`
}
// MuteHost mutes all monitors for the given host
func (client *Client) MuteHost(host string, action *HostActionMute) (*HostActionResp, error) {
var out HostActionResp
uri := "/v1/host/" + host + "/mute"
if err := client.doJsonRequest("POST", uri, action, &out); err != nil {
return nil, err
}
return &out, nil
}
// UnmuteHost unmutes all monitors for the given host
func (client *Client) UnmuteHost(host string) (*HostActionResp, error) {
var out HostActionResp
uri := "/v1/host/" + host + "/unmute"
if err := client.doJsonRequest("POST", uri, nil, &out); err != nil {
return nil, err
}
return &out, nil
}
// HostTotalsResp defines response to GET /v1/hosts/totals.
type HostTotalsResp struct {
TotalUp *int `json:"total_up"`
TotalActive *int `json:"total_active"`
}
// GetHostTotals returns number of total active hosts and total up hosts.
// Active means the host has reported in the past hour, and up means it has reported in the past two hours.
func (client *Client) GetHostTotals() (*HostTotalsResp, error) {
var out HostTotalsResp
uri := "/v1/hosts/totals"
if err := client.doJsonRequest("GET", uri, nil, &out); err != nil {
return nil, err
}
return &out, nil
}
|