Skip to content

Instantly share code, notes, and snippets.

@ripienaar
Created September 10, 2019 17:55
Show Gist options
  • Save ripienaar/912b073487acc16ca75f2abaf50ef3a5 to your computer and use it in GitHub Desktop.
Save ripienaar/912b073487acc16ca75f2abaf50ef3a5 to your computer and use it in GitHub Desktop.
package main
import (
"context"
"fmt"
cc "github.com/ripienaar/rpcwrapperpoc/choriautil"
)
func main() {
c, err := cc.New()
if err != nil {
panic(err)
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
res, err := c.OptionFactFilter("country=mt").Info().Do(ctx)
if err != nil {
panic(err)
}
res.EachOutput(func(r *cc.InfoOutput) {
fmt.Printf("%s: %#v\n", r.ResultDetails().Sender(), r.ClientStats())
})
}
% choria req choria_util info -I `hostname` -j|jq '.replies|.[]|.data.client_stats'
{
"in_msgs": 209,
"out_msgs": 238,
"in_bytes": 1010967,
"out_bytes": 263311,
"reconnects": 1
}
% go run cmd/info/main.go <19:49:40
dev1.devco.net: map[string]interface {}{"in_bytes":1.020613e+06, "in_msgs":211, "out_bytes":266941, "out_msgs":240, "reconnects":1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment