Zabbix Walkthrough

FIXME We do not use Zabbix any longer. This guide will not receive updates.

Basic Setup

  • Debian Squeeze 64bit (so we don't have to go with backports)
  • MySQL because I suppose it is easier than Postgres for most people
  • We use lighttpd, but it will run with Apache or anything else, as well

Install dependencies

aptitude install mysql-server php5 lighttpd

Get those things up and running and we're ready to install the Zabbix Server

Install Zabbix Server

Zabbix is split in three components that we need. Server, Frontend and (since we als want to monitor our www Server) the Agent.

aptitude install zabbix-server-mysql

Follow Debconf Instructions

In case you chose a random password:

cat /etc/zabbix/zabbix_server.conf | grep DBPassword

You need that password to install the Frontend

aptitude install zabbix-frontend-php

Follow Debconf and as DB Password give the password retrieved from zabbix Server

Now there are three things left to do:

  1. Fix the DB Username and DB Name the zabbix-frontend-php installed with
  2. Get it to work with our Webserver
  3. Tweak some php Settings
vi /etc/zabbix/dbconfig.php
Replace the Database Name with "zabbixservermysql" and the User with "zabbix-server-my"
:q
touch /etc/lighttpd/conf.d/zabbix.conf
echo "alias.url += ( "/zabbix" => "/usr/share/zabbix" )" > /etc/lighttpd/conf.d/zabbix.conf

In case you use Apache there is a config for it in /etc/zabbix which only needs to be copied over to apaches config directory

vi /etc/php5/cgi/php.ini
post_max_size = 32M
max_execution_time = 300
max_input_time = 300
Also set your php timezone

Now restart lighttpd and zabbix-server and it should be reachable with your browser.

Install Zabbix Agent

aptitude install zabbix-agent
vi /etc/zabbix/zabbix_agent.conf
set Server and increase the timeout maybe
vi /etc/zabbix/zabbix_agentd.conf
set Server,
set Hostname
increase timeout if necessary

Now start zabbix-agent

Firewall

In case you use iptables you need to open port 10050 on the client side and 10050 and 10051 on the server side (or any other port of course if you configured Zabbix to use non-standard ports). As an alternative you can also use Active Checks which don't require open Ports on the Nodes that are to be monitored and also help to reduce load on the Server side, since the Client does all the work itself in this case.

Advanced

stunnel

UserParameter=hdd.sda.temperature,/etc/zabbix/scripts/get_smart_value.sh /dev/sda Temperature_Celsius UserParameter=hdd.sda.raw_read_error_rate,/etc/zabbix/scripts/get_smart_value.sh /dev/sda Raw_Read_Error_Rate UserParameter=hdd.sda.reallocated_sector_count,/etc/zabbix/scripts/get_smart_value.sh /dev/sda Reallocated_Sector_Ct

UserParameter=hdd.sdb.temperature,/etc/zabbix/scripts/get_smart_value.sh /dev/sdb Temperature_Celsius UserParameter=hdd.sdb.raw_read_error_rate,/etc/zabbix/scripts/get_smart_value.sh /dev/sdb Raw_Read_Error_Rate UserParameter=hdd.sdb.reallocated_sector_count,/etc/zabbix/scripts/get_smart_value.sh /dev/sdb Reallocated_Sector_Ct

Some suitable alternatives to Zabbix, since not used anymore are as follows:

Custom Scripts

md

Here is a small script for monitoring md. It can only monitor Raid1 systems so far, since we don't have the need to monitor Raid5 or anything else. Feel free to expand this in case you need it.

#!/bin/bash
if [ $# -ne 1 ];
then
echo "Usage: $0 "
exit
fi
var_mdnum="$1"
if [[ "$var_mdnum" != md* ]]
then
var_mdnum=`echo $var_mdnum | sed 's/\/[a-z]*\/md*/md/'`
fi
if [ `cat /proc/mdstat | grep -C 1 $var_mdnum | grep -o UU` == "UU" ]
then
echo 0
exit
else
echo 1
exit
fi

Put something like

UserParameter=raid.md0.status, /etc/zabbix/scripts/get_md_status.sh md0

in your zabbix_agentd.conf to use this and configure an Item for it on the Zabbix Server for the node you wish to use this for or in its underlying template.

Smart

#!/bin/bash
if [ $# -ne 2 ];
then
echo "Usage: $0 <device> <parameter>"
exit
fi
 
sudo smartctl -A $1 | grep $2 | tr -s ' ' | sed "s/^[[:space:]]*\(.*\)[[:space:]]*$/\1/" | cut -d " " -f 10

Make sure smartmontools are installed and accessible for Zabbix. You might need something like

%zabbix ALL= NOPASSWD: /usr/sbin/smartctl

in your sudoers file.

Here are my UserParameters:

UserParameter=hdd.sda.temperature,/etc/zabbix/scripts/get_smart_value.sh /dev/sda Temperature_Celsius
UserParameter=hdd.sda.raw_read_error_rate,/etc/zabbix/scripts/get_smart_value.sh /dev/sda Raw_Read_Error_Rate
UserParameter=hdd.sda.reallocated_sector_count,/etc/zabbix/scripts/get_smart_value.sh /dev/sda Reallocated_Sector_Ct
 
UserParameter=hdd.sdb.temperature,/etc/zabbix/scripts/get_smart_value.sh /dev/sdb Temperature_Celsius
UserParameter=hdd.sdb.raw_read_error_rate,/etc/zabbix/scripts/get_smart_value.sh /dev/sdb Raw_Read_Error_Rate
UserParameter=hdd.sdb.reallocated_sector_count,/etc/zabbix/scripts/get_smart_value.sh /dev/sdb Reallocated_Sector_Ct

FPing

When using Active Checks you might still want to Monitor a hosts uptime. For this you need to install fping on the Server and do a chown root:zabbix on its binary for zabbix to be able to use it.

setup/zabbix.txt · Last modified: 2017/04/12 20:38 by linxugeek