The attached code is not a ready-to-use solution! E.g. it includes unavailable procedures for logging.
I just want to share some code snippets that might or might not be useful.
The PL/SQL procedures make use of PL/JSON.
Examples:
I just want to share some code snippets that might or might not be useful.
The PL/SQL procedures make use of PL/JSON.
Examples:
Code:
set serveroutput on
--
-- Q: get ZabbiX server API version ?
--
SELECT pc_zabbix_api.fn_GetAPIVersion (p_authid_in => pc_zabbix_api.fn_GetAuthID('<zabbix_user>','<zabbix_password>')) zabbix_api_version
FROM dual;
DECLARE
v_version VARCHAR2(64);
BEGIN
v_version := pc_zabbix_api.fn_GetAPIVersion (
p_authid_in => pc_zabbix_api.fn_GetAuthID('<zabbix_user>','<zabbix_password>')
);
DBMS_OUTPUT.PUT_LINE(v_version);
END;
/
--
-- Q: get information for all hosts ?
--
DECLARE
v_json json;
BEGIN
v_json := pc_zabbix_api.fn_GetHost (
p_authid_in => pc_zabbix_api.fn_GetAuthID('<zabbix_user>','<zabbix_password>')
);
v_json.print(false);
END;
/
--
-- Q: get information for single host ?
--
DECLARE
v_json json;
BEGIN
v_json := pc_zabbix_api.fn_GetHost (
p_authid_in => pc_zabbix_api.fn_GetAuthID('<zabbix_user>','<zabbix_password>'),
p_host_in => '<zabbix_host>'
);
DBMS_OUTPUT.PUT_LINE(json_ext.get_string(v_json, 'result[1].name'));
END;
/
--
-- Q: get information for all items on single host ?
--
DECLARE
v_json json;
BEGIN
v_json := pc_zabbix_api.fn_GetHostItem (
p_authid_in => pc_zabbix_api.fn_GetAuthID('<zabbix_user>','<zabbix_password>'),
p_host_in => '<zabbix_host>'
);
v_json.print(false);
END;
/
--
-- Q: get information for single item on single host ?
--
DECLARE
v_json json;
BEGIN
v_json := pc_zabbix_api.fn_GetHostItem (
p_authid_in => pc_zabbix_api.fn_GetAuthID('<zabbix_user>','<zabbix_password>'),
p_host_in => '<zabbix_host>',
p_item_in => '<zabbix_item>'
);
DBMS_OUTPUT.PUT_LINE(json_ext.get_string(v_json, 'result[1].lastvalue'));
END;
/