Documentation ¶
Overview ¶
Package rsyncprom implements a parser that extracts transfer details from rsync standard output output.
This package contains the parser, see cmd/rsync-prom for a wrapper program.
Rsync Requirements ¶
Start rsync with --verbose (-v) or --stats to enable printing transfer totals.
Do not use the --human-readable (-h) flag in your rsync invocation, otherwise rsyncprom cannot parse the output!
Run rsync in the C.UTF-8 locale to prevent rsync from localizing decimal separators and fractional points in big numbers.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WrapRsync ¶
func WrapRsync(ctx context.Context, params *WrapParams, args []string, start func(context.Context, []string) (io.Reader, error), wait func() int) error
WrapRsync starts one rsync invocation and pushes prometheus metrics about the invocation to the Prometheus push gateway specified in the WrapParams.
This function is used by the cmd/rsync-prom wrapper tool, but you can also use it programmatically and start rsync remotely via SSH instead of wrapping the process, for example.
Types ¶
type Stats ¶
type Stats = rsyncparse.Stats
Stats contains all data found in rsync output.
func Parse ¶
Parse reads from the specified io.Reader and scans individual lines. rsync transfer totals are extracted when found, and returned in the Stats struct.
Example ¶
stats, err := Parse(strings.NewReader(` sent 1,192,097 bytes received 1,039 bytes 795,424.00 bytes/sec total size is 1,188,046 speedup is 1.00 `)) if err != nil { log.Fatal(err) } fmt.Printf("corpus is %d bytes big!\n", stats.TotalSize)
Output: corpus is 1188046 bytes big!
type WrapParams ¶
type WrapParams struct { // Address of a Prometheus push gateway. This is passed as url parameter to // https://pkg.go.dev/github.com/prometheus/client_golang/prometheus/push#New Pushgateway string // Prometheus instance label. Instance string // Prometheus job name. Job string }
WrapParams is the configuration struct for the WrapRsync() function.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
rsync-prom
Program rsync-prom is a wrapper for rsync which exports prometheus metrics to a prometheus push gateway.
|
Program rsync-prom is a wrapper for rsync which exports prometheus metrics to a prometheus push gateway. |