Tuesday, 9 December 2014

Zabbix 2.2 верхом на nginx + php-fpm и mariadb

Source: here , added to blog to remember :)

I used nginx configs and agent config  - all worked for me, Centos 7


Zabbix 2.2 верхом на nginx + php-fpm и mariadb tutorial recovery mode



Хочу отметить, что эта инструкция родилась в процессе внедрения Zabbix в стенах компании Acronis.
В процессе экспертизы и проведенных мною исследований, она доказала свое право на жизнь и благополучно служит нам верой и правдой день изо дня.


Перед нами стоит нетривиальная задача, добиться максимальной производительности известной системы мониторинга zabbix.
Среди многих статей в интернете, есть много описаний типовых установок этой системы. Я подробно опишу, как заставить работать zabbix быстрее.
В качестве базовой системы я буду использовать CentOS 6.4. Так же как и многие я люблю Debian, Gentoo и все остальные дистрибутивы, но эта статья именно для CentOS.

Все что нужно делать я распишу подробно и шаг за шагом, и начнем с базовой настройки нашего CentOS


# Выключаем SELINUX
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

# Настраиваем часовой пояс
ln -sf /usr/share/zoneinfo/Europe/Moscow /etc/localtime

# Запускаем синхронизацию времени 
yum install ntp -y
chkconfig ntpd on
/etc/init.d/ntpd stop
ntpdate 0.ru.pool.ntp.org 1.ru.pool.ntp.org 2.ru.pool.ntp.org 3.ru.pool.ntp.org
/etc/init.d/ntpd start


# Устанавливаем вспомогательные компоненты
yum install wget nano wget ntpdate -y 

# Эти репозитории должны быть, очень много пакетов что нет в базовых репозиториях, мы найдем тут
wget dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
rm *.rpm -f


# Этот репозиторий нам пригодится но мы его выключим по умолчанию 
rpm --import dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
cd /tmp
wget dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm && rpm -ivh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm


# Выключаем, будем использовать через --enablerepo=rpmforge 
sed -i 's/enabled = 1/enabled = 0/g' /etc/yum.repos.d/rpmforge.repo

# А вот это жемчужина для web систем и не только, тут действительно есть очень много того, что нужно администратору в своей работе. MustHave
wget -q -O - http://www.atomicorp.com/installers/atomic | sh

# Ставим полезный софт 
yum install nano mc screen sudo nscd htop ntp zip unzip pigz iotop sysstat lsof strace atop multitail -y
yum --enablerepo=rpmforge install htop -y

# Обновляем систему
yum update -y

Теперь перейдем к установке самого zabbix и требуемых ему компонентов:

SERVER

# Установим официальный репозиторий zabbix для centos
rpm -ivh http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm

# Убиваем все старые компоненты MySQL, Это удалит MySQL!
yum remove php-* mysql-* MariaDB-* -y

# Устанавливаем mariadb из репозитория atomic
yum install mariadb-server mariadb-devel mariadb-client -y

# Устанавливаем много компонентов и модулей которые нужны для работы zabbix
yum install ntp php php-mysql php-mbstring php-mcrypt rpm-build gcc mariadb-devel openssl-devel cyrus-sasl-devel pkgconfig zlib-devel pcre-devel openldap-devel postgresql-devel expect libtool-ltdl-devel openldap-servers libtool gdbm-devel pam-devel gamin-devel php-fpm php-cli php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-pecl-apc hp-magpierss php-snmp php-tidy spawn-fcgi openssl perl-TimeDate webalizer perl-DateTime-Format-HTTP perl-DateTime-Format-Builder perl-TimeDate libevent-devel php-pecl-memcache nginx cronie cronie-anacron crontabs postfix sysstat -y


# Устанавливаем сам zabbix
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent


# Настраиваем MariaDB, нужно привести ее конфиг к такому виду (эти конфиг расчитан на 16ГБ ОЗУ на сервере)
[root@zabbix ~] nano /etc/my.cnf


[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
default_storage_engine=InnoDB
innodb_file_per_table = 1

#
#
# network
connect_timeout = 60
wait_timeout = 28800
max_connections = 200
max_allowed_packet = 512M
max_connect_errors = 1000

# limits
tmp_table_size = 512M
max_heap_table_size = 256M
table_cache = 1024

# logs
log_error = /var/log/mysql/mysql-error.log
#slow_query_log_file = /var/log/mysql/mysql-slow.log
#slow_query_log = 1
#long_query_time = 20

# innodb
default_storage_engine=InnoDB
innodb_file_per_table = 1
innodb_status_file = 1
innodb_additional_mem_pool_size = 128M
innodb_buffer_pool_size = 12G # Значение этого параметра должно быть не более 60% от объема ОЗУ на сервере
innodb_flush_method = O_DIRECT
innodb_io_capacity = 2000
innodb_flush_log_at_trx_commit = 2
innodb_support_xa = 0
innodb_log_buffer_size = 128M

# experimental
innodb_stats_update_need_lock = 0

# other stuff
event_scheduler = 1
query_cache_type = 0
query_cache_size = 536870912
join_buffer_size=1M
query_cache_limit=2M
sort_buffer_size=2M
read_buffer_size=2M
read_rnd_buffer_size=4M
key_buffer = 256M
key_buffer_size=64M
open_files_limit = 100000
thread_cache_size = 100

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d


# Добавляем mysql в автозагрузку
chkconfig mysqld on && /etc/init.d/mysqld restart

# Добавляем php-fpm в автозагрузку
chkconfig --levels 235 php-fpm on
/etc/init.d/php-fpm start


# Удаляем конфиги по умолчанию nginx
rm /etc/nginx/conf.d/default.conf -f
rm /etc/nginx/conf.d/virtual.conf -f

# Создаем базу zabbix
mysql -e 'CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;'
mysql -e 'grant all privileges on zabbix.* to zabbix@localhost identified by «9c9yUiUuros»;'
mysql -e 'flush privileges;'


# Заливаем стандартные схемы для базы zabbix
mysql zabbix < /usr/share/doc/zabbix-server-mysql-2.2.0/create/schema.sql
mysql zabbix < /usr/share/doc/zabbix-server-mysql-2.2.0/create/images.sql
mysql zabbix < /usr/share/doc/zabbix-server-mysql-2.2.0/create/data.sql


# Добавляем правила iptables
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 10050 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 10051 -j ACCEPT
iptables -A INPUT -p udp -m state --state NEW -m udp --dport 10050 -j ACCEPT
iptables -A INPUT -p udp -m state --state NEW -m udp --dport 10051 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
service iptables save


# Внесем обязательные изменения в конфигурацию php
[root@zabbix ~] nano /etc/php.ini


post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Europe/Moscow


# Приведем конфигурациию zabbix к следующему виду:
egrep -v '^#|^$' /etc/zabbix/zabbix_server.conf

[root@zabbix ~] nano /etc/zabbix/zabbix_server.conf

LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
DBName=zabbix
DBUser=zabbix
DBUser=zabbix
DBPassword=9c9yUiUuros
DBSocket=/var/lib/mysql/mysql.sock
SNMPTrapperFile=/var/log/snmptt/snmptt.log
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts


# Добавляем сервер zabbix в автозагрузку 
chkconfig zabbix-server on

# Немного изменим стандартную конфигурацию nginx, приведем конфиг к такому виду:
[root@zabbix ~] nano /etc/nginx/nginx.conf

user nginx;
worker_processes 10;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
use epoll;

multi_accept on;

}

error_log /var/log/nginx/error.log warn;

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr — $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

connection_pool_size 256;
client_header_buffer_size 4k;
client_max_body_size 100m;
large_client_header_buffers 8 8k;
request_pool_size 4k;
output_buffers 1 32k;
postpone_output 1460;
proxy_max_temp_file_size 0;
gzip on;
gzip_min_length 1024;
gzip_proxied any;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/xml application/xml application/x-javascript text/javascript text/css text/json;
gzip_comp_level 8;
gzip_disable «MSIE [1-6]\.(?!.*SV1)»;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 75 20;
server_names_hash_max_size 8192;
ignore_invalid_headers on;
server_name_in_redirect off;

proxy_buffer_size 8k;
proxy_buffers 32 4k;
proxy_connect_timeout 1000;
proxy_read_timeout 12000;
proxy_send_timeout 12000;
proxy_cache_path /var/cache/nginx levels=2 keys_zone=pagecache:5m inactive=10m max_size=50m;
real_ip_header X-Real-IP;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

allow all;

include /etc/nginx/conf.d/*.conf;
}


# Настраиваем nginx на работу с zabbix и php-fpm
[root@zabbix ~]# nano /etc/nginx/conf.d/zabbix.conf

server {
listen 80;
server_name имя;
server_name другое имя;

location / {
root /usr/share/zabbix;
index index.php index.html index.htm;
}

location ~ \.php$ {
root /usr/share/zabbix;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}

server {
listen 80;
server_name _;

location / {
root /usr/share/zabbix;
index index.php index.html index.htm;
}

location ~ \.php$ {
root /usr/share/zabbix;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}


# Убираем из автозагрузки apache
chkconfig --levels 235 httpd off
/etc/init.d/httpd stop


# Добавляем nginx в автозагрузку
chkconfig --levels 235 nginx on
/etc/init.d/nginx start

After install: 

 mysql zabbix
MariaDB [zabbix]> update users set passwd=md5('New Password') where alias='Admin';

Вот таким простым методом, мы получаем высокопроизводительную установку zabbix.

Статья была бы не полной, если бы я не сказал об установке zabbix-proxy и zabbix-agent, предполагается что шаги базовой настройки системы (в самом начале статьи) мы уже прошли


PROXY

# Установим официальный репозиторий zabbix для centos
rpm -ivh http://repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-release-2.0-1.el6.noarch.rpm

# Удаляем старый софт
yum remove zabbix-proxy-* -y
yum remove mysql* mysql-*


# Устанавливаем mariadb из репозитория atomic
yum install mariadb-server mariadb-devel mariadb-client -y

# После удаления компонентов mysql, могли удалиться важные компоненты
yum install -y cronie cronie-anacron crontabs postfix sysstat

# Собственно сам zabbix из официального репозитория
yum install zabbix zabbix-agent zabbix-proxy-mysql zabbix-proxy -y

Рассмотрим случай, что zabbix-proxy нужно поставить на чем то другом, например fedora 14

mkdir /root/zabbix && cd /root/zabbix
wget repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-2.0.9-1.el6.x86_64.rpm
wget repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-agent-2.0.9-1.el6.x86_64.rpm
wget repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-proxy-2.0.9-1.el6.x86_64.rpm
wget repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-proxy-mysql-2.0.9-1.el6.x86_64.rpm
wget repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-get-2.0.9-1.el6.x86_64.rpm
rpm -Uhv *.rpm


# Настраиваем MariaDB, нужно добавить параметры
[root@zabbix ~] nano /etc/my.cnf


default_storage_engine=InnoDB
innodb_file_per_table = 1


# Добавляем zabbix в автозагрузку 
chkconfig zabbix-proxy on
chkconfig zabbix-agent on
chkconfig mysqld on && /etc/init.d/mysqld start


# Создаем базу
mysql -e 'CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;'
mysql -e 'grant all privileges on zabbix.* to zabbix@localhost identified by «lNZrKeZASv0L»;'
mysql -e 'flush privileges;'


# Заливаем стандартные схемы для базы zabbix
mysql zabbix < /usr/share/doc/zabbix-server-mysql-2.0.9/create/schema.sql
mysql zabbix < /usr/share/doc/zabbix-server-mysql-2.0.9/create/images.sql


# Добавляем правила iptables
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 10050 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 10051 -j ACCEPT
iptables -A INPUT -p udp -m state --state NEW -m udp --dport 10050 -j ACCEPT
iptables -A INPUT -p udp -m state --state NEW -m udp --dport 10051 -j ACCEPT
service iptables save


# Настраиваем сам zabbix-proxy
sed -i «s/^Server=.*/Server=адрес-сервера-zabbix/g» /etc/zabbix/zabbix_proxy.conf
sed -i «s/^Hostname=.*/Hostname=имя-этого-прокси-который-указали-zabbix-server/g» /etc/zabbix/zabbix_proxy.conf
sed -i «s/^DBName=.*/DBName=zabbix/g» /etc/zabbix/zabbix_proxy.conf
echo ProxyMode=0 >> /etc/zabbix/zabbix_proxy.conf
echo ProxyLocalBuffer=1 >> /etc/zabbix/zabbix_proxy.conf
echo ProxyLocalBuffer=ProxyOfflineBuffer=100 >> /etc/zabbix/zabbix_proxy.conf
echo HousekeepingFrequency=1r=100 >> /etc/zabbix/zabbix_proxy.conf
echo DataSenderFrequency=300 >> /etc/zabbix/zabbix_proxy.conf
echo StartPollers=5 >> /etc/zabbix/zabbix_proxy.conf
echo StartIPMIPollers=1 >> /etc/zabbix/zabbix_proxy.conf
echo StartPollersUnreachable=1 >> /etc/zabbix/zabbix_proxy.conf
echo StartTrappers=5 >> /etc/zabbix/zabbix_proxy.conf
echo StartHTTPPollers=1 >> /etc/zabbix/zabbix_proxy.conf
echo StartDBSyncers=4 >> /etc/zabbix/zabbix_proxy.conf
echo Timeout=10 >> /etc/zabbix/zabbix_proxy.conf
echo FpingLocation=/usr/sbin/fping >> /etc/zabbix/zabbix_proxy.conf
echo Fping6Location=/usr/sbin/fping6 >> /etc/zabbix/zabbix_proxy.conf
echo DebugLevel=3 >> /etc/zabbix/zabbix_proxy.conf
echo StartDiscoverers=10 >> /etc/zabbix/zabbix_proxy.conf
echo DBPassword=lNZrKeZASv0L >> /etc/zabbix/zabbix_proxy.conf


# Проверяем конфигурационный файл zabbix-proxy
egrep -v '^#|^$' /etc/zabbix/zabbix_proxy.conf

# Поехали
/etc/init.d/zabbix-proxy start


AGENT, очевидно мы будем его разворачивать через chef или puppet но для полноты материала

# Установим официальный репозиторий zabbix для centos
rpm -ivh http://repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-release-2.0-1.el6.noarch.rpm

# Устанавливаем агента из официального репозитория
yum install zabbix zabbix-agent -y

или если у Вас не очень свежая fedora
rpm -Uhv http://repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-2.0.9-1.el6.x86_64.rpm

# Даем пользователю zabbix права sudo и создаем папки для наших будущих скриптов
usermod -s /bin/bash zabbix
echo 'zabbix ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
sed -i 's/Defaults\ requiretty/#Defaults\ requiretty/g' /etc/sudoers
mkdir /etc/zabbix/scripts/
chmod 750 /etc/zabbix/scripts/


# Добавляем zabbix-agent в автозагрузку
chkconfig zabbix-agent on

# Добавляем правила iptables
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 10050 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 10051 -j ACCEPT
iptables -A INPUT -p udp -m state --state NEW -m udp --dport 10050 -j ACCEPT
iptables -A INPUT -p udp -m state --state NEW -m udp --dport 10051 -j ACCEPT
service iptables save


# Настраиваем нашего zabbix-agent
sed -i «s/^Server=.*/Server=адрес-zabbix-sever-или-proxy/g» /etc/zabbix/zabbix_agentd.conf
sed -i «s/^ServerActive=.*/ServerActive=адрес-zabbix-sever-или-proxy/g» /etc/zabbix/zabbix_agentd.conf
sed -i «s/^Hostname=.*/Hostname=`hostname`/g» /etc/zabbix/zabbix_agentd.conf
echo EnableRemoteCommands=1 >> /etc/zabbix/zabbix_agentd.conf
echo LogRemoteCommands=1 >> /etc/zabbix/zabbix_agentd.conf
echo Timeout=30 >> /etc/zabbix/zabbix_agentd.conf


# Готово, наблюдаем логи
/etc/init.d/zabbix-agent restart && tail -f -n 100 /var/log/zabbix/zabbix_*.log

Спасибо за Ваше внимание, если Вы сочтете этот материал интересным, то я буду рад поделиться еще многим и многим! 

Install Zabbix 2.4 on Centos 7

Reposted from here, really amazing post!

Install and use Zabbix on CentOS 7 or RHEL 7

Zabbix is a monitoring tool which is widely used in all kinds of environments. Zabbix is very flexible, information can be retrieved using HTTP/SNMP or by installing a Zabbix agent on the machines to monitor, and allows a lot of customization. Unfortunately this also means that the learning curve can be rather high. This post will go a little deeper into the installation process and the first steps in Zabbix.
Zabbix can be installed from most standard repositories in a variety of Linux distributions. For this post, I’m using CentOS 7 and I decided to use the official Zabbix repository to ensure that we’re using the latest version of Zabbix. Zabbix requires a database backend and for this post, I will use MariaDB (a fork of MySQL).

Add the Zabbix repository and install the packages

The first step is to enable the Zabbix official repository by creating a file in /etc/yum.repos.d:
Contents of the file:
The packages in the standard CentOS repositories have the version number in their name. (zabbix22 for version 2.2) so they will not conflict with the packages from the repository which we added.
To be sure, we can check if we really are installing the latest version:
As you can see, package Zabbix is version 2.4.3 and it will be taken from the repository which we just added, named Zabbix.
Besides the Zabbix-repository, you will also need the EPEL repository for some dependencies. If you haven’t done so, add that repo too:
Now that we are sure that Yum has access to the correct packages, let’s install what is necessary:

Configure the database

After installing the packages, we need to do initialize MariaDB and set the root password. Don’t get confused with all the references to MySQL in the commands below. MariaDB is a fork of MySQL and clearly branding wasn’t very high on the priority list :)
Now that MariaDB is running and initialized, we can add a database for Zabbix, named zabbix, and create a user that has access to that DB. Use the root-password which you changed in the previous step when asked for a password and replace secretpassword with your own password for the zabbix database user.
Now that the database and user are ready, it’s time to create the database schema for Zabbix in the DB which we just added. The schema is delivered with Zabbix in /usr/share/doc/zabbix-server-mysql-<version>/create/. (If you would install the packages from the standard repositories, the schema can be found in /usr/share/zabbix-mysql/.)

Be aware that, for this post, I’m leaving the rest of the MariaDB configuration at it’s default. For a production environment you really need some tuning in MariaDB to optimize the database system. To do so, I recommend using Zabbix for a while and then use https://github.com/major/MySQLTuner-perl on a regular basis to tune the database parameters. This approach is very straightforward and delivers very good results with a minimal effort.

Configure the webserver

At this point, our database is ready so the next step is to configure the webserver (Apache) and PHP.
The default parameters of PHP need some tuning for Zabbix:
The above commands just replace lines in /etc/php.ini by a line with the correct value. You can also edit the file by hand if you would like to.
Next up is Apache. The Yum-installation, created a file for Apache in /etc/httpd/conf.d/zabbix.conf. Edit this file to look similar to this:

Configure Zabbix parameters:

Next in the list, is the Zabbix configuration file for the server. It needs to know the password which we set for the zabbix database user earlier. Replace secretpassword with your own password which you set for the zabbix database user:
In order to avoid some warnings like: “Less than 25% free in the configuration cache” or “Zabbix icmp pinger processes more than 75% busy”, set some more parameters in the file:

Security considerations

Before we can really use Zabbix, we need to open up the firewall to allow access to the Apache webserver and the webinterface of Zabbix. I’m assuming that outgoing traffic is allowed, otherwise you also need to open up UDP 161 for SNMP and TCP 10050 for the Zabbix agent.
With firewalld:
With iptables:
When using SELinux, we need to allow Apache to communicate with Zabbix:

Start and initialize Zabbix

At this point, most of the configuration should be completed. The only thing that is left is to start the services related to Zabbix and finish the configuration by using the webinterface:
Start the services:
After starting the services, browse to the following URL: http://<ip or hostname>/zabbix (for example: http://192.168.202.101/zabbix). If all goes well, you should see something like this:
zabbix_install1
Click next and check if everything is marked with OK:
zabbix_install2
In the next step, enter the details about the MariaDB user which we created (named zabbix and password secretpass):
zabbix_install3
Continue to step 6 and finish the installation:
zabbix_install4
After clicking finish, you should see the login screen to your new Zabbix installation:
zabbix_install5
The default username is admin and the default password for that user is zabbix.
At this point the Zabbix server is ready to use.

Basic actions for hosts to monitor:

Now that we have our Zabbix server up and running, we need to have something to monitor. For several types of hosts, there is an agent available. The agent is listening for requests on TCP port  10050 so make sure that this port is open from the Zabbix server to the host to monitor

INSTALL THE ZABBIX AGENT ON LINUX:

The Zabbix-agent is part of the base repositories of almost all standard Linux distributions so the easiest is to install it from here:
After the installation, set the hostname of the Zabbix-server in /etc/zabbix/zabbix_agentd.conf to match your configuration. Replace 192.168.202.101 by the IP or hostname of your Zabbix-server:
To disable the active checks, clear the value of the ServerActive parameter:
Enable the service and make it persistent:

INSTALL THE ZABBIX AGENT ON WINDOWS

To install the Zabbix agent on a Windows machine, I created a small archive that contains the Zabbix agent for 64bit Windows installations.
You can simply extract the archive and edit the following line in the file zabbix_agentd.win.conf:
Replace it with the hostname or IP of your Zabbix server.
After changing zabbix_agentd.win.conf, run the install-agent.bat. It creates a service for the Zabbix agent and starts it.

ENABLE SNMP ON LINUX

Besides using the Zabbix agent, you can also monitor hosts using SNMP. SNMP isn’t always as fast and flexible as the agent but does the job. Also SNMP can be used for devices that can’t have an agent installed (like a switch):
Install the net-snmp package:
Create the snmpd.conf file in /etc/snmpd/snmpd.conf:
The community string is set as public in the above file, change it to something else if you prefer to.
After configuring, start and enable the service:

Add a host in Zabbix

After installing SNMP or a Zabbix agent on your systems, you can add them in Zabbix as follows:
Log on to the web interface by browsing to http://<ip or hostname>/zabbix (for example: http://192.168.202.101/zabbix) and log in.
Go to Configuration – Hosts and click on “Create host”:
zabbix_host1
In the next screen, enter a host name, add the host to a group by selecting it on the right side and clicking <<.
When the host has the agent installed, enter the DNS-name or IP for the host in the Agent interfaces. For SNMP, remove the Agent interface and add an SNMP interface containing the same information.
zabbix_host2
On the templates tab, add ICMP ping and a template that matches the host (for example “Template OS Linux” for a Linux host with a Zabbix agent or “Template SNMP OS Linux” for a Linux host with SNMP).
zabbix_host3
When using SNMP, you need to enter the community string which you have chose (public in my example above) on the Macros tab:
zabbix_host4
Finally click Add and the host should be monitored. Don’t panic if you don’t see information iimmediately give Zabbix some time to discover all items that are relevant for the host.
This should be all it takes to get started with Zabbix. Take some time to explore Zabbix’ functionality and experiment to discover all features.