Exemplo n.º 1
0
func (h *Harvester) Snapshot() *core.Snapshot {
	h.RLock()

	ret := core.NewSnapshot("Harvester")
	ret.AddEntry("Speed (Lps)", h.line_speed)
	ret.AddEntry("Speed (Bps)", h.byte_speed)
	ret.AddEntry("Processed lines", h.line_count)
	ret.AddEntry("Current offset", h.offset)
	if h.last_eof_off == nil {
		ret.AddEntry("Last EOF Offset", "Never")
	} else {
		ret.AddEntry("Last EOF Offset", h.last_eof_off)
	}
	if h.last_eof == nil {
		ret.AddEntry("Status", "Alive")
	} else {
		ret.AddEntry("Status", "Idle")
		if age := time.Since(*h.last_eof); age < h.stream_config.DeadTime {
			ret.AddEntry("Dead timer", h.stream_config.DeadTime-age)
		} else {
			ret.AddEntry("Dead timer", "0s")
		}
	}

	if sub_snap := h.codec.Snapshot(); sub_snap != nil {
		ret.AddSub(sub_snap)
	}

	h.RUnlock()

	return ret
}
Exemplo n.º 2
0
func (p *Prospector) Snapshot() []*core.Snapshot {
	select {
	case p.snapshot_chan <- 1:
	// Timeout after 5 seconds
	case <-time.After(5 * time.Second):
		ret := core.NewSnapshot("Prospector")
		ret.AddEntry("Error", "Timeout")
		return []*core.Snapshot{ret}
	}

	return <-p.snapshot_sink
}
Exemplo n.º 3
0
func (p *Prospector) snapshotInfo(info *prospectorInfo) *core.Snapshot {
	var extra string
	var status string

	if info.file == "-" {
		extra = "Stdin / "
	} else {
		switch info.orphaned {
		case Orphaned_Maybe:
			extra = "Orphan? / "
		case Orphaned_Yes:
			extra = "Orphan / "
		}
	}

	switch info.status {
	default:
		if info.running {
			status = "Running"
		} else {
			status = "Dead"
		}
	case Status_Resume:
		status = "Resuming"
	case Status_Failed:
		status = fmt.Sprintf("Failed: %s", info.err)
	case Status_Invalid:
		if _, ok := info.err.(*ProspectorSkipError); ok {
			status = fmt.Sprintf("Skipped (%s)", info.err)
		} else {
			status = fmt.Sprintf("Error: %s", info.err)
		}
	}

	snap := core.NewSnapshot(fmt.Sprintf("\"State: %s (%s%p)\"", info.file, extra, info))
	snap.AddEntry("Status", status)

	if info.running {
		if sub_snap := info.getSnapshot(); sub_snap != nil {
			snap.AddSub(sub_snap)
		}
	}

	return snap
}
Exemplo n.º 4
0
func (p *Prospector) handleSnapshot() {
	snapshots := make([]*core.Snapshot, 1)

	snapshots[0] = core.NewSnapshot("Prospector")
	snapshots[0].AddEntry("Watched files", len(p.prospectorindex))
	snapshots[0].AddEntry("Active states", len(p.prospectors))

	for _, info := range p.prospectorindex {
		snapshots = append(snapshots, p.snapshotInfo(info))
	}

	for _, info := range p.prospectors {
		if info.orphaned == Orphaned_No {
			continue
		}
		snapshots = append(snapshots, p.snapshotInfo(info))
	}

	p.snapshot_sink <- snapshots
}
Exemplo n.º 5
0
func (c *Client) FetchSnapshot() (*core.Snapshot, error) {
	response, err := c.request("SNAP")
	if err != nil {
		return nil, err
	}

	if ret, ok := response.Response.(*core.Snapshot); ok {
		return ret, nil
	}

	// Backwards compatibility
	if ret, ok := response.Response.([]*core.Snapshot); ok {
		snap := core.NewSnapshot("Log Courier")
		for _, sub := range ret {
			snap.AddSub(sub)
		}
		snap.Sort()
		return snap, nil
	}

	return nil, c.resolveError(response)
}
Exemplo n.º 6
0
func (p *Publisher) Snapshot() []*core.Snapshot {
	p.RLock()

	snapshot := core.NewSnapshot("Publisher")

	switch p.status {
	case Status_Connected:
		snapshot.AddEntry("Status", "Connected")
	case Status_Reconnecting:
		snapshot.AddEntry("Status", "Reconnecting...")
	default:
		snapshot.AddEntry("Status", "Disconnected")
	}

	snapshot.AddEntry("Speed (Lps)", p.line_speed)
	snapshot.AddEntry("Published lines", p.last_line_count)
	snapshot.AddEntry("Pending Payloads", p.num_payloads)
	snapshot.AddEntry("Timeouts", p.timeout_count)
	snapshot.AddEntry("Retransmissions", p.last_retry_count)

	p.RUnlock()

	return []*core.Snapshot{snapshot}
}
Exemplo n.º 7
0
func (c *CodecMultiline) Snapshot() *core.Snapshot {
	snap := core.NewSnapshot("Multiline Codec")
	snap.AddEntry("Pending lines", c.meter_lines)
	snap.AddEntry("Pending bytes", c.meter_bytes)
	return snap
}
Exemplo n.º 8
0
func (c *CodecFilter) Snapshot() *core.Snapshot {
	snap := core.NewSnapshot("Filter Codec")
	snap.AddEntry("Filtered lines", c.meter_filtered)
	return snap
}