Skip to content

Commit

Permalink
Attempts to construct a target switch name based on the node name in …
Browse files Browse the repository at this point in the history
…the absence of the -target flag. (#7)
  • Loading branch information
nkinkade authored Jun 23, 2020
1 parent 3d4c189 commit 1873bc4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions disco.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"flag"
"fmt"
"log"
"strings"
"time"
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 1873bc4

Please sign in to comment.