Search This Blog

How to install zabbix Server on Rocky Linux 9

How to set up Zabbix Server on Rocky Linux 9

1. Set Selinux to permissive mode

sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config
cat /etc/selinux/config | grep SELINUX=

2. Install and Configure Zabbix Server

Add zabbix repository to server.

sudo rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-7.0-5.el9.noarch.rpm
sudo dnf clean all

Install Zabbix server, frontend, agent.

sudo dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

3. Install and configure Mariadb database Server

Install Mariadb database server.

sudo dnf install mariadb-server mariadb -y

Restart and enable Mariadb service.

sudo systemctl start mariadb && sudo systemctl enable mariadb

Secure Mariadb instance.

sudo mariadb-secure-installation

Create Database for Zabbix Server.

mysql -u root -p
CREATE DATABASE zabbix character set utf8mb4 collate utf8mb4_bin;
CREATE USER zabbix@localhost IDENTIFIED by 'Khmer-EmpireP@$$';
GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost;
FLUSH PRIVILEGES;
QUIT

Import initial schema and data to the zabbix database.

zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

Disable log_bin_trust_function_creators option after importing database schema.

mysql -uroot -p
set global log_bin_trust_function_creators = 0;
quit;

4. Configure zabbix Server

Configure Zabbix. Open zabbix server configuration.

vim /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=Khmer-EmpireP@$$

Configure your timezone in zabbix frontend.

sudo vim /etc/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Phnom_Penh

Restart and Enable service.

sudo systemctl restart zabbix-server zabbix-agent httpd php-fpm
sudo systemctl enable zabbix-server zabbix-agent httpd php-fpm

Allow zabbix web service in firewalld.

sudo firewall-cmd --add-port={80,443}/tcp --permanent
sudo firewall-cmd --reload

5. Set up Zabbix in Web UI

The default URL for Zabbix UI when using Apache web server is http://host/zabbix.
The default user and password Admin:zabbix

How to Install Cacti on CentOS 8

Update System

dnf update -y

Install Apache

dnf -y install httpd httpd-devel

Install SNMP and RRDTool

dnf -y install net-snmp net-snmp-utils net-snmp-libs rrdtool

Restart service and enable service to start on boot time.

systemctl restart snmpd
systemctl enable snmpd

Install PHP Extension

dnf -y install php php-xml php-session php-sockets php-ldap php-gd php-gmp php-intl php-mbstring php-mysqlnd php-pdo php-process php-snmp

Change PHP Settings

vi /etc/php.ini

date.timezone = Asian/Phnom_Penh
memory_limit = 512M
max_execution_time = 60

Restart services

systemctl restart httpd
systemctl restart php-fpm

Enable services to startup on boot time.

systemctl enable httpd
systemctl enable php-fpm

Install MariaDB

dnf -y install mariadb-server

Restart and Enable to startup on boot time.

systemctl restart mariadb
systemctl enable mariadb

Secure MariaDB by setting a password.

mysqladmin -u root password your_strong_password

Create a Database for Cacti. Login into the database with a password just set at the moment.

mysql -u root -p

create database cacti;
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'p@$$w0rd';
flush privileges;
exit;

Import time.zone table into default database.

mysql -u root -p mysql < /usr/share/mariadb/mysql_test_data_timezone.sql

Grant permission to cactiuser on the timezone table.

mysql -u root -p

GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;
flush privileges;
exit;

Optimize Database

vi /etc/my.cnf.d/mariadb-server.cnf

Put the following lines under the [mysqld] section.

collation-server = utf8mb4_unicode_ci
character-set-server=utf8mb4
max_heap_table_size = 64M
tmp_table_size = 64M
join_buffer_size = 64M
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_flush_log_at_timeout = 3
innodb_buffer_pool_size = 1GB
innodb_buffer_pool_instances = 10
innodb_read_io_threads = 32
innodb_write_io_threads = 16
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000

Install Cacti from the EPEL repository. First, we need to enable epel-release into the CentOS repository.

dnf -y install epel-release

Install Cacti

dnf -y install cacti

Configure Cacti

Edit the Cacti's configuration file and specify the database name, database username and password accordingly.

vi /usr/share/cacti/include/config.php

/* make sure these values reflect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "p@$$w0rd";
$database_port = "3306";
$database_ssl = false;

Import the Cacti database into our database name cacti.

mysql -u root -p cacti < /usr/share/doc/cacti/cacti.sql

Enable Cron Job

Create a cron job to schedule Cacti runs its poller every 5 minutes.

vi /etc/cron.d/cacti

*/5 * * * * apache /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

Allow remote access

By default, Cacti allows only the localhost to access. To allow remote access please make the change as follow.

vi /etc/httpd/conf.d/cacti.conf

Alias /cacti /usr/share/cacti
<Directory /usr/share/cacti/>
            <IfModule mod_authz_core.c>
                         # httpd 2.4
                         Require all granted
            </IfModule>
            <IfModule !mod_authz_core.c>
                         # httpd 2.2
                         Order deny,allow
                         Deny from all
                         Allow from all
            </IfModule>
</Directory>

Allow Firewall and SELinux

firewall-cmd --permanent --add-service=http
firewall-cmd --reload

SELinux

sed -i 's/enforcing/disabled/g' /etc/selinux/config
setenforce 0

Restart service

systemctl restart mariadb httpd

Setup Cacti

Open your favorite browser and type http://server_ip/cacti. The default username is admin and password admin.


Cannot log in with the default username and password. Please follow the following steps.

vi /usr/share/cacti/include/config.php

Comment the following line by putting the hash sign (#) in the front.

#$cacti_cookie_domain = 'cacti.net';

Then, change the current password to the new secure password.


Check the License Agreement box and Begin.


Cacti check all the following requirements like PHP Setting, Timezome, Database running and Next.


Select the installation type and Next.


Directory Permission Checks, Cacti check all the directories permission that is required by Cacti and Next.


Specify the Critical Binary Location that will be used by Cacti and Next.


Read the security enhancement of Cacti, check the box below and Next.


Default profile, just keep it default and Next.


The default templates that will be installed and Next.


Cacti validate the database collation if any warning about the database, we can fix by follow the message here, Next.


Confirm the installation and Install.


Click on Get Started to finish.


Our Cacti installation is Done.










How to install Icinga Web 2 on CentOS 8

Icinga Web 2 is a web-based application that comes along with Icinga2. In this post, we show how to install Icinga Web 2 on CentOS 8.

Install icinga2 web2

After we installed the icinga2 successfully, we need to install the Icinga Web 2, Web interface of Icinga2.

Install PHP and PHP Extensions

Install the PHP extension required by the Icinga Web2 with the below command.

dnf install -y php php-json php-xml php-intl php-common php-pdo php-mysqlnd php-cli php-mbstring php-fpm php-gd php-zip php-ldap

Install Icinga Web 2

To install the Icinga Web 2 package along with Icinga CLI and Apache web service.

dnf install -y icingaweb2 icingacli httpd

Start the Apache web server and PHP FPM, and enable it to start when the server boot.

systemctl start httpd
systemctl start php-fpm
systemctl enable httpd
systemctl enable php-fpm

Create a database for Icinga web 2

Login into MariaDB sever. Please take note of this database information, we will use it when setting up Icinga Web 2.

CREATE DATABASE icingaweb2db;
grant all privileges on icingaweb2db.* to icingaweb2@localhost identified by 'icinga123';
quit;

SELinux

dnf install -y icingaweb2-selinux

Firewall

firewall-cmd --permanent --add-service=http
firewall-cmd --reload

Setup Icinga Web 2

icingacli setup token create

The newly generated setup token is: 500ee69ca39cfb89

Conclusion
Icinga Web 2 is a web-based application used as Icinga2 GUI for viewing the device status, service status, etc. You may also like:

How to install Icinga2 on CentOS 8

How to install Icinga2 on CentOS 8

Icinga is a monitoring system that checks the availabilities of network resources, notifies the user of any outages events. In this post, we are going to show, how to install Icinga2 and Icinga Web2 on

Enable EPEL Repository

The Icinga packages for CentOS 8 depend on other packages that are in the REPEL repository. CentOS 8 need the PowerTools repository for EPEL:

dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf config-manager --set-enabled PowerTools

Add Icinga Repository

Icinga provides the dedicated repositories, so we need to enable its repository.

rpm --import https://packages.icinga.com/icinga.key
dnf install -y https://packages.icinga.com/epel/icinga-rpm-release-8-latest.noarch.rpm

Install Icinga 2

We can install icinga2 using our package manager DNF to install the icinga2 package.

dnf install -y icinga2

Restart service and enable icinga2 service to start automatically when the system boot.

systemctl start icinga2
systemctl enable icinga2

SELinux

Icinga 2 provides its own SELinux policy name icinga2-SELinux, so install it.

dnf install -y icinga2-selinux

Intall Nagios Plugins

Icinga2 would be able to monitor the network, application and service depend on the plugins. Icinga2 uses Nagios plugins as its plugins to monitor. The Nagios plugins are available in the EPEL repository, so we can install it now.

dnf install -y nagios-plugins-all

Firewalld

Allow port 5665 in our firewall rule.

firewall-cmd --permanent --add-port=5665/tcp
firewall-cmd --reload

Configuring DB IDO MySQL

The DB IDO help icinga2 to export all of its configuration and status information to the database. We are going to use MariaDB as our database server.

Install Database Server

dnf install -y mariadb-server mariadb

Restart and Enable MariaDB service to start up when system boot.
systemctl restart mariadb
systemctl enable mariadb

Install IDO modules for MySQL

Now, install the icinga2-ido-mysql module to help icinga2 to communicate with MariaDB.

dnf install -y icinga2-ido-mysql

Create a Database for IDO modules

By default, no password requires for the root user to login to the MariaDB database. To secure, mysqladmin -u root password YOURPASSWORD.
Create a database and database username and password. Please take note of this database information, we will need it when setting up the web interface.

mysql -u root -p

create database icinga2;
grant all privileges on icinga2.* to icinga2@localhost identified by 'icinga123';
flush privileges;
quit

Now import the Icinga 2 IDO schema into our database just created at the moment by running the following commands.

mysql -u root -p icinga2 < /usr/share/icinga2-ido-mysql/schema/mysql.sql

Enable IDO MySQL Module

The ido-mysql is disabled by default. Use the command below to verify the enabled and available module in icinga2.

icinga2 feature list

Type the below command to enable ido-mysql module for Icinga2.

icinga2 feature enable ido-mysql

Enable command feature for Icinga2.

icinga2 feature enable command

Configure the IDO DB MySQL module

After we have enabled the IDO module, edit /etc/icinga2/features-enabled/ido-mysql.conf file and make change the database information accordingly.

vi /etc/icinga2/features-enabled/ido-mysql.conf

user = "icinga2",
password = "icinga123",
host = "localhost",
database = "icinga2"

systemctl restart mariadb icinga2

Conclusion

Icinga is a monitoring system that checks the availabilities of network resources, notifies the user of any outages events. Follow the below link for How to install Icinga Web 2 on CentOS 8.

How to install Nagios Core on CentOS8

Nagios Core is an open source Monitoring System. It is used for monitoring such as network infrastructure, switch, router, server, printer, network service, application and protocols. In this guide we are going to show how to install Nagios Core on CentOS 8.

Update our system

yum -y update

Disable Selinux

sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0

Install require package

yum -y install gcc glibc glibc-common perl httpd php php-cli wget net-snmp gd gd-devel

Download Nagios Source

After install packages required by Nagios, donwload Nagios source from the official site below.

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz

Extract Nagios Source

Extract Nagios Source and go to Nagios source directory.

tar -xvf nagios-4.4.5.tar.gz

Compile Nagios

Run ./configure script, it will check all the required package and dependencies that Nagios need and compile the main program and CGIs.

cd nagios-4.4.5
./configure
make all

Create user and group

The following command will create user nagios, group nagios and add Apache user to nagios group.

make install-groups-users
usermod -a -G nagios apache

Install Binaries

Install nagios binary , CGIs, and HTML files.

make install

Install service daemon

make install-daemoninit

Install the external command file

make install-commandmode

Install Configuration file

make install-config

Install Apache config file

make install-webconf

Allow port apache service on firewalld

firewall-cmd --zone=public --add-port=80/tcp
firewall-cmd --zone=public --add-port=80/tcp --permanent

Create nagiosadmin User Account

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Install Nagios plugins

Install dependencies.

yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release
yum --enablerepo=PowerTools,epel install perl-Net-SNMP

Download Nagios plugins source.

cd /tmp/
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz

Extract plugin source.

tar zxf nagios-plugins.tar.gz

Compile and Install Plugin

cd /tmp/nagios-plugins-release-2.2.1/
./tools/setup
./configure
make
make install

Now, we almost done for Nagios Core installation. To verify our Nagios is working or not.
Restart service

systemctl restart httpd
systemctl restasrt nagios

Open favorite web browser and type http://server_ip/nagios. Put the correct user and password(nagiosadmin:yourpassword).


Now our Nagios Core installation is done.


Conclusion

Nagios Core is an open source Monitoring System. It is used for monitoring such as network infrastructure, switch, router, server, printer, network service, application and protocols.

How to reset Cacti admin password

For our daily work, we will meet the problem like forgot Cacti admin password by unplanned. In this  post, will you all to reset Cacti admin password. Login into our database mysql -u root -p

use cacti;
update user_auth set password=MD5('NEWPASSWORD') where username='admin';
flush privileges;
exit;

Restart database.

systemctl restart mariadb

Conclusion
I hope this post will be helpful for you. You may also like the related post:

READ: Monitor Linux and Windows
READ: How to create Graph Tree on Cacti
READ: How to Install Plugin on Cacti
READ: Notification on Cacti

READ: How to install Cacti on Centos 7
READ: How to install Cacti on Debian 10

READ: How to compile Cacti spine on Debian

How to compile Cacti spine on Debian

Spine, formerly Cactid, is a poller for Cacti that primarily strives to be as fast as possible. For this reason it is written in native C, makes use of POSIX threads, and is linked directly against the net-snmp library for minmumal SNMP polling overhead. Spine is a replacement for the default cmd. 
In this post, we show how to compile Cacti-spine on Debian 10. 

Install dependencies

apt-get -y install g++ gcc libssl-dev libsnmp-dev help2man default-libmysqlclient-dev build-essential automake libtool dos2unix

Download Cacti-Spine Source

wget https://www.cacti.net/downloads/spine/cacti-spine-1.2.2.tar.gz

Extract Cacti-Spine source.

tar -xzf cacti-spine-1.2.2.tar.gz
cd cacti-spine-1.2.2

Compile Cacti-Spine with below command.

./bootstrap
./configure
make
make install
chown root:root /usr/local/spine/bin/spine
chmod u+s /usr/local/spine/bin/spine

Create new file name /usr/local/spine/etc/spine.conf.

vim /usr/local/spine/etc/spine.conf

Paste the following line and change the database username and password based on our cacti database.

DB_Host localhost
DB_Database cacti
DB_User cactiuser
DB_Pass cactipassword
DB_Port 3306
#DB_UseSSL 0
#RDB_SSL_Key
#RDB_SSL_Cert
#RDB_SSL_CA

Go to Cacti web interface => Settings => Paths and fill in the follow fileds.


To change cmd.php to spine for Cacti polling option. Go to Poller and change to Spine.


Conclusion

Spine, formerly Cactid, is a poller for Cacti that primarily strives to be as fast as possible. For this reason it is written in native C, makes use of POSIX threads, and is linked directly against the net-snmp library for minmumal SNMP polling overhead. 
I hope you all be able to understand this post well. If you don't understand any point or  have any problem, recommendation, suggestion don't hesitate to tell us, we will try our best to help. You may also like Related Posted:

READ: Monitor Linux and Windows
READ: How to create Graph Tree on Cacti
READ: How to Install Plugin on Cacti
READ: Notification on Cacti

READ: How to install Cacti on Centos 7
READ: How to install Cacti on Debian 10

How to install zabbix Server on Rocky Linux 9

How to set up Zabbix Server on Rocky Linux 9 1. Set Selinux to permissive mode sudo setenforce 0 sudo sed -i...