func (p *HeartbeatProcessor) Process(e *events.Envelope) []metrics.WMetric {
	processedMetrics := make([]metrics.WMetric, 4)
	heartbeat := e.GetHeartbeat()
	origin := e.GetOrigin()

	processedMetrics[0] = *p.ProcessHeartbeatCount(heartbeat, origin)
	processedMetrics[1] = *p.ProcessHeartbeatEventsSentCount(heartbeat, origin)
	processedMetrics[2] = *p.ProcessHeartbeatEventsReceivedCount(heartbeat, origin)
	processedMetrics[3] = *p.ProcessHeartbeatEventsErrorCount(heartbeat, origin)

	return processedMetrics
}
Beispiel #2
0
func Heartbeat(msg *events.Envelope) Event {
	heartbeat := msg.GetHeartbeat()

	var avail uint64

	if heartbeat.GetSentCount() > 0 {
		avail = heartbeat.GetReceivedCount() / heartbeat.GetSentCount()
	}

	fields := logrus.Fields{
		"ctl_msg_id":     heartbeat.GetControlMessageIdentifier(),
		"error_count":    heartbeat.GetErrorCount(),
		"origin":         msg.GetOrigin(),
		"received_count": heartbeat.GetReceivedCount(),
		"sent_count":     heartbeat.GetSentCount(),
		"availability":   avail,
	}

	return Event{
		Fields: fields,
		Msg:    "",
		Type:   msg.GetEventType().String(),
	}
}