인프라/리눅스
[zabbix] 호스트 조회 api curl 명령어
IT맥구리나스
2023. 9. 27. 16:35
curl 명령어를 이용하여 zabbix host id를 조회 할 수 있다.
아래는 hostname이 test123인 서버의 id를 조회하기 위한 호출 명령어
auth는 토큰이다.
curl -s -X POST -H 'Content-Type: application/json' -d '
{
"jsonrpc": "2.0",
"method": "host.get",
"params": {
"filter": {
"host": [
"testgame123"
]
}
},
"auth": "12321312312323123123123123d416b70b2",
"id": 1
}' "http://12.123.123.123/api_jsonrpc.php"
토큰을 얻는 방법은 다음과 같다
curl --request POST --url 'https://zbx.test.com/api_jsonrpc.php' --header 'Content-Type: application/json-rpc' --data '{"jsonrpc":"2.0","method":"user.login","params":{"username":"test","password":"test123"},"id":1}' | jq -r '.result'
반응형