# dnf update -y
# reboot
–> Verify the Linux operating system and Kernel versions, that are being used in this article.
# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.4 (Ootpa)
# uname -r
4.18.0-305.12.1.el8_4.x86_64
–> Switch SELinux Target Policy to Permissive Mode:
# sed -i ‘s/^SELINUX=.*/SELINUX=permissive/g’ /etc/sysconfig/selinux
# setenforce permissive
–> Create Prometheus User and Directories:
–> Create a Linux user to own Prometheus software and processes.
# useradd –no-create-home -s /bin/false prometheus
–> Create required Prometheus directories and adjust the ownership.
# mkdir /etc/prometheus
# mkdir /var/lib/prometheus
# chown prometheus:prometheus /etc/prometheus
# chown prometheus:prometheus /var/lib/prometheus
–> Install Prometheus Systems Monitoring Tool on Linux:
# w!get https://github.com/prometheus/prometheus/releases/download/v2.29.2/prometheus-2.29.2.linux-amd64.tar.gz -P /tmp
–> Extract the downloaded tarball into the /var/lib/prometheus directory.
# tar -xf /tmp/prometheus-2.29.2.linux-amd64.tar.gz -C /var/lib/prometheus/ –strip-components=1
–> Adjust the ownership of the extracted files.
# chown -R prometheus:prometheus /var/lib/prometheus
–> Move Prometheus configuration file to /etc/prometheus directory.
# mv /var/lib/prometheus/prometheus.yml /etc/prometheus/
–> Check the default configurations in prometheus.yml file.
# grep -v ‘#’ /etc/prometheus/prometheus.yml
global:
alerting:
alertmanagers:
– static_configs:
– targets:
rule_files:
scrape_configs:
– job_name: “prometheus”
static_configs:
– targets: [“localhost:9090”]
–> Create symbolic links for Prometheus commands at /usr/bin directory to make them globally executable from any path.
# cp -s /var/lib/prometheus/prometheus /usr/bin
# cp -s /var/lib/prometheus/promtool /usr/bin
========> Create Systemd Service Unit for Prometheus: <=========
–> To enable autostart of Prometheus server, you are required to create systemd service unit.
# vi /usr/lib/systemd/system/prometheus.service
–> Add following directives in this file.
==================================================================
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/bin/prometheus \
–config.file /etc/prometheus/prometheus.yml \
–storage.tsdb.path /var/lib/prometheus/ \
–web.console.templates=/var/lib/prometheus/consoles \
–web.console.libraries=/var/lib/prometheus/console_libraries
[Install]
WantedBy=multi-user.target
======================================================================
–> Enable and start Prometheus service.
# systemctl enable –now prometheus.service
=====> Configure Linux Firewall for Prometheus:<======================
–> This network monitoring server uses default port 9090/tcp. Therefore, it is necessary to allow it Linux firewall to make it accessible accross the network.
# firewall-cmd –permanent –add-port=9090/tcp
# firewall-cmd –reload
–> Open URL http://prometheus-01.centlinux.com in a web browser.
–> Open Status > Targets from top menu.
http://Your Server IP or Host Name:9090/
=================================Install Node Exporter on Linux:=====================================
You need to install node_exporter on your Prometheus server to gather metrics.
–> Create directory for Node Exporter software.
# mkdir -p /var/lib/prometheus/node_exporter
–> Download Node Exporter tarball from Prometheus website.
# w!get https://github.com/prometheus/node_exporter/releases/download/v1.2.2/node_exporter-1.2.2.linux-amd64.tar.gz -P /tmp
–> Extract downloaded tarball into /var/lib/prometheus/node_exporter/ directory.
# tar xf /tmp/node_exporter-1.2.2.linux-amd64.tar.gz -C /var/lib/prometheus/node_exporter/ –strip-components=1
–> Adjust directory ownership.
# chown -R prometheus:prometheus /var/lib/prometheus/node_exporter/
–> Create a symbolic link for node_exporter at /usr/bin directory.
# cp -s /var/lib/prometheus/node_exporter/node_exporter /usr/bin/
–> Enable autostart of node_exporter process, create a systemd service unit.
# vi /usr/lib/systemd/system/node_exporter.service
–> Add following lines of code in this file.
=================================================================================
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
ExecStart=/usr/bin/node_exporter
[Install]
WantedBy=default.target
================================================================================
-> Enable and start Node Exporter service.
# systemctl enable –now node_exporter.service
–> Configure Linux firewall to allow node_exporter default port 9100/tcp.
# firewall-cmd –permanent –add-port=9100/tcp
# firewall-cmd –reload
–> Edit Prometheus configuration file in vim text editor.
# vi /etc/prometheus/prometheus.yml
–> Add the node_exporter endpoint configuration in this file.
===================================================
– job_name: ‘node_exporter’
static_configs:
– targets: [‘localhost:9100’]
=========================================================
-> Restart Prometheus service to load new configurations.
# systemctl restart prometheus.service
–> Open Status > Targets or refresh the web page, if already opened.
===============================Install Grafana===============================
Create a repo file.
# vi /etc/yum.repos.d/grafana.repo
Add the following contents to file:
[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
# sudo yum install grafana
// # yum install fontconfig
// # yum install freetype*
// # yum install urw-fonts
# systemctl start grafana-server
# systemctl enable grafana-server.service
# firewall-cmd –zone=public –add-port=3000/tcp –permanent
# firewall-cmd –reload
– Browse Grafana
Use the following URL to access the Grafana web interface.
http://Your Server IP or Host Name:3000/
Default User/Pass : admin/admin
[new password will be zafims@123]
=====================To Install Zabbix plugin run following command:=======================
# grafana-cli plugins install alexanderzobnin-zabbix-app
Default plugin installation directory is /var/lib/grafana/plugins. Restart Grafana Service.
# systemctl restart grafana-server
============================================================Install Zabbix=========================================================
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
# dnf install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-apache-conf
# vi /etc/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Dhaka
# dnf install -y mariadb-server mariadb
# systemctl start mariadb
# mysql -u root -p
N.B. Donot provide password
create database zafardb character set utf8 collate utf8_bin;
grant all privileges on zafardb.* to zafar@localhost identified by ‘zafims@123’;
quit;
# cd /usr/share/doc/zabbix-server-mysql/
# zcat create.sql.gz | mysql -u zafar -p zafardb
—> Enter password: zafims@123
# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zafardb
DBUser=zafar
DBPassword=zafims@123
(Optional if configured before)
SELinux
#vim /etc/sysconfig/selinux
SELINUX=disabled
#reboot
(Optional)Configure Zabbix Frontend
# vi /etc/php.ini
memory_limit 512M
upload_max_filesize 8M
post_max_size 16M
max_execution_time 300
max_input_time 300
# firewall-cmd –permanent –add-port=10050/tcp
# firewall-cmd –permanent –add-port=10051/tcp
# firewall-cmd –permanent –add-port=80/tcp
# firewall-cmd –reload
# systemctl restart zabbix-server zabbix-agent httpd php-fpm
# systemctl enable zabbix-server zabbix-agent httpd mariadb
http://your-ip-add-ress/zabbix/
Log in with the Zabbix default username and password.
Username: Admin
Password: zabbix
Username: Admin
Pass: zafar
================Install Zabbix agent ==============================
# nano /etc/selinux/config
Change the following line:
SELINUX=disabled
# dnf install https://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm
# dnf install zabbix-agent
# vi /etc/zabbix/zabbix_agentd.conf
===========================================
#Server=[zabbix server ip]
#Hostname=[ Hostname of client system ]
Server=103.120.223.126
Hostname=ZafarSrv
===========================================
# firewall-cmd –permanent –add-port=10050/tcp
# firewall-cmd –permanent –add-port=10051/tcp
# firewall-cmd –reload
# systemctl enable zabbix-agent
# systemctl start zabbix-agent
——————– For Windows: ————————
in Client PC:
in Zabbix: Configuration -> Host –> Createhost
Host name: ZafarSrv
Groups ->Select -> Virtual Machine
Interface: Agent : 103.120.223.126
Select Templete: Templete OS Windows by Zabbix agent or Templete OS Linux by Zabbix agent –> Add
Goto monitor Host
======================================================================