Exemplo n.º 1
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.º 2
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.º 3
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.º 4
0
func (h *Harvester) Snapshot() *core.Snapshot {
	h.mutex.Lock()

	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("Last offset", h.offset)
	if h.last_eof == nil {
		ret.AddEntry("Last EOF", "Never")
	} else {
		ret.AddEntry("Last EOF", h.last_eof)
	}

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

	h.mutex.Unlock()

	return ret
}
Exemplo n.º 5
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.º 6
0
func (c *CodecFilter) Snapshot() *core.Snapshot {
	snap := core.NewSnapshot("Filter Codec")
	snap.AddEntry("Filtered lines", c.meter_filtered)
	return snap
}