예제 #1
0
// Authenticate authenticates any agent and returns a heartbeat interval, a
// fake entity ID and "stable" channel. It's used along with endpoint.Hub
func (auth authenticator) Authenticate(agentName string, agentID string, token string, responder *endpoint.Responder, connCtx endpoint.ConnContext) endpoint.HandleCode {
	var result helloResult
	result.HeartbeatInterval = "1000"
	result.EntityID = "fake-entity-id-asdfghjkl"
	result.Channel = "stable"
	responder.Respond(result, nil)

	// return OK for any agent
	return endpoint.OK
}
예제 #2
0
// Handle responds to check_schedule.get requests with a list of checks
func (c checkScheduleHandler) Handle(req *endpoint.Request, responder *endpoint.Responder, connCtx endpoint.ConnContext) endpoint.HandleCode {
	var rsp checkScheduleGetResult
	checks := [][]interface{}{
		{"agent.memory", nil},
		{"agent.disk", map[string]string{"target": "/dev/mapper/precise64-root"}},
		{"agent.filesystem", map[string]string{"target": "/"}},
		{"agent.network", map[string]string{"target": "eth0"}},
		{"agent.network", map[string]string{"target": "eth1"}},
		{"agent.cpu", nil},
		{"agent.load_average", nil},
	}
	for i, v := range checks {
		rsp.Checks = append(rsp.Checks, check{
			ID:       fmt.Sprintf("check-%02d", i),
			Type:     v[0].(string),
			Details:  v[1],
			Period:   scheduleInterval,
			Timeout:  scheduleInterval,
			Disabled: false,
		})
	}
	responder.Respond(rsp, nil)
	return endpoint.OK
}
// Handle finalizes check_metrics.post request, writing a non-error response
func (c checkMetricsFinalizeHandler) Handle(req *endpoint.Request, responder *endpoint.Responder, connCtx endpoint.ConnContext) endpoint.HandleCode {
	responder.Respond(0, nil)
	return endpoint.OK
}