Skip to content

Instantly share code, notes, and snippets.

@Jiab77
Last active June 27, 2024 21:09
Show Gist options
  • Save Jiab77/6e1bf27cbe3a58fa0529bd7c644683bb to your computer and use it in GitHub Desktop.
Save Jiab77/6e1bf27cbe3a58fa0529bd7c644683bb to your computer and use it in GitHub Desktop.
Quick resume of the installation process.

Zabbix Installation with Grafana

Quick resume of the installation process.

Dependencies

Install dependecies first.

sudo apt update
sudo apt dist-upgrade
sudo apt install php7.0-xml php7.0-bcmath php7.0-mbstring

Repository

Setup the repository.

wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+xenial_all.deb
sudo dpkg -i zabbix-release_3.4-1+xenial_all.deb
sudo apt update

Server packages

For the server, install these packages:

sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent

Setup the database

This will setup MySQL for the use of Zabbix.

mysql -uroot -p

Set privileges.

create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'your_password';
flush privileges;
quit;

Import the database.

zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p zabbix

Change the config file

Update the database settings to the config.

sudo nano /etc/zabbix/zabbix_server.conf
...
### Option: DBPassword                           
#       Database password. Ignored for SQLite.   
#       Comment this line if no password is used.
#                                                
# Mandatory: no                                  
# Default:                                       
# DBPassword=

DBPassword=your_zabbix_mysql_password

Update the web server config.

sudo nano /etc/zabbix/apache.conf
...
<IfModule mod_php7.c>
    php_value max_execution_time 300
    php_value memory_limit 128M
    php_value post_max_size 16M
    php_value upload_max_filesize 2M
    php_value max_input_time 300
    php_value always_populate_raw_post_data -1
    # php_value date.timezone Europe/Riga
</IfModule>

Adjust timezone to your country. Here is a list of supported timezones: http://php.net/manual/en/timezones.php

Apply settings

We need to restart services to apply new settings.

sudo systemctl restart apache2
sudo systemctl start zabbix-server

Check the status

Check the status to be sure that everthing is setup properly.

sudo systemctl status zabbix-server apache2

You should see active (running) for both.

Enable Zabbix

Now its time to enable Zabbix at boot time.

sudo systemctl enable zabbix-server

Continue with the web interface

The rest of the setup is done throught the web interface.

To access to the web interface, open your web browser to this address http://your_zabbix_server_ip_address/zabbix/.

Go to this link to see the screens (step 4). https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-zabbix-to-securely-monitor-remote-servers-on-ubuntu-16-04

Client package

For the client, setup the repository and install this package:

sudo apt install zabbix-agent

Update the client config

Now the client need to know who is the server.

sudo nano /etc/zabbix/zabbix_agentd.conf
### Option: Server
#       List of comma delimited IP addresses (or hostnames) of Zabbix servers.
#       Incoming connections will be accepted only from the hosts listed here.
#       If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally.
#
# Mandatory: no
# Default:
# Server=

Server=zabbix_server_ip

Do the same for server active and hostname.

Beware, hostname needs to be the exact name of the client computer.

Apply the client settings

Now we're almost done, we just need to apply settings and add host the configuration.

sudo systemctl start zabbix-agent
sudo systemctl enable zabbix-agent
sudo systemctl status zabbix-agent

You should see active (running).

Firewal setup

This needs to be done on both, clients and server(s).

sudo ufw allow 10050/tcp
sudo ufw allow 10051/tcp

Add the host to the configuration

This is the last step to finish the Zabbix installation.

Proceed as usual. 😄

See this link for the screens, https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-zabbix-to-securely-monitor-remote-servers-on-ubuntu-16-04

Grafana

Quick install instructions for using Grafana with Zabbix.

sudo nano /etc/apt/sources.list

Add this line: deb https://packagecloud.io/grafana/stable/debian/ jessie main

Install the repository key:

curl https://packagecloud.io/gpg.key | sudo apt-key add -

Update package information and install the server package:

sudo apt update
sudo apt install grafana

Start the service and check the status:

sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl status grafana-server

You should see active (running).

Let the server start at boot:

sudo systemctl enable grafana-server.service

Install the plugin

Now we can continue and install the Zabbix plugin for Grafana.

sudo grafana-cli plugins install alexanderzobnin-zabbix-app

You should see this on sucess:

✔ Installed alexanderzobnin-zabbix-app successfully

Configure the plugin

To finish, we need to configure the plugin to use our Zabbix server.

Go to this address to proceed, http://your_zabbix_server_ip_address:3000

Default credentials are: admin/admin.

Go to this address to see the screens, https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-grafana-to-plot-beautiful-graphs-from-zabbix-on-centos-7

Dashboard setup

More information and screens to this address:

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-grafana-to-plot-beautiful-graphs-from-zabbix-on-centos-7

Resources

Used references:

Will add some other links later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment