I've looked around a little and haven't seen much on this front. I have a Zabbix server, and in the process of migration, I have a bulk of copy/paste from old system (would you believe Nagios?
) to new system. I don't relish this task so I decided to see what I could manage via API.
I have some experience pulling out info from the API to get me hostnames for machines I have added to a template. I have expanded this into a bash/curl/jq script to allow me to make all the calls I need to gather information from the API, but via the command line so my other scripts can act on that.
Example to query the hostname and get the hostid:
This is not limited to getting items. Example to query and delete a macro from a host:
Any interest for me to share it?
) to new system. I don't relish this task so I decided to see what I could manage via API. I have some experience pulling out info from the API to get me hostnames for machines I have added to a template. I have expanded this into a bash/curl/jq script to allow me to make all the calls I need to gather information from the API, but via the command line so my other scripts can act on that.
Example to query the hostname and get the hostid:
Code:
$ ./api -m host.get -f '"host": "myhost.com"' -r .hostid 11
Code:
$ ./api -m usermacro.get -p '"hostids": "11"'
{
"value": "test",
"macro": "{$TEST}",
"hostid": "11",
"hostmacroid": "5"
}
$ ./api -m usermacro.delete -a -p '"5"'
[
"5"
]
Comment