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

Following the development


So, you have seen some interesting new feature in the monthly development update, and you want to try it out. Maybe you want to check exactly how a particular change was implemented. Or maybe you would like to produce a patch which depends on some changes being made in the development version.

Zabbix stores all its source code in a code repository, namely a Subversion one. As an open source project, it also provides access to this repository to everybody, so it is possible to take a look at how a development version is shaping up. In general, there are many possibilities - not unique to Zabbix, but possible because of the open source approach that open this way. Some might be:

  • Trying out new a development version out of curiosity

  • Testing the development version to provide feedback sooner in the development cycle

  • Using the development version to create patches

  • Providing feedback and improving documentation of new features

Providing early feedback is also an influential method to impact future of Zabbix if a particular feature is important to you, testing it early and letting developers know about any problems you find with it and what improvements are possible is more likely to result in those changes happening.

The first thing we have to solve is actually getting the source.

Getting the source

When looking for the Zabbix development version, there are two ways to get it, each with it's strengths and weaknesses.

Daily snapshots

On the Zabbix development download page, http://www.zabbix.com/developers.php, there are daily snapshots of development versions provided. These usually have the same setup procedures as the released versions. Benefits of using daily snapshots include:

  • Getting them is a simple download

  • The package is already generated for you

drawbacks include:

  • No way to update only those parts of the development version that have actually changed

  • No way to see what actually has changed

  • No way to get some arbitrary older version

It is suggested to use daily snapshots if you want a simple, one time peek at how Zabbix's development is progressing.

Accessing the version control system

If you plan to follow Zabbix development for a longer time period, or you want to see how exactly a particular change was implemented, daily snapshots would soon become cumbersome to use. Luckily, we can directly access the system Zabbix developers themselves use, a popular version control system Subversion or SVN.

To access SVN repositories, some specific software, a client, is needed. There are many different SVN clients for various platforms, and you can choose whichever seems more convenient to you. Here we will use the official command line client. As this client is available in almost all Linux distributions, you may want to use it on our Zabbix test server. But before we start playing with it, we must know that the Zabbix source code repository resides at svn://svn.zabbix.com. In SVN, development is usually split into a trunk and branches. While the trunk represents the most recent development work, branches usually are used for stable version maintenance. Zabbix uses the same schema, and there are branches for stable version maintenance like 1.6 while 1.8, and big changes happen in the development section, trunk.

So let's say we are interested in latest new features and want to retrieve trunk. To do this, create some directory to hold the data, called checkout. Enter it and run:

$ svn checkout svn://svn.zabbix.com/trunk

This will proceed to retrieve all the files in the trunk. As of this writing, Zabbix trunk checkout uses approximately 114 MB on disk, but the amount transferred over the network will be smaller than that. Once the process completes, you might be tempted to proceed but that won't be easy to do, as there is no configure script at all. According to Zabbix scripts, we should now execute some commands to create this script:

$ aclocal -I m4
$ autoconf
$ autoheader
$ automake -a
$ automake

Note

Since February, 2010, you can simply launch script named bootstrap.sh instead of the commands above.

After these are completed, we should have the configuration script. Now we can compile this development version of Zabbix, right? Not quite yet. Development repositories hold only generic database schema, so we would not be able to create the database. We will have to generate the actual schema files ourselves. It is also suggested to create a package, one just like those downloadable from Zabbix site, so let's do that. Before we can generate the database schema and package, we have to use configure script, though. But we can make it slightly faster and requiring less dependencies by omitting any features that are not required. This also allows the creation of a Zabbix package on another machine that would not have all dependencies for the required functionality like SNMP or IPMI monitoring installed. In the simplest approach, run:

$ ./configure

This will produce the files required for database schema and package generation. Now we can proceed with schema generation:

$ make dbschema

With database schema files generated, we are ready to create a package:

$ make dist

After this command completes, the source directory should have a new package named zabbix-<version>.tar.gz. Here, the version will be whatever name the development part has received. As we discussed before, odd numbers are used for development versions, so it could be named 1.9, for example. From now on we are back to the known path, as this package pretty much the same you can download from released version area or from the daily snapshots area.

But that was a lot of work to get the same thing as we could have downloaded right away - why do it at all? Indeed, if you only want to grab development version once, daily snapshots should be your choice. But SVN checkout presents other benefits. Let's see what they are.

Looking at the changesets

A collection of changes to repository is called changeset. A changeset that has been placed in a repository is said to be committed. We can list changesets being committed. For example, if we would like to know what the last two changesets that were committed to this part of the repository, we would issue:

$ svn log -r PREV:HEAD

The Subversion switch -r allows us to specify revisions - numeric representations of each change. PREV and HEAD are special references, being the previous change and latest version respectively. Sometimes we might be instructed to test or use a specific version, called revision. In that case, it is possible to retrieve it by issuing:

$ svn up -r 1234

Replace 1234 with the revision number you are told to use. This will update the whole checkout to that revision, and you should now run again the commands discussed above, repeating the same process as after just having checked out. But sometimes we might need to update only one or a few files to a specific revision - that can be done by specifying path, for example:

$ svn up -r 1234 frontends/php/discovery.php

You can specify both directories and files and get different revisions to test behavior changes or find the specific change that introduced a problem for you.

So you have tried out a development version, maybe several revisions. Some time later, you decide to find out what changes have been made to the trunk. First, the current revision should be figured out, while in the checkout directory, run the following command:

$ svn info

Look for the line that looks like this:

Revision: 8000

With that number on hand, it is now time to update local copy to the latest and greatest. From the local copy directory, run:

$ svn up

This will proceed to update everything that has changed, compared to whatever copy you have. As only changes are pulled, this will result in much less data downloaded, compared to downloading daily snapshots over and over again. Now you can just proceed with building Zabbix as discussed before, or you can choose to view what exact changes developers have committed:

$ svn log -r 11000:HEAD

This command will display the exact changes pushed to the code repository, along with any comments that the developers decided to add. This can be used to determine what exactly was changed. But all this about forward looking development version, trunk - what if you want to see a particular bug fix for some problem in the stable version, applied to that particular branch? Just as we grabbed the trunk from the code repository, we can also grab the branch. Create a separate directory to hold this checkout, and issue:

$ svn checkout svn://svn.zabbix.com/branches/1.8

As we can see, instead of the trunk we are now specifying the subsection branches. After that comes the specific branch, which can be any valid branch.

Note

Available branches can be listed with svn ls svn://svn.zabbix.com/branches.

While installing a branch version is pretty much the same as installing the trunk, there's one more use case with branches. If a particular bug is fixed in the branch and you want to benefit from that before the next stable version is out, it is possible to apply this single change to the installed copy. To do that, though, the change first has to be extracted in a format that is easy to reuse. Here, another command comes to help. Remember svn log we used to look at the changesets before? It showed the revision number for each changeset. If we now have this number, we can take a look at what files a particular commit modified.

$ svn log -v -c 8001

Here we use the switches -c to specify single changeset and -v to increase verbosity level. In the Changed paths section one or more files will be listed, for example:

M /trunk/ChangeLog
M /trunk/src/zabbix_server/operations.c

When creating a patch, we might want to omit files that do not affect actual software behavior, ChangeLog in this case. Creating a patch thus would be done like this:

$ svn diff -c 8001 src/zabbix_server/operations.c > /tmp/zabbix.patch

Notice how we used Subversion's diff subcommand, specified a single file, and redirected output to a file. Now the patch should be applied to our Zabbix installation. To do this, transfer the patch file to Zabbix source installation directory and execute:

$ patch -p 0 -i zabbix.patch

The patch utility is instructed use input file zabbix.patch and use full path information as specified to apply the changes. After patching we should evaluate areas the patch applies to - if it's the server, we should recompile and reinstall our server binary, the same with the agent daemon. If changes were performed on the frontend only, we'll usually want to apply the patch to the installed frontend directly, by placing the patch in the frontend directory and applying it as root with:

# patch -p 2 -i zabbix.patch.

Note that in this case we are instructing the patch utility to strip the first two directories from the path. When we are patching the frontend, no recompilation is necessary, and all changes will be visible immediately. What if we applied a patch, but it only made things worse? Thankfully, that is easy to undo by applying the same patch in reverse:

# patch -R -p 2 -i zabbix.patch

If using the above command line for the frontend, again, no further action is required. If it affects binaries, we would have to recompile them.

Note

See the SVN documentation for more detailed instructions, or ask in the Zabbix IRC channel for Zabbix specific Subversion repository questions.