Installation and using of demo application

Demo application can be used for testing Zabbix API.

  1. Upload demo and jqzabbix directory to web server that Zabbix web interface is working
  2. Edit demo/main.js
  3. // Zabbix server API url
    var url = 'http://localhost/zabbix/api_jsonrpc.php';
  4. Access demo/index.html from browser.
  • Login with user which have permission of API access
  • Login

  • Select Zabbix API method on dropdown list.
  • Method List

  • Click “Send Request”, the result of the request is displayed.

    Result

  • Method parameters for the request can set to click “Parameters” link
  • Parameters

    How to use jQuery plugin

    Upload jqzabbix.js and jquery-1.4.2.js to the web server.

    Include both of .js file in your application html file.

    <script type="text/javascript" charset="utf-8" src="jquery-1.4.2.js"></script>
    <script type="text/javascript" charset="utf-8" src="jqzabbix.js"></script>

    Create object with several options. These options are optional. Followings are default value.

    server = new $.jqzabbix({
        url: 'http://localhost/zabbix/api_jsonrpc.php',  // URL of Zabbix API
        username: 'Admin',   // Zabbix login user name
        password: 'zabbix',  // Zabbix login password
        basicauth: false,    // If you use basic authentication, set true for this option
        busername: '',       // User name for basic authentication
        bpassword: '',       // Password for basic authentication
        timeout: 5000,       // Request timeout (milli second)
        limit: 1000,         // Max data number for one request
    })

    Need to get API version and Login before using normal api method.

    server.getApiVersion();
    server.userLogin();

    If request is successful, API version and authentication id are stored in server property. If you need to execute some command when the function is success or error, need to specify success or error callback to these method like jQuery ajax request.

    var success = function() { alert('success!'); }
    var error = function() { alert('error!'); }
    
    server.userLogin(null, success, error)

    After execute getApiVersion() and userLogin() method, you can execute normal API method.

    server.sendAjaxRequest(method, params, success, error)
    • method: Zabbix API method listed on Zabbix API document
    • params: Zabbix API method parameters
    • success: Success callback function
    • error: Error callback function