I have configured a trigger in Zabbix which gets active when there's no internet connectivity. All other triggers are depending on this trigger, so if there's no internet connection, only one trigger is getting active instead of all. This works as expected.
But when I get all active triggers via Zabbix API, it returns all triggers and does not take account of the configured dependencies.
This is how my API request looks like:
{
"jsonrpc": "2.0",
"method": "trigger.get",
"params": {
"output": "extend",
"selectTriggers": "extend",
"selectGroups": "extend",
"selectHosts": "extend",
"withLastEventUnacknowledged": 1,
"expandDescription": 1,
"filter": {
"value": 1,
"status": 0
},
"sortfield": "priority",
"sortorder": "DESC"
},
"id": 2,
"auth": "XXX"
}
It's a bit later, but in Zabbix API v. 2.4-3.0 there is a flag "skipDependent".
So, the request will be
{
"jsonrpc": "2.0",
"method": "trigger.get",
"params": {
"output": "extend",
"skipDependent": "1",
"selectTriggers": "extend",
"selectGroups": "extend",
"selectHosts": "extend",
"withLastEventUnacknowledged": 1,
"expandDescription": 1,
"filter": {
"value": 1,
"status": 0
},
"sortfield": "priority",
"sortorder": "DESC"
},
"id": 2,
"auth": "XXX"
}
You probably need to add: "selectDependencies": "true" to your request.
It's avaliable as a flag and as query.
https://www.zabbix.com/documentation/2.2/manual/api/reference/trigger/get
Related
I am able to add Quality Issues through the BIM360 API (or associated APIs, link below) and I am able to set the Location Details. However, my customer uses the Location field, not Location Details. Is there any way to set the Location, specifically?
Here is the page for posting an item:
https://forge.autodesk.com/en/docs/bim360/v1/reference/http/field-issues-POST/
I don't see a location attribute or a location permitted attribute, just location details.
See image: https://i.stack.imgur.com/3OmZd.png
We can get the location id under the path attributes.lbs_location
{
"id": "038edfcf-t56y-4e04-a358-42c95f20c945",
"type": "quality_issues",
//...
"attributes": {
//...
"lbs_location": "d14ce3a6-e61b-4ab0-a9be-5acf7b5366df",
//...
},
// ...
}
To get corresponding location data, we need to call GET v2/containers/{containerId}/trees/{treeId}/nodes
{
"pagination": {
"limit": 2,
"offset": 0,
"totalResults": 2,
"nextUrl": null
},
"results": [
{
"id": "5add4375-f223-4201-88b9-8049e68416aa",
"parentId": null,
"type": "Root",
"name": "Project",
"description": "Project description",
"barcode": null,
"order": 0,
"documentCount": 0,
"areaDefined": false
},
{
"id": "d14ce3a6-e61b-4ab0-a9be-5acf7b5366df",
"parentId": "5add4375-f223-4201-88b9-8049e68416aa",
"type": "Area",
"name": "Area 1",
"description": "An Area 1 node",
"barcode": "ABC123",
"order": 0,
"documentCount": 2,
"areaDefined": true
}
]
}
To modify the location id for a quality issue, we can call PATCH issues/:id with the below payload:
{
"data": {
"type": "quality_issues",
"id": "038edfcf-t56y-4e04-a358-42c95f20c945",
"attributes": {
"lbs_location": "d14ce3a6-e61b-4ab0-a9be-5acf7b5366df"
}
}
}
Im using Debezium to sync data from MySQL to S3. Now I want to make some changes.
Sample insert:
create table new (id int);
insert into new (1);
1. Custom Payload
{
"schema": {
"type": "struct",
bla bla bla
"optional": false,
"name": "_72.31.84.129.test.new.Envelope"
},
"payload": {
"before": null,
"after": {
"id": 10
},
"source": {
"version": "0.10.0.Final",
"connector": "mysql",
"name": "11.11.84.129",
"ts_ms": 1576605998000,
"snapshot": "false",
"db": "test",
"table": "new",
"server_id": 1,
"gtid": "3a7b90e9-207e-11ea-b3ed-121a0cbac3cb:51",
"file": "mysql-bin.000003",
"pos": 12770,
"row": 0,
"thread": 47,
"query": null
},
"op": "c",
"ts_ms": 1576605998231
}
}
I want to only push the payload option with some custom changes. I need to include the source,op,ts_ms are inside the payload.after.
Expected output:
{
"id": 10,
"source": {
"version": "0.10.0.Final",
"connector": "mysql",
"name": "11.11.84.129",
"ts_ms": 1576605998000,
"snapshot": "false",
"db": "test",
"table": "new",
"server_id": 1,
"gtid": "3a7b90e9-207e-11ea-b3ed-121a0cbac3cb:51",
"file": "mysql-bin.000003",
"pos": 12770,
"row": 0,
"thread": 47,
"query": null
},
"op": "c",
"ts_ms": 1576605998231
}
I don't want schema, payload.before. Im not sure how to get this output.
Check out the SMT for extracting the new record state. It will only propagate what's in after. Optionally, you can let it add chosen field from source, too.
...
transforms=unwrap
transforms.unwrap.type=io.debezium.transforms.ExtractNewRecordState
transforms.unwrap.add.source.fields=table,lsn
...
You cannot insert the op and ts_ms fields atm., but they can be propgated as message headers.
want to returned values itemsid by list hostnames
found variant for hostid list
zabbix_get=\
{
"jsonrpc": "2.0",
"method": "item.get",
"params": {
"output": "extend",
"hostids": [123, 234],
"search": {
"key_": "vfs.fs.size"
},
"sortfield": "name"
},
"auth": authToken.get("result"),
"id": authToken.get("id")
}
tried to request by one hostname - GOOD
zabbix_get=\
{
"jsonrpc": "2.0",
"method": "item.get",
"params": {
"output": "extend",
"host": "server01"
"search": {
"key_": "vfs.fs.size"
},
"sortfield": "name"
},
"auth": authToken.get("result"),
"id": authToken.get("id")
}
Tried to request by list hostnames
zabbix_get=\
{
"jsonrpc": "2.0",
"method": "item.get",
"params": {
"output": "extend",
"hosts": ["server01","server02"]
"search": {
"key_": "vfs.fs.size"
},
"sortfield": "name"
},
"auth": authToken.get("result"),
"id": authToken.get("id")
}
zabbix is frozen.
How solve this problem?
The item.get method does not support a parameter named hosts, so it is now trying to get you data for all of the hosts (and templates).
If you want to filter by multiple hosts, use the hostids parameter instead.
I am using the Bluemix Workload Scheduler REST API to create Processes with a Scheduled Trigger having a oneTimeProperty and a startDate.
Additionally the json i am sending also has a restfulStep.
The issue i have is, that no matter how i provide the "queryParameters" and "headers" for the restfulStep, they are not accepted/configured in the process after the successful process creation.
Here is the json i am using:
{
"name": "my process name",
"processlibraryid": 1234,
"processstatus": true,
"triggers": [
{
"name": "Scheduled Trigger",
"triggerType": "OnceTrigger",
"oneTimeProperty": {
"startDate": "TIMEVALUE"
}
}
],
"steps": [
{
"restfulStep": {
"agent": "AGENTNAME}",
"action": {
"uri": "MYCUSTOMURL",
"contentType": "application/json",
"method": "POST",
"verifyHostname": true,
"queryParameters": [
["param1", "value1"],
["param2", "value2"]
],
"headers": [
["param3", "param4"]
],
"numberOfRetries": 3,
"retryIntervalSeconds": 30
},
"authdata": {
"username": "USERNAME",
"password": "PASSWORD"
},
"input": {
"input": "",
"isFile": false
}
}
}
]
}
issue has been fixed with last Workload Scheduler upgrade.
Could you try using a Json like the following?
{
"name": "myname",
"processlibraryid": <1234>,
"processstatus": false,
"triggers": [
{
"name": "Scheduled Trigger",
"triggerType": "OnceTrigger",
"oneTimeProperty": {
"startDate": "2016-12-16T10:30:43.218Z"
}
}
],
"steps": [
{
"restfulStep": {
"agent": "<MY_AGENT_NAME>",
"action": {
"uri": "<MY_URL>",
"contentType": "application/json",
"method": "GET",
"verifyHostname": true,
"queryParameters": [
["param1", "value1"],
["param2", "value2"]
],
"headers": [
["Accept", "application/json"],
["User-Agent", "Mozilla/5.0 "]
],
"numberOfRetries": 3,
"retryIntervalSeconds": 30
},
"authdata": {
"username": "USERNAME",
"password": "PASSWORD"
},
"input": {
"input": "",
"isFile": false
}
}
}
]
}
Regards
Andrea I
your json is correct but there is a little bug in Workload Scheduler service.
A fix will be released by the end of December.
As workaround, you could use Application Lab in order to create your Restful step. In addition, you could append the queryParameters to your uri address.
At the moment, there is no workarounds for headers.
If you find other issue using the service, do not hesitate to post your comments.
Thanks!
Andrea I
I'm trying to remotely stop/start services using systemctl inside Zabbix's system.run[] request/item but it doesn't seem to work.
I'm using Zabbix 3.0 JSON-RPC API and my JSON looks like this:
{
"jsonrpc": "2.0",
"method": "item.get",
"params": {
"filter": {
"host": "host-name",
"key_": "system.run[sudo systemctl stop nginx.service]"
}
},
"id": 1,
"auth": "my-token"
}
Result:
{"jsonrpc":"2.0","result":[],"id":1}
But I'm not too sure about validity of this request because all the information I've seen on system.run[] so far was related to zabbix_get. Is it even possible to execute system.run[] this way? What am I doing wrong?
This is obviously just filtering items but I have no idea how to replicate what zabbix_get does using Zabbix JSON-RPC API. There is no information I could find about this.
This works well for gathering data, tho:
{
"jsonrpc": "2.0",
"method": "item.get",
"params": {
"filter": {
"host": "host-name",
"key_": "vm.memory.size[used]"
}
},
"id": 1,
"auth": "my-token"
}
Result:
{
"jsonrpc": "2.0",
"result": [
{
"itemid": "455",
"type": "0",
"snmp_community": "",
"snmp_oid": "",
"hostid": "12241",
"name": "Used memory",
"key_": "vm.memory.size[used]",
"delay": "60",
"history": "90",
"trends": "365",
"status": "0",
"value_type": "3",
"trapper_hosts": "",
"units": "B",
"multiplier": "0",
"delta": "0",
"snmpv3_securityname": "",
"snmpv3_securitylevel": "0",
"snmpv3_authpassphrase": "",
"snmpv3_privpassphrase": "",
"formula": "1",
"error": "",
"lastlogsize": "0",
"logtimefmt": "",
"templateid": "106",
"valuemapid": "0",
"delay_flex": "",
"params": "",
"ipmi_sensor": "",
"data_type": "0",
"authtype": "0",
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"mtime": "0",
"flags": "0",
"interfaceid": "2",
"port": "",
"description": "",
"inventory_link": "0",
"lifetime": "30",
"snmpv3_authprotocol": "0",
"snmpv3_privprotocol": "0",
"state": "0",
"snmpv3_contextname": "",
"evaltype": "0",
"lastclock": "1466142275",
"lastns": "142277413",
"lastvalue": "3971121455",
"prevvalue": "3971001230"
}
],
"id": 1
}
If someone managed to execute system.run[] using JSON-RPC API, please, share your solution.
Thank you.
No, there seem to be a few things wrong. First, the Zabbix API is JSON-RPC (not REST). Second, the item.get method is primarily used to get item configuration from the server.
To request item values from an agent (and this is how remote commands are implemented with the system.run item key), you can use the already mentioned zabbix_get:
$ zabbix_get -s host-name -k "system.run[sudo systemctl stop nginx.service]"
Note that when you say "This works well for gathering data", you are not telling Zabbix to collect data at that point - it just returns you some data that is already in the database. In the case of remote commands, the best you could get would be "1" that indicates that last time this remote command was sent to the agent successfully.