Book Image

Zabbix 1.8 Network Monitoring

By : Rihards Olups
Book Image

Zabbix 1.8 Network Monitoring

By: Rihards Olups

Overview of this book

Imagine you're celebrating the start of the weekend with Friday-night drinks with a few friends. And then suddenly your phone rings -- one of the servers you administer has gone down, and it needs to be back up before tomorrow morning. So you drag yourself back to the office, only to discover that some log files have been growing more than usual over the past few weeks and have filled up the hard drive. While the scenario above is very simplistic, something similar has happened to most IT workers at one or another point in their careers. To avoid such situations this book will teach you to monitor your network hardware, servers, and web performance using Zabbix- an open source system monitoring and reporting solution.The versatility of Zabbix allows monitoring virtually anything, but getting started with the new concepts can take some time. This book will take you through the most common tasks in a hands-on, step by step manner.Zabbix is a very flexible IT monitoring suite, but not every part of it is immediately clear to new users. Following the instructions in this book should allow you to set up monitoring of various metrics on various devices, including Linux and Windows machines, SNMP devices, IPMI enabled server,s and other network attached equipment. You will learn to define conditions – such a temperature being too high or service being down – and act upon them by notifying user by email, SMS, or even restarting service. You will learn to visualize the gathered data with graphs and the various tips and tricks that are provided will help to use Zabbix more efficiently and avoid common pitfalls.This book covers setting up Zabbix from the scratch and gradually introduces basic components of Zabbix, moving to more advanced topics later. Book's scope is based on the author's experience of working with Zabbix for many years, as well as on the questions users have asked on the Zabbix IRC channel and forums.
Table of Contents (22 chapters)
Zabbix 1.8 Network Monitoring
Credits
About the Author
About the Reviewers
Preface
6
Acting Upon Monitored Conditions

The Web frontend


Now that we have the Zabbix server and agent compiled, installed, and running, there's probably a feeling that something's missing. We have only configured some low-level behavior, so where's the meat?

That's what the frontend is for. While in theory Zabbix can have multiple frontends, the only one with full functionality so far is web frontend, which was written in PHP. We have to set it up to configure Zabbix and get to those nice graphs everybody likes.

Prerequisites and setting up the environment

Of course, being a web frontend, it will require a platform to run on; a web server with a PHP environment. We will need the following installed:

  • A web server that is supported by PHP; Apache is the most common choice

  • PHP version 5

It is easiest to install these from distribution packages. For PHP we'll also need the following functionality:

  • GD

  • MySQL

  • BCmath

  • mbstring

Note

Some distributions split out core PHP modules. These might include php5-ctype and php-net-socket.

Once you have all these installed, it's time to set up the frontend. First, you have to decide where the frontend code has to go. Most distributions that package web servers use /srv/www/htdocs or /var/www. If you compiled the Apache web server from source, it would be /usr/local/apache2/htdocs (unless you manually changed the prefix or installed an older Apache version). We will place the frontend in a simple subdirectory, zabbix.

Assuming you have distribution packages installed with the web root directory at /srv/www/htdocs, placing the frontend where it is needed is as simple as executing it as root:

# cp -r frontends/php /srv/www/htdocs
# mv /srv/www/htdocs/php /srv/www/htdocs/zabbix

Now it's time to fire up a browser and navigate to Zabbix's address: http://<server_ip_or_name>/zabbix. It should work just fine in the latest versions of most browsers, including Firefox, Opera, Konqueror, and Internet Explorer.

Installation of the web frontend

The web frontend has a wizard that helps you to configure its basics. Let's go through the simple steps it offers.

Step 1 Welcome

If everything is configured properly, you should be greeted by the installation wizard:

If you are not, there are several things that could have gone wrong.

If you see a blank page or some PHP code, make sure that PHP is properly installed and configured to parse files ending with the extension php through the AddType application/x-httpd-php directive. If you see a file and directory listing instead of the installation wizard, make sure you have added index.php to DirectoryIndex directive. If these hints do not help, check the PHP documentation available at http://www.php.net/manual/en/.

This screen doesn't offer us much to configure, so just click Next > >.

Step 2 Licence

On the second screen you are presented with the license, GPLv2. Hopefully you have no objections to this license, so check the I agree box and click Next > > again.

Step 3 PHP prerequisites

In this step, the installation wizard checks PHP-related prerequisites. If you are lucky, all will be satisfied, and you will be greeted with all green entries.

If so, the Next > > button will be enabled, and you just have to click on it to continue to step 4.

Though, more often than not, one or more entries will have a red Fail warning listed next to them. This is where things get more interesting. Problems at this point fall into two categories PHP installation, and configuration.

Entries like PHP version, PHP Databases support, PHP BC math PHP MB string, GD Version, and Image formats are PHP installation problems. To solve these, either install the appropriate distribution packages (sometimes called php5-bcmath, php5-gd, php5-mysql, and so on), or recompile PHP with the corresponding options.

PHP Memory limit, PHP post max size, PHP max execution time, PHP Timezone , and PHP MB string overload are configuration issues that are all set in the php.ini configuration file. This file is usually located at /etc/php5 or similar for distribution packages, and /usr/local/lib for PHP source installations. Set the following options:

memory_limit = 128M
post_max_size = 16M
max_execution_time = 300
mbstring.func_overload = 2

For timezone, set the date.timezone option to a timezone that best matches your environment. For Zabbix home it's Europe/Riga, and you can see valid options at http://www.php.net/manual/en/timezones.php

Note

Since Zabbix version 1.8.2 mbstring.func_overload is not required anymore.

If you can't find php.ini, or you make changes but installation wizard does not pick them up, create a file named test.php in htdocs directory with only this content:

<?php phpinfo() ?>

Navigate using your browser to this file and check the value for entry Configuration File (php.ini) Path - that's where you should look for php.ini.

Once everything is fixed, click Retry button, and you should see more green entries.

Now the Next > > button should be enabled, click on it to continue.

Step 4 Database access.

Remember the database we created before? That's the information we'll insert here. Default database Type, Host, and Port should work for us. Set both Name and User to zabbix. If you have forgotten the password, just look it up or copy it from /etc/zabbix/zabbix_server.conf. After entering the data, click the Test connection button. If all the information is correct, the status should be Ok, so click Next > > again.

Step 5 Zabbix server details

The next screen specifies the Zabbix server location, with defaults being suitable for us, so Next it is again. The following screen is a summary of choices made in the previous screen.

Step 6 Summary

If you left the defaults where appropriate and your database connection test was successful, it should be safe to continue by clicking Next > >.

Step 7 Writing the configuration file

It is quite likely that in the next screen you will be greeted with failure. The installation wizard attempted to save the configuration file, but with the access rights that it has, that should not be possible. There are two possible solutions:

  • Click Save configuration file and place this file in the htdocs/zabbix/conf directory.

  • Make a directory htdocs/zabbix/conf writable by web server user (execute as root):

    # chown <username> /path/to/htdocs/zabbix/conf
    # chmod 700 /path/to/htdocs/zabbix/conf
    

Obviously, we need to insert the correct username and directory in the above commands. Remember, common locations were /srv/www/htdocs and /usr/local/apache2/htdocs, use the one you copied the Zabbix frontend code to. Common users are wwwrun, www-data, nobody, and daemon you can find out what the correct user for your system is by running:

$ ps aux | grep http

The username that most httpd processes are running under will be the correct one. Once the permissions have been changed, click Retry. That should successfully save the configuration file.

Note

You can also skip configuration wizard by copying zabbix.conf.php.example in the conf directory to zabbix.conf.php and editing it directly.

It is suggested that you restrict the permissions on this file afterwards to be readable only by web server user, by issuing as root:

# chmod 400 /path/to/htdocs/zabbix/conf/zabbix.conf.php
# chown <username> /path/to/htdocs/zabbix/conf/zabbix.conf.php

The file contains the database password which is better kept secret.

Note

It is possible to personalize Zabbix frontend installation a bit. Adding in the zabbix.conf.php configuration file after the line that starts with $ZBX_SERVER_PORT another line $ZBX_SERVER_NAME = "Test server"; will make all pages in Zabbix setup use this name in page titles and display it in the upper-right corner of the frontend, so it would be easier to distinguish this installation from the production instance created later.

Step 8 Configuration file in place

After successfully performing this step and clicking Retry, the installation wizard should be happy, so do as it says and click Next.

Step 9 Finishing the wizard

Congratulations, this is the last wizard screen which only wants you to be friendly to it and press Finish.

Step 10 Logging in

Immediately after clicking Finish you should see a login form.

The Zabbix database data that we inserted previously also supplied the default username and password, so enter admin as the Login name, and zabbix as the Password.

That should get you to the initial frontend screen, which doesn't show much; it only greets you.

Congratulations! The web frontend is now set up and we have logged in.

Note that with some browsers it is possible that you will see either the same page or a blank screen after pressing Finish in the installation wizard, or after logging in. If that is the case, you can try either refreshing the page, or opening the Zabbix root URL, http://<server_ip_or_name>/zabbix.

This view isn't too exciting, so let's check whether the frontend can see if the Zabbix server is running. Hover your mouse over Reports and click Status of Zabbix, the very first report.

So that's some more information already. The frontend successfully sees that Zabbix server is running. It also knows some basic things about Zabbix's configuration there are in total 43 hosts configured. Wait, what's that? We have only set it up and did not configure anything, how can there be 43 hosts already? Let's take a closer look at the Details column. Those values correspond to descriptions in parenthesis, located in Parameter column. So there are 0 monitored hosts, 1 that is not monitored and 42 templates. Now that makes more sense 42 of those 43 are templates, not actual hosts. Still, there's one host that isn't monitored, what's up with that?

Hover your mouse over Configuration and choose Hosts.

So there it is. It turns out that the default Zabbix database already has one server configured; the local Zabbix server. It is disabled by default, as indicated in the Status of Zabbix screen and here by Not monitored string in Status column.