Configuring Zabbix

Configuring Zabbix

Zabbix is configured via a PHP web interface. This is either good or bad news, depending on your point of view. Personally, I prefer to configure things with text files. This is mainly because I can look at them, when I come back to the system after some time, and read them to get an idea of what I was trying to do.

Zabbix Concepts

A quick run-through of the basic conceptual model of a zabbix installation is a big help, when you're getting started.

The Zabbix Server

The zabbix server is the heart of a monitoring setup. The zabbix server holds the configuration database and serves the web interface that you use both to configure your monitoring and to see status information and graphs of historical data. The zabbix server fires 'questions' to a zabbix agent running on each monitored host. A question might be "what is your current CPU load?", or "what percentage of /home is free disk space?"

The Zabbix Agent

This runs on all monitored hosts, listening (on port 10050, by default, although you can change that) for questions from the zabbix server, and responding with the answers.

Whatever port the agent is listening on (10050, by default) must be accessible from the zabbix server. So, you may need to open up a hole in your firewall to allow the server to talk to the agent.

Configuration Entities

On the configuration side of things, these are the main entities you need to know about;

  • Hosts - these are the servers (or routers, switches or whatever) that you are monitoring. Hosts can be grouped into, surprise surprise, host groups.
  • Items - these are the data items or properties that you are monitoring. e.g. free disk space, server load, network traffic or a whole host of other items. Items are grouped into "Applications".
  • Triggers - conditions that you care about. e.g. the server load on a particular host is higher than 5, or there is less than 10% disk space free on the home partition. Triggers apply to items, and may be simple or complex thresholds. Triggers have a severity, so less than 10% free disk space could be a "warning", but the web server going down might be a "disaster".

  • Actions - things that you want to happen in response to a trigger switching on or off. e.g. send a warning message to all the users in the "sysadmin" group if any triggers switch on whose severity is "warning" or higher.
  • Templates - templates simplify the configuration process by allowing you to define sets of items, triggers and graphs (which we haven't talked about yet), which you can then apply to one or several hosts at the same time. Zabbix comes with some pre-defined templates, such as one to set up typical monitoring of a Linux host, and you can easily define your own.

Setting up monitoring of a host

This is a quick walk-through of setting up monitoring of a single host by applying a pre-defined zabbix template. I'm using Zabbix version 1.4.1, which is the version you currently get if you install zabbix on Ubuntu 7.10 Gutsy Gibbon via apt.

Client configuration

The zabbix agent must be running on the host you want to monitor. On a Fedora, or similar, Linux server, you should be able to install the agent using the "yum" package manager;

$ sudo yum install zabbix-agent

On an ubuntu or other Debian-type server, use apt;

$ apt-get install zabbix-agent

The zabbix agent needs very little configuration, but you do need to tell it the zabbix server's IP number. The zabbix agent will only answer questions it receives from this IP.

$ sudo vi /etc/zabbix/zabbix_agentd.conf

Look for the line "Server=" and change the IP to that of your zabbix server. If you want the zabbix agent to listen on a non-default port, change the value on the "ListenPort" line and uncomment it.

You should also add the zabbix agent to your system startup, so that it runs on boot;

$ sudo vi /etc/rc.local

Add this line;

/etc/init.d/zabbix-agent start

That's it for the client-side configuration. You should check that the agent is running by doing a "ps aux | grep zabbix-agent".

Server Configuration

Now we need to set up the server so that it will periodically ask the host some questions, and show us the answers.

1. Login as an administrator

Login to the web interface of your zabbix server.

The default zabbix login is "admin", with no password. If your zabbix server is exposed to the Internet, or even if it's not, you really should change that.

2. Click on "Configuration" then "Hosts", then "Create Host"

Make sure the selection box next to the "Create Host" button has "Hosts" selected.

Enter the details for your new host. The "Connect to" drop-down is used to tell zabbix how it should try to reach your host when it gathers item data. In my case, I'm using the IP number.

Port 10050 is the default port on which the zabbix agent listens. If you are planning to use a different port, enter it here.

3. Add a template

In the "Link with Template" section, click on the "Add" button.

Check the box next to the default "Template_Linux" template and click the "Select" button.

Now click the "Save" button on the host details page.

You should see a screen like this, showing that a host of monitoring items have been added to your server.

If you click on "Monitoring", "Latest data", and select your server from the drop-downs, you should see the data being gathered from your server.

This is a very basic introduction to setting up monitoring using zabbix. There is a lot more that can be done, and I'm planning to cover some of them in future posts.