Hi All,
I am currently trying to automate the process of installing the agent on servers as well as adding the Host to Zabbix at the same time. I have come a little unstuck when I run the host.create command. The PowerShell code is as follows (lost it's formatting in the copying into this thread):
$request = @{
jsonrpc = "2.0"
method = "host.create"
params = @{
host = $hostName
interfaces = @{
type = 1 # 1 = agent
main = 1
useip = 1
ip = $hostIP
dns = $fqdn
port = 10050 # This is the default Zabbix agent port
}
groups = @{
groupid = "35"
}
templates = @{
templateid = "10081"
}
}
auth = $authToken
id = 2
} | ConvertTo-Json
The ConvertTo-Json creates the following Json:
{
"method": "host.create",
"params": {
"host": "CHC-G2-VDA12",
"groups": {
"groupid": "35"
},
"templates": {
"templateid": "10584"
},
"interfaces": {
"port": 10050,
"dns": "CHC-G2-VDA12.hot.co.nz",
"ip": "10.151.103.51",
"useip": 1,
"type": 1,
"main": 1
}
},
"id": 2,
"jsonrpc": "2.0",
"auth": "902ec9f6929bbd2628ad6d0c3015026e"
}
I then run the following:
$response = Invoke-RestMethod -Uri $apiEndpoint -Method Post -Body $request -ContentType "application/json-rpc"
The following is the error returned in $response
jsonrpc error
@{code=-32500; message=Application error.; data=No permissions to referred object or it does not exist!}
Does anyone have any ideas on what could be causing this?
Thanks in advance
Cheers
Marc
I am currently trying to automate the process of installing the agent on servers as well as adding the Host to Zabbix at the same time. I have come a little unstuck when I run the host.create command. The PowerShell code is as follows (lost it's formatting in the copying into this thread):
$request = @{
jsonrpc = "2.0"
method = "host.create"
params = @{
host = $hostName
interfaces = @{
type = 1 # 1 = agent
main = 1
useip = 1
ip = $hostIP
dns = $fqdn
port = 10050 # This is the default Zabbix agent port
}
groups = @{
groupid = "35"
}
templates = @{
templateid = "10081"
}
}
auth = $authToken
id = 2
} | ConvertTo-Json
The ConvertTo-Json creates the following Json:
{
"method": "host.create",
"params": {
"host": "CHC-G2-VDA12",
"groups": {
"groupid": "35"
},
"templates": {
"templateid": "10584"
},
"interfaces": {
"port": 10050,
"dns": "CHC-G2-VDA12.hot.co.nz",
"ip": "10.151.103.51",
"useip": 1,
"type": 1,
"main": 1
}
},
"id": 2,
"jsonrpc": "2.0",
"auth": "902ec9f6929bbd2628ad6d0c3015026e"
}
I then run the following:
$response = Invoke-RestMethod -Uri $apiEndpoint -Method Post -Body $request -ContentType "application/json-rpc"
The following is the error returned in $response
jsonrpc error
@{code=-32500; message=Application error.; data=No permissions to referred object or it does not exist!}
Does anyone have any ideas on what could be causing this?
Thanks in advance
Cheers
Marc
Comment