33 lines
672 B
Markdown
33 lines
672 B
Markdown
# zabbixTokenUpdater
|
|
An ugly simple script that updates the API bearer token for HTTP Agent checks
|
|
|
|
# Reqs
|
|
* requests
|
|
* json
|
|
* logging
|
|
* pyzabbix
|
|
|
|
|
|
# Notes.
|
|
I know there are many other ways to script this prettier, I am just lazy.
|
|
|
|
# How to
|
|
|
|
Create a python script that:
|
|
|
|
reqs: pyzabbix (pip install pyzabbix), json, requests, logging
|
|
|
|
1- Get the bearer from your web/api endpoint using 'requests' python package.
|
|
|
|
2- create a function to update the item by:
|
|
|
|
```
|
|
zapi = ZabbixAPI("https://127.0.0.1")
|
|
zapi.login("<zabbix api user>","zabbix api password")
|
|
|
|
jsontoken = {
|
|
'Authorization': 'Bearer '+ token
|
|
}
|
|
zapi.item.update(itemid='<your item ID>', headers=jsontoken)
|
|
```
|