Skip to content

Commit

Permalink
Use hostname for probe ID
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbourgon committed Aug 12, 2015
1 parent f85b505 commit 013d175
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions probe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import (
"flag"
"fmt"
"log"
"math/rand"
"net"
"net/http"
_ "net/http/pprof"
"os"
"os/signal"
"runtime"
"strconv"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -50,9 +48,12 @@ func main() {
)
flag.Parse()

rand.Seed(time.Now().UnixNano())
id := strconv.FormatInt(rand.Int63(), 16)
log.Printf("probe starting, version %s, ID %s", version, id)
var (
hostName = hostname()
hostID = hostName // TODO: we should sanitize the hostname
probeID = hostName // TODO: does this need to be a random string instead?
)
log.Printf("probe starting, version %s, ID %s", version, probeID)

if len(flag.Args()) > 0 {
targets = flag.Args()
Expand All @@ -78,7 +79,7 @@ func main() {
log.Printf("warning: process reporting enabled, but that requires root to find everything")
}

publisherFactory := func(target string) (xfer.Publisher, error) { return xfer.NewHTTPPublisher(target, *token, id) }
publisherFactory := func(target string) (xfer.Publisher, error) { return xfer.NewHTTPPublisher(target, *token, probeID) }
publishers := xfer.NewMultiPublisher(publisherFactory)
resolver := newStaticResolver(targets, publishers.Add)
defer resolver.Stop()
Expand All @@ -96,8 +97,6 @@ func main() {
}

var (
hostName = hostname()
hostID = hostName // TODO: we should sanitize the hostname
taggers = []Tagger{newTopologyTagger(), host.NewTagger(hostID)}
reporters = []Reporter{host.NewReporter(hostID, hostName, localNets), endpoint.NewReporter(hostID, hostName, *spyProcs)}
processCache *process.CachingWalker
Expand Down

0 comments on commit 013d175

Please sign in to comment.