Browse Source

close connection to snmp properly

master v0.1.1
Lars Hoogestraat 4 months ago
parent
commit
2e8e3d4448
1 changed files with 11 additions and 4 deletions
  1. +11
    -4
      main.go

+ 11
- 4
main.go View File

@ -78,6 +78,15 @@ func main() {
stat := ok
defer func() {
if gosnmp.Default.Conn != nil {
err := gosnmp.Default.Conn.Close()
if err != nil {
fmt.Println(err)
os.Exit(unknown)
}
}
os.Exit(stat)
}()
@ -136,8 +145,6 @@ func main() {
return
}
defer gosnmp.Default.Conn.Close()
status, err := dfFlags.diskSpaceUsage()
if err != nil {
@ -145,8 +152,8 @@ func main() {
stat = int(status)
return
}
os.Exit(int(status))
stat = int(status)
return
case "version":
version.Parse(os.Args[2:])


Loading…
Cancel
Save