diff --git a/disco.go b/disco.go index ee9f3ff..432d253 100644 --- a/disco.go +++ b/disco.go @@ -3,6 +3,7 @@ package main import ( "context" "flag" + "fmt" "log" "strings" "time" @@ -38,6 +39,12 @@ func main() { log.Fatal("Node's FQDN must be passed as an arg or env variable.") } + // If the -target flag is empty, then attempt to construct it using the hostname. + if len(*fTarget) <= 0 { + h := *fHostname + *fTarget = fmt.Sprintf("s1-%s.measurement-lab.org", h[6:11]) + } + goSNMP := &gosnmp.GoSNMP{ Target: *fTarget, Port: uint16(161),