Showing posts with label Monitoring. Show all posts
Showing posts with label Monitoring. Show all posts

Tuesday, May 13, 2014

Zabbix monitor VMWare Infrastructure

Monitor VMware is new feature of Zabbix 2.2
I got alot of disadvantages at this moment, can't get the most from guest machine: host IP address, host status, trigger, action... But it worth a try.
To turn on VMware monitoring, Zabbix extensions --with-libxml2 --with-libcurl needs to be compiled with. In addition, the configuration file zabbix_server.conf StartVMwareCollectors must be set to 1 or higher.
apt-get install libxml2-dev libcurl

Edit /etc/zabbix/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBPassword=
StartTrappers=5
StartVMwareCollectors=5
VMwareFrequency=10
VMwareCacheSize=32M
ListenIP=0.0.0.0
StartPollers=96
CacheSize=64M
HistoryCacheSize=16M
TrendCacheSize=16M
HistoryTextCacheSize=32M
ValueCacheSize=16M

Use the following procedure to monitor VMware.
  1. Create a host of vCenter VMware hypervisor or (vSphere / ESXi)
  2. $ {URL} , {$ USERNAME} , {$ PASSWORD}
    $URL -> https://(name/IP of vSphere Host or vCenter)/sdk

    You must have access to the URL. Try test it first. If it not work go to your VCenter and adjust it.
  3. Apply "Template Virt VMware" to host
  4. Hypervisor, guest VM is automatically registered by the discovery, monitoring is started. It take more than 2 hours to fetch the Information from VCenter. That's it

Zabbix change Global SNMP Community String

Using the default community string of public is not exactly safe and you can chose to change it in your devices.

When you do you’ll need to update the {$SNMP_COMMUNITY} macro to reflect this:

In Zabbix Dashboard go to Administration > General > Macro’s set the {$SNMP_COMMUNITY} macro to the SNMP Community name.

Friday, April 25, 2014

Zabbix monitoring on Ubuntu Server 14.04

First Production Ubuntu Server 14.04 running:
  1. MariaDB (Mysql) 
  2. Nginx 
  3. Php5-fpm
  4. Zabbix 2.2.*
All Stock Packages no Extra Repositories is needed. It Awesome!

DIY Ubuntu Server 14.04, it extremely easy. I mount /var on seperate hard disk for Mysql perfomance. MariaDB have many advantage than Mysql (belong to Oracle already).
hostname zabbix.mydomain.vn && echo 'zabbix.mydomain.vn ' > /etc/hostname

Note: 
  • datetime: sync your server to your NTP server.
  • Notice your mysql password
sudo apt-get update && apt-get -y dist-upgrade
sudo apt-get install mariadb-server nginx php5-fpm php5-mysql snmp libnet-snmp-perl snmp-mibs-downloader
sudo apt-get install zabbix-server-mysql  zabbix-frontend-php zabbix-agent

MariaDB Mysql 

create zabbix user, zabbix database, grant privileges for zabbix user on database zabbix.
mysql -u root -p
Enter password: your root password at MariaDB installation
create user 'zabbix'@'localhost' identified by 'Zabbix_DB_Passwd';
create database zabbix;
grant all privileges on zabbix.* to 'zabbix'@'localhost';
flush privileges;
exit;

Php5-fpm

Edit /etc/php5/fpm/php.ini for Zabbix
[PHP]
.....
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time =  300
......
[Date]
date.timezone = Asia/Ho_Chi_Minh

Edit [www] pool /etc/php5/fpm/pool.d/www.conf
[www]
user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
#### It depend on my server hardware, you can leave it as default ^^ #####
pm = dynamic
pm.max_children = 24
pm.start_servers = 8
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.max_requests = 50000
chdir = /

Restart php5-fpm
sudo service php5-fpm restart

Nginx 

In my case, this box is dedicated for Zabbix, so default site will be zabbix, Php web app root dir is in /usr/share/zabbix. 
Edit /etc/nginx/sites-available/default
server {
        listen 80 default_server;
        root /usr/share/zabbix;
        index index.php index.html index.htm;
        server_name zabbix.mydomain.vn;
        location / {
                try_files $uri $uri/ =404;
        }
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
}

Restart Nginx
sudo service nginx restart

Zabbix-server 

Init Zabbix database:
cd /usr/share/zabbix-server-mysql/
mysql -u zabbix -p zabbix < schema.sql
mysql -u zabbix -p zabbix < images.sql
mysql -u zabbix -p zabbix < data.sql
sudo cp /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php

Edit /etc/zabbix/zabbix.conf.php
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'Zabbix_DB_Passwd';
$ZBX_SERVER = 'zabbix.mydomain.vn';
$ZBX_SERVER_PORT = '10051';

Enable Zabbix monster in /etc/default/zabbix-server 
START=yes
CONFIG_FILE="/etc/zabbix/zabbix_server.conf"

Edit /etc/zabbix/zabbix_server.conf 
LogFile=/var/log/zabbix-server/zabbix_server.log
PidFile=/var/run/zabbix/zabbix_server.pid
DBName=zabbix
DBUser=zabbix
DBPassword=Zabbix_DB_Passwd
AlertScriptsPath=/etc/zabbix/alert.d/
FpingLocation=/usr/bin/fping

Start up Zabbix monster
service zabbix-sever restart 

Zabbix-agent

Hostname is very important. It must be same with Hostname in Host Configuration in Zabbix Dashboard.
I disable ServerActive => My Zabbix agent will run in Passive mode (Server directive). The Server will open a port and then visit his Agent port 10050 and ask for his money :D

Edit /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix-agent/zabbix_agentd.log
LogFileSize=0
Server=127.0.0.1    #Address of Zabbix Server
Hostname=zabbix.ssis.edu.vn     #FQDN of monitored host

Restart Zabbix-agent
sudo service zabbix-agent restart

Zabbix Dashboard

Go to Zabbix web dashboard: http://zabbix.mydomain.vn
Defaut username: Admin
Default password: zabbix

Add host monitoring will be on next Part

Troubleshooting

MariaDB: /var/log/mysql/error.log
Nginx: /var/log/nginx/error.log
Php5-fpm: /var/log/php5-fpm.log
Zabbix-server: /var/log/zabbix-server/zabbix_server.log
More verbosity? Turn on DebugLevel=4 at /etc/zabbix/zabbix_server.conf

Reference