Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using z.HostCreate to create SNMP type hosts, I think Details should not need slicing, using slicing will report an error: Incorrect arguments passed to function. #5

Open
want-u opened this issue Dec 20, 2022 · 0 comments

Comments

@want-u
Copy link

want-u commented Dec 20, 2022

thisHost := zabbix.HostObject{
	Host: "api-snmp-host",
	Interfaces: []zabbix.HostinterfaceObject{
		{
			Type:  zabbix.HostinterfaceTypeSNMP,
			Main:  zabbix.HostinterfaceMainDefault,
			UseIP: zabbix.HostinterfaceUseipIP,
			IP:    "127.0.0.1",
			DNS:   "",
			Port:  "161",
			Details: zabbix.HostinterfaceDetailsTagObject{
				Version:   zabbix.HostinterfaceDetailsTagVersionSNMPv2c,
				Community: "{$SNMP_COMMUNITY}",
				Bulk:      zabbix.HostinterfaceDetailsTagBulkDontUse,
			},
		},
	},
	Groups: []zabbix.HostgroupObject{
		{
			GroupID: 16,
		},
	},
	// Templates: []zabbix.TemplateObject{
	// 	{
	// 		TemplateID: 10283,
	// 	},
	// },
}
_, _, err = z.HostCreate([]zabbix.HostObject{thisHost})
if err != nil {
	Logger.Println("[HostCreate error]:", err)
	return
}

{"jsonrpc":"2.0","method":"host.create","params":[{"host":"api-snmp-host","groups":[{"groupid":16}],"interfaces":[{"dns":"","ip":"127.0.0.1","main":1,"port":"161","type":2,"useip":1,"details":[{"version":2,"community":"{$SNMP_COMMUNITY}"}]}]}],"auth":"0431bdb48d29fd8ebb7de518b68a3c52","id":1}
[LOG]2022/12/20 20:52:56 main.go:156: [HostCreate error]: Incorrect arguments passed to function. Invalid params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant