This commit is contained in:
Wolfgang Hottgenroth 2025-02-13 17:16:55 +01:00
commit b41db4f2ae
Signed by: wn
GPG Key ID: 18FDFA577A8871AD
3 changed files with 58 additions and 0 deletions

5
go.mod Normal file
View File

@ -0,0 +1,5 @@
module agentx-go
go 1.22.3
require github.com/posteo/go-agentx v0.2.1

12
go.sum Normal file
View File

@ -0,0 +1,12 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posteo/go-agentx v0.2.1 h1:HO0zO/+GosL0RYEodu7KNH9OF/rL5bJbhXNP1z3hkT8=
github.com/posteo/go-agentx v0.2.1/go.mod h1:EUR75CfAEDstQn3WqCs26Ti64EsggaSXDk2dgxPQ5TI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

41
main.go Normal file
View File

@ -0,0 +1,41 @@
package main
import (
"log"
"time"
"github.com/posteo/go-agentx"
"github.com/posteo/go-agentx/pdu"
"github.com/posteo/go-agentx/value"
)
func main() {
client, err := agentx.Dial("unix", "/var/agentx/master")
if err != nil {
log.Fatalf("%v", err)
}
client.Timeout = 1 * time.Minute
client.ReconnectInterval = 1 * time.Second
session, err := client.Session()
if err != nil {
log.Fatalf("%v", err)
}
listHandler := &agentx.ListHandler{}
item := listHandler.Add("1.3.6.1.4.1.9676.1.1")
item.Type = pdu.VariableTypeInteger
item.Value = int32(-123)
session.Handler = listHandler
if err := session.Register(127, value.MustParseOID("1.3.6.1.4.1.9676.1")); err != nil {
log.Fatalf("%v", err)
}
for {
time.Sleep(100 * time.Millisecond)
}
}