获取交换机状态

// Copyright 2012 The GoSNMP Authors. All rights reserved.  Use of this
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.

// This program demonstrates BulkWalk.
package main

import (
	"flag"
	"fmt"
	"github.com/gosnmp/gosnmp"
	"os"
	"time"
)

func main() {
	var address string
	//fmt.Println(os.Args)
	flag.StringVar(&address, "a", "127.0.0.1", "地址")
	flag.Parse()
	{
	}
	//fmt.Println(address)
	gosnmp.Default.Target = address
	gosnmp.Default.Community = "public"
	oid := ".1.3.6.1.2.1.1"
	gosnmp.Default.Timeout = time.Duration(10 * time.Second) // Timeout better suited to walking
	err := gosnmp.Default.Connect()
	if err != nil {
		//fmt.Printf("Connect err: %v\n", err)
		fmt.Printf("%s\n", "0")
		os.Exit(1)
	} //else {
	//	fmt.Printf("%s", "1")
	//	os.Exit(1)
	//}
	defe

你可能感兴趣的:(Go,go)