How to get the Farm List with ZAPI v1

13 October, 2015 | Technical

Hi Zen Masters, today we bring an example about how to use our Zen Load Balancer API! This article presents the use of this API to get a farm list with the name, profile and status parameters of all created farms.

Zen Load Balancer API (ZAPI)

This ZAPI allows you to use the powerful Zen Load Balancer without the graphical user interface (GUI) through several commands using curl (a command line tool for getting or sending files using URL syntax).

If you want to use this API, go to ‘Users’ section (in Zen GUI) and enable zapi user.

Once zapi user is enabled, it’s necessary to set a key (custom or random key) and a password. These parameters are required to use the ZAPI.

For the following example, these parameters will be used:

Key: CiEuYlS4GtfSq3yrknv0YMnA7j5fhm4piVZh49yt5JcjQ0aDyxImz2Y7DAUhstce5
Password: admin
Zen Load Balancer IP: 192.168.101.25
Zen Web Port: 444

How to get the farm list with ZAPI

In the first place we have to open a terminal where the commands will be introduced. Then let’s get the farm list with a GET request:

curl --tlsv1 -k -X GET -H 'Content-Type: text/json' -H "ZAPI_KEY: CiEuYlS4GtfSq3yrknv0YMnA7j5fhm4piVZh49yt5JcjQ0aDyxImz2Y7DAUhstce5" -u zapi:admin  https://192.168.101.25:444/zapi/v1/zapi.cgi/farms

HTTP verb: GET, used for getting parameters of farms, backends, services…
JSON parameters: None.
URI parameters: None.

Once this command is launched, the following response will be shown:

{
    "description" : "List farms",
    "params" : [
        {
            "farmname" : "FarmTCP",
            "profile" : "tcp",
            "status" : "up"
        },
        {
            "farmname" : "FarmHTTP",
            "profile" : "http",
            "status" : "up"
        },
        {
            "farmname" : "FarmDATALINK",
            "profile" : "datalink",
            "status" : "up"
        },
        {
            "farmname" : "FarmL4",
            "profile" : "l4xnat",
            "status" : "down"
        },
        {
            "farmname" : "FarmGSLB",
            "profile" : "gslb",
            "status" : "up"
        }
    ]
}

As we can see, there are 5 farms in our virtual machine with Zen Load Balancer. All these farms are ‘up’ except the L4xNAT farm called FarmL4.

ZAPI Advantages

This ZAPI is a powerful tool that allows you to use and configure Zen Load Balancer thought curl. What are the advantages of getting this tool?

  • Use of an external software through ZAPI. For example a monitoring software like Nagios.
  • Load balancing automation with ZAPI to view, create, delete and modify resources in the load balancer.
  • It’s included in your Zen Load Balancer Enterprise Edition 4.0 (or higher) version!

There is a detailed documentation about all the possible commands and examples of a success execution here
https://www.relianoid.com/zapidoc/.

We hope you enjoy the ZAPI experience!

SHARE ON:

Related Blogs

Posted by reluser | 28 October 2024
The Hypertext Transfer Protocol (HTTP) is the foundation of data communication for the web. HTTP/2, the second major version of the protocol, represents a significant evolution from HTTP/1.1, designed to…
59 LikesComments Off on Understanding HTTP/2 Load Balancing
Posted by reluser | 30 September 2024
Operational Support Systems (OSS) and Business Support Systems (BSS) are vital for the efficient functioning of telecommunications companies, such as mobile, fixed-line, and Internet operators. These systems serve different purposes…
76 LikesComments Off on OSS/BSS reliability for Telecom industry support systems
Posted by reluser | 26 July 2024
The Netdev 0x18 Conference, held from July 15th to 19th, 2024, in Santa Clara, California, brought together leading minds in Linux networking for a week of insightful presentations, technical sessions,…
126 LikesComments Off on Netdev Conference 0x18: A Deep Dive into the Future of Linux Networking