ZABBIX
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
Contents |
Introduction
ZABBIX is software for monitoring of your applications, network and servers.
After installation Zabbix supports checks of ~100 network protocols. Further protocol checks can be added using shell-, C- or perlscripts. Zabbix understands the SNMP Protocol. It can create graphs of network-, cpu- or hard disk load, and so on. Many of these checks are done with agent software which is availabe for many platforms including Linux, Solaris, AIX, HP-UX, BSD, Windows, MacOS. Different views of a network can be defined for checks and documentation.
Prerequisites
Zabbix can use a number of database backends. This HOWTO focuses on using Zabbix with MySQL (HOWTO MySQL), but you can also use PostgreSQL or Oracle.
The only frontend currently available for Zabbix is the PHP-based web frontend, so you'll need a PHP compatible web server, such as Apache2 or lighttpd. See HOWTO Apache2 with PHP MySQL.
Use Flags
Much of the use flag information is directly from Zabbix's wiki; however, this is not an exhaustive listing of all available use flags for these packages.
MySQL
- berkdb: This provides support for berkley DB, which, while not required for Zabbix is very much recommended for MySQL and PHP.
PHP
- apache2: Tells PHP to build the mod_php support.
- berkdb: Tells PHP to use berkley DB for non MySQL bindings
- bzip2: Tells PHP to support file compression. This is optional, but I recommend it.
- bcmath: This is required for Zabbix
- gd: This tells PHP to support graphics creation. This is required by Zabbix for maps, graphs, and SLA support.
- gdbm: Tells PHP to add support for GDBM. Not required, but helpful to have, just in case.
- mysql: This tells PHP to add support for MySQL and is required to use Zabbix UI, if you are using MySQL database.
- pcre: This adds support for Perl Compatible Regular Expressions. Not required yet, but strongly recommend for compatibility with future features for Zabbix.
- session: This adds session support. This is a must. If this is left out, MySQL servers melt under load as multiple people look through Zabbix data and graphs.
- ssl: This adds SSL support for PHP. There are various patches out there for Zabbix that take advantage of this, but Zabbix itself does not require this. The Zabbix team recommends using it.
- threads: See session above.
- tokenizer: This adds tokenization support. Not required yet, but strongly recommend for compatibility with future features for Zabbix. When needed, it will be very helpful if you ever want to dig through Zabbix and customize it.
- unicode: This add unicode support. It is not really required if you are going to run Zabbix in english mode, but if you plan to use other languages it is required.
- xml: This adds basic XML parsing support to PHP and is required by Zabbix 1.4.x
- zlib: This provides basic deflate and gzip support to PHP which improves performance of your web server, so I recommend adding it.
Apache
- apache2: This forces Apache to be compiled with Apache 2 compliance. Not needed, but it is recommended.
- ssl: This provides SSL support, again, not needed, but recommended.
- threads This tells Apache to support threads as well. Without this, PHP will be unable to support threads or sessions. See warning above, under sessions.
SNMP
- perl: This provides a perl API into SNMP.
- ssl: This provides support for SNMPv2 and SNMPv3, as such it is required if you wish to support those versions.
Zabbix
- agent: Installs the monitoring agent.
- curl: Enables support for checking content on homepages.
- frontend: Installs the web frontend for Zabbix.
- jabber: Enables support for notices sent via Jabber.
- ldap: ?
- mysql: Allows MySQL database support for use with the Zabbix server.
- server: Installs the Zabbix polling server.
- snmp: Allows the Zabbix server to poll devices using SNMP. It is recommended to use this as it provides useful features.
- oracle: Allows Oracle database support for use with the Zabbix server.
- postgres: Allows PostgreSQL database support for use with the Zabbix server.
- sqlite3: Allows SQLite version 3 database support for use with the Zabbix server.
- vhosts: This gives the Zabbix frontend virtual server support.
Emerging
The Zabbix package has not been marked stable yet (Sep 2007). If you're the daring type who wants to use it anyway, start by adding the following line to /etc/portage/package.keywords where ~x86 must match to your machines architecture. In the new 1.4.x versions interesting features are implemented like autodetection of services or XML im-/export of Objects.
echo "net-analyzer/zabbix ~x86" >> /etc/portage/package.keywords
With version 1.4, Zabbix was consolidated into one ebuild for Gentoo. Add the following to your /etc/portage/package.use to gain the desired functionality from Zabbix.
On the Zabbix server machine:
echo "net-analyzer/zabbix server frontend" >> /etc/portage/package.use (add mysql, etc for the database you're using)
On clients machines you wish to collect statistics from and/or monitor:
echo "net-analyzer/zabbix agent" >> /etc/portage/package.use
Now emerge Zabbix with the following:
emerge -av zabbix
If you intend to use simple ICMP-checks (like ping-checks without installing the zabbix-agent) with your zabbix-server you have to install fping suid-root. To do this you have to do "chmod u+s /usr/sbin/fping" after emerging fping. Beware however that this might be a security risk!
Create the database
Perform the following on your database of choice. The instructions here are for MySQL; however, installation for other databases are very similar. Zabbix ships with .sql files to create the schema and populate it with data for us, so just use the corresponding files like we do in the following examples.
Log on to MySQL and give Zabbix access to its database.
# mysql -u <your MySQL root account> -p Enter password: <MySQL password> mysql> create database zabbix; mysql> grant all on zabbix.* to zabbix@localhost identified by '<some password for zabbix>'; mysql> flush privileges; mysql> quit
Populate the database with initial Zabbix tables and data.
mysql -uzabbix -p zabbix < /usr/share/zabbix/database/create/schema/mysql.sql Enter password: <MySQL password> mysql -uzabbix -p zabbix < /usr/share/zabbix/database/create/data/data.sql Enter password: <MySQL password> mysql -uzabbix -p zabbix < /usr/share/zabbix/database/create/data/images_mysql.sql Enter password: <MySQL password>
Edit /etc/mysql/my.cnf
There are a couple settings that need to be changed from Gentoo's default. The first is the bin log rotation setting. It is not rotated by default, and can quickly fill up your partition. The bin logs keep track of all actions that may change data (INSERT, UPDATE, DELETE, etc) and are primarily used to restore the database after a corruption (see the MySQL binary log documentation for more info). To delete the log every two days, add the following line to /etc/mysql/my.cnf under the mysqld code> section.
expire_logs_days = 2
Though not recommended, some users forgo the previous step and turn off the bin log completely. If you feel the logs are unnecessary then comment out the log-bin code> line.
#NOTE: I don't care about recovering from database corruptions and want to save disk space #log-bin
The other setting that needs to be changed is the InnoDB data file size.
innodb_data_file_path = ibdata1:10M:autoextend:max:128M
After a few days, this will lead to errors with the data history and graphs. Your requirements may vary, but replacing the above with the following should be sufficient.
innodb_data_file_path = ibdata1:128M;ibdata2:50M:autoextend:max:12800M
(Note: You may have to remove either or both ibdata1 or ibdata2 to get MySQL to work after changing the above line.) Credit for tracking down the above fix belongs to http://jon.netdork.net/2005/11/09/argh-table-full-1114/ For additional information read http://dev.mysql.com/doc/refman/5.0/en/innodb-configuration.html You may want to change the max size setting to fit your installation.
Configure Startup
On all machines you wish to monitor, you need to modify the files in /etc/zabbix. In particular, you need to point the SERVER= line to the IP address of the server where you are running the Zabbix server. In addition, each client running zabbix-agentd needs to have its hostname defined to a unique value (usually the simple hostname, fully qualified hostnames break remote command functionality).
Furthermore, the ListenIP=127.0.0.1 should be commented out on all clients where the server and front end are not running locally.
Add the daemons to the default runlevel
On all machines:
rc-update add zabbix-agentd default
On the zabbix server machine:
rc-update add zabbix-server default
Start them
/etc/init.d/zabbix-agentd start /etc/init.d/zabbix-server start
Configure the Web interface
Install the Zabbix frontend in a vhost:
webapp-config -h $vhost -I zabbix $version -d /$dir (for example: webapp-config -I zabbix 1.4.2 -d zabbix)
Zabbix requires that php be configured in a specific way. Edit /etc/php/apache2-php5/php.ini
date.timezone = America/Chicago (change to your timezone and uncomment the line) max_execution_time = 300 (Default is 30, Zabbix wants 300)
And restart Apache so that it sees these changes.
/etc/init.d/apache2 restart
You should now be able to get to a login screen under http://$vhost/$dir.
The initial credentials are 'Admin' with no password.
Updated: If you in some reasons dont want change default config /etc/php/apache2-php5/php.ini, you can do that in very intelligent way - put the file .htaccess in /zabbix/ folder on web:
php_value max_execution_time 300 php_value memory_limit 200M php_value post_max_size 200M php_value upload_max_filesize 200M php_value date.timezone Europe/Berlin
dont forget to change timezone, etc..
Adding Hosts to Monitor
http://www.zabbix.com/manual/v1.1/qs.host.agent.php
User-Defined Monitored Parameters
Users can define their own monitored parameters in zabbix_agentd.conf To use the parameters below, just copy and paste them into your zabbix_agentd.conf and restart zabbix-agentd.
General
number of packages installed on a Gentoo system
UserParameter=gentoo.packages_installed,find /var/db/pkg/*/* -type d | wc -l
disk usage (percent used)
UserParameter=system.hd,df -h | grep /dev/hda3 | tr -s " " | cut -d " " -f 5 | cut -d % -f 1
memory usage (megabytes used)
UserParameter=system.mem,free -mt | grep + | tr -s [:space:] | cut -d ' ' -f 3
load average (for the past minute)
UserParameter=system.load,uptime | tr ' ' '\n' | tail -n 3 | head -n 1 | cut -d ',' -f 1
Apache Webserver
You can monitor the apache webserver using the examples below. All of them require mod_status (it comes with apache by default and its trivial to enable).
Total Accesses
UserParameter=apache.accesses,wget --quiet -O - http://localhost/server-status?auto | head -n 9 | grep Accesses | cut -d " " -f 3
Total kBytes
UserParameter=apache.totalkb,wget --quiet -O - http://localhost/server-status?auto | head -n 9 | grep kBytes | cut -d " " -f 3
CPU Load
UserParameter=apache.cpuload,wget --quiet -O - http://localhost/server-status?auto | head -n 9 | grep CPULoad | cut -d " " -f 2
httpd uptime
UserParameter=apache.uptime,wget --quiet -O - http://localhost/server-status?auto | head -n 9 | grep Uptime | cut -d " " -f 2
Requests per second
UserParameter=apache.reqpersec,wget --quiet -O - http://localhost/server-status?auto | head -n 9 | grep ReqPerSec | cut -d " " -f 2
Bytes per second
UserParameter=apache.bytespersec,wget --quiet -O - http://localhost/server-status?auto | head -n 9 | grep BytesPerSec | cut -d " " -f 2
Bytes per request
UserParameter=apache.bytesperrec,wget --quiet -O - http://localhost/server-status?auto | head -n 9 | grep BytesPerReq | cut -d " " -f 2
Busy Workers
UserParameter=apache.busywokers,wget --quiet -O - http://localhost/server-status?auto | head -n 9 | grep BusyWorkers | cut -d " " -f 2
Idle Workers
UserParameter=apache.idleworkers,wget --quiet -O - http://localhost/server-status?auto | head -n 9 | grep IdleWorkers | cut -d " " -f 2
Troubleshooting
To make sure Zabbix is working, start by looking at the Reports page from the top menu. The "ZABBIX Server is running" line should say "YES". If it doesn't, try the command 'rc-status' and make sure zabbix-server is listed as 'started'. If not, try '/etc/init.d/zabbix-server start'.
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should be using interactive floor plans and list their apartments, townhouses and units.
