Search This Blog

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 Cacti on Debian 10

Cacti is a complete frontend to RRDTool, it stores all of the necessary information to create graphs and populate them with data in a MySQL database. The frontend is completely PHP driven. Along with being able to maintain Graphs, Data Sources, and Round Robin Archives in a database, cacti handles the data gathering. Mostly, Cacti user SNMP to query and gathering for the information about the network device's resources. In this post, we demonstrate how to install Cacti on Debian 10.

Modify Repository

nano /etc/apt/sources.list

For Debain 10 Buster

deb http://deb.debian.org/debian/ buster main
deb http://security.debian.org/debian-security buster/updates main
# buster-updates, previously known as 'volatile'
deb http://deb.debian.org/debian/ buster-updates main

Update our system

apt -y update

Install Apache2 and PHP module

apt install -y vim apache2 libapache2-mod-php php-xml php-ldap php-mbstring php-gd php-gmp php-mysql

Change PHP setting

To verify the current time zone on our system ls -l /etc/localtime.

vim /etc/php/7.3/apache2/php.ini

AND

vim /etc/php/7.3/cli/php.ini

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

Install SNMP and RRDTool

apt install -y snmpd php-snmp rrdtool librrds-perl

Install MariaDB

apt install -y mariadb-server mariadb-client

Customize MariaDB setting to get better performance. Place the following lines under [mysqld] section.

vim /etc/mysql/mariadb.conf.d/50-server.cnf

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

Restart MariaDB service

systemctl restart mariadb

Create a database and database user for Cacti. Login into our database.

mysql -u root -p

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

Import the timezone table into default databases.

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

Grant permission for cactiuser on the default database. Login into our database.

mysql -u root -p

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

Install Cacti

There are two ways to install Cacti:

       Method #1 Install Cacti from the repository

We can install Cacti from the repository of Debian with apt -y install cacti. The latest stable Cacti version will be installed.

apt install -y cacti

Choose web service for Cacti, we use apache2 as web service, so press Tab to select OK.


Cacti ask for database configuration if we choose Yes, Cacti automatically configuration database for us. We want to configure a database by our hand so choose No.


Import database into MariaDB.

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

Configure username, password and database name for Cacti.

vim /usr/share/cacti/site/include/config.php

$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'cactipassword';
$database_port = '3306';
$database_ssl = false;
$database_ssl_key = '';
$database_ssl_cert = '';
$database_ssl_ca = '';

Change ownership on Cacti's directories to apache user (www-data)

chown -R www-data.www-data /usr/share/cacti/site/resource/snmp_queries/
chown -R www-data.www-data /usr/share/cacti/site/resource/script_server/
chown -R www-data.www-data /usr/share/cacti/site/resource/script_queries/
chown -R www-data.www-data /usr/share/cacti/site/scripts/

Cron job

/etc/cron.d/cacti

MAILTO=root
*/5 * * * * www-data php /usr/share/cacti/site/poller.php 2>&1 >/dev/null | if [ -f /usr/bin/ts ] ; then ts ; else tee ; fi >> /var/log/cacti/poller-error.log

       Method #2 Install Cacti Manually

When we install Cacti from the repository based on OS, the Cacti latest stable version in the repository will be installed. Sometimes we want to install Cacti by a specific version based on our requirement. So, we can manually install Cacti from the source.  First, download the Cacti source from the Cacti site https://www.cacti.net/downloads. Select which version we want to install, in this guide we will install cacti-1.2.2.

Download the Cacti source.

wget https://cacti.net/downloads/cacti-1.2.2.zip

Extract the Cacti source.

unzip cacti-1.2.2.zip

Move Cacti to DocumentRoot of apache.

mv cacti-1.2.2 /var/www/html/cacti

Change ownership to apache user (www-data). Move Cacti to DocumentRoot of apache.

chown -R www-data.www-data /var/www/html/cacti

Import Cacti database

mysql -u root -p cacti < /var/www/html/cacti/cacti.sql

Configure username, password, and database name for Cacti.

vim /var/www/html/cacti/include/config.php

$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'cactipassword';
$database_port = '3306';
$database_ssl = false;
$database_ssl_key = '';
$database_ssl_cert = '';
$database_ssl_ca = '';

Create a Cron job

Cacti need to run its poller regularly, so we need to schedule it with cron job.

echo '*/5 * * * * www-data /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1' >/etc/cron.d/cacti

Setup Cacti

Open favorite web browser and type http://server_ip/cacti . Default username and password (admin: admin) and change a new password.


Check the box Accept GPL License Agreement and Begin. 


This step the Cacti validates the PHP and MySQL setting,  if there is any recommendation will be shown here. Next.


Keep the default settings. Next.


Directories permission, Cacti check the directories permission all directories should be granted to www-data apache user. Next. 


Critical Binary that Cacti will use to function its operation properly. If any binary missing Cacti will show here.


Default Profile. Next. 


This is the default template that will be created with the Cacti installation. Next.


This is the warning from our database setting. we can keep it default. Next. 


Confirm Installation and Install.


We are almost done here, Get Started to finish our installation.


We are done for Cacti Installation.



Conclusion

Cacti is a web-based open-source monitoring system, that provides the graphing solution by RRDTool. We can use Cacti to monitor network traffic, system resource like CPU, RAM, HardDisk, and so on. I hope you all be able to understand this post well. If you don't understand any point or have any problem, recommendation, the suggestion doesn'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

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 ...