-
Notifications
You must be signed in to change notification settings - Fork 32
/
helper_test.go
31 lines (26 loc) · 956 Bytes
/
helper_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package agentx_test
import (
"fmt"
"os/exec"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func SNMPGet(tb testing.TB, oid string) string {
cmd := exec.Command("snmpget", "-v2c", "-cpublic", "-On", "127.0.0.1:30161", oid)
output, err := cmd.CombinedOutput()
require.NoError(tb, err)
return strings.TrimSpace(string(output))
}
func SNMPGetNext(tb testing.TB, oid string) string {
cmd := exec.Command("snmpgetnext", "-v2c", "-cpublic", "-On", "127.0.0.1:30161", oid)
output, err := cmd.CombinedOutput()
require.NoError(tb, err)
return strings.TrimSpace(string(output))
}
func SNMPGetBulk(tb testing.TB, oid string, nonRepeaters, maxRepetitions int) string {
cmd := exec.Command("snmpbulkget", "-v2c", "-cpublic", "-On", fmt.Sprintf("-Cn%d", nonRepeaters), fmt.Sprintf("-Cr%d", maxRepetitions), "127.0.0.1:30161", oid)
output, err := cmd.CombinedOutput()
require.NoError(tb, err)
return strings.TrimSpace(string(output))
}