Skip to content

Instantly share code, notes, and snippets.

@doublemarket
Last active March 12, 2018 16:32
Show Gist options
  • Save doublemarket/3ae0f260d1700bd49fc22b6d8b8a956f to your computer and use it in GitHub Desktop.
Save doublemarket/3ae0f260d1700bd49fc22b6d8b8a956f to your computer and use it in GitHub Desktop.
Small Go server getting metrics from Collectd and dumping into stdout
package main
import (
"context"
"log"
"net"
"os"
"collectd.org/format"
"collectd.org/network"
)
func main() {
ctx := context.Background()
graphite := &format.Graphite{
W: os.Stdout,
Prefix: "test.",
Suffix: "",
EscapeChar: "_",
SeparateInstances: true,
AlwaysAppendDS: false,
}
srv := &network.Server{
Addr: net.JoinHostPort("127.0.0.1", network.DefaultService),
Writer: graphite,
}
// blocks
log.Fatal(srv.ListenAndWrite(ctx))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment