Last active
March 12, 2018 16:32
-
-
Save doublemarket/3ae0f260d1700bd49fc22b6d8b8a956f to your computer and use it in GitHub Desktop.
Small Go server getting metrics from Collectd and dumping into stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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