Search This Blog

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 Compile Cacti-Spine on Centos 7

Compile Cacti-Spine

Install dependencies.

yum install -y libdb-devel.x86 httpd-devel net-snmp-devel openssl-devel perl-devel rpm-devel mariadb-devel libtool help2man dos2unix

Download Cacti-Spine.

wget https://www.cacti.net/downloads/spine/cacti-spine-1.2.10.tar.gz
tar xzf cacti-spine-1.2.10.tar.gz
cd cacti-spine-1.2.10

Compile with the command below.

./bootstrap
./configure
make
make install

Permission and ownership.

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.

vi /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 following fields.


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


Conclusion
Spine is a replacement for the default cmd.php poller so you must decide if using Spine makes sense for your installationI 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. 

Notification on Cacti


Cacti provides compatibility to send notification when any events occurred. Notification is every important option for every monitoring system because we cannot look at the computer screen all the times. Notification on Cacti is the way that, Cacti will send message to notify the administrator when any devices down or any abnormal events. So, let’s start how to configure it. First of all, we need to install mail service mostly postfix, and mailx which is the command line utility that allow us to send mail from command line. Cacti can send notification to local mail and external mail like Gmail. 
Install Postfix
Postfix is the mail service on Linux.

yum install postfix -y

Restart postfix service

system restart postfix
systemctl enable postifx

In order to send email from command line on Linux, we need to install mail command utility.

yum install mailx -y

Cacti send notification to local mail

Cacti can send email notification within three of mail services PHP Mail() Function, Sendmail, SMTP. Go to the web interface of Cacti -> Configuration -> Settings -> Mail/Reporting/DNS.


Fill in the following field.
Test Email: the destination email that we want to Cacti to notify for any events.
Mail Services: chose the sending method to send notification
Ping Mail Server: this option is to ping before send
From Email Address:  the source email address of the notification
From Name: it is an alias name.
Next, click on Save and Send a Test Email. We will see the pop-up screen indicate that Test Email Results is Success.



To verify that user jipo surely get the notification message. Go to command line cat /var/mail/jipo. We will see the message in jipo’s mail box.


The other method for sending notification is that using Sendmail option. This option is not much different from PHP Mailer. Go to the web interface of Cacti -> Configuration -> Settings -> Mail/Reporting/DNS. And select Mail services as Sendmail and fill the Sendmail path as /usr/bin/mailx. When we complete the required file Save, and Send a Test Email.



The message indicates the sending status pop-up here.



To verify that user jipo surely get the notification message. Go to command line cat /var/mail/jipo. We will see the message in jipo’s mail box. So, the result is the same right.


Cacti send notification to Gmail

Cacti can be configured to send notification to Gmail. That’s Awesome!!
First, we need to allow Less secure app access on Gmail by follow the link below and then turn it ON. https://myaccount.google.com/lesssecureapps?pli=1


Go to the web interface of Cacti -> Configuration -> Settings -> Mail/Reporting/DNS.
For example I want to send notification from Cacti by using email source@gmail.com and destination email as dest@gmail.com .
Test Email: the destination email that will get the notification for any events notified by Cacti (dest@gmail.com )
Mail Services: chose SMTP because we need to authenticate by SMTP. The idea about SMTP is that we need to login into Gmail before we can send email.
From Email Address: the email address that use to send notification (source@gmail.com )
SMTP Hostname: smtp.gmail.com
SMTP Port: 587
SMTP Username: source@gmail.com
SMTP Password: xxxxx
SMTP Security: TLS
Then click on Save, then Send a Testing Email.


The pop-up message will appear. This message will show whether Test Send is success or failed.


Here below is the message that we send test from Cacti notification.


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




How to Install Plugin on Cacti

Cacti Plugins

Not only providing more and more powerful features, Cacti also compatible with many useful plugins to make its productivity more flexible. Cacti support many plugins like Monitor plugin, Thold plugin, Weathermap plugin and many more. In this post we will show how to install plugins on Cacti and we will install Monitor, Thold, and Weathermap.

Monitor Plugins

Monitor plugin enables Cacti to display all hosts status UP or Down on a single page. For the latest Cacti version support some plugins and some not yet, if we use Cacti old version under 0.xx version there are many plugin that it support. For the latest version Monitor plugin is available in Github.com. There are two common ways to install plugin on cacti:

Method #1

Go to https://github.com/Cacti/plugin_monitor and Donwload ZIP then copy by ssh or WinScp or other method to the server.


Method #2

yum install git -y

Copy the URL of that project and clone it with git command.


Clone project with git command.

git clone https://github.com/Cacti/plugin_monitor.git

If we installed cacti with specific version by manually the plugin path is /var/www/html/cacti/plugins/. If we installed Cacti with yum install cacti -y command the plugin path is /usr/share/cacti/plugins. Copy it to the right location and name as monitor.

cp -R plugin_monitor /var/www/html/cacti/plugins/monitor

change ownership to apache user.

chown apache.apache -R /var/www/html/cacti/plugins/monitor/

After we download or clone with git command, copy and name monitor to the correct location, now it is time to install it.

Install Monitor Plugin

Go to Configuration -> Plugins, we see that our plugin is here move the mouse hover the Setting sign under Actions. There is a warning message.


We notice that, Monitor Plugin requires Thold plugins to make it works.


Go to https://github.com/Cacti/plugin_thold/releases right click on Source code (zip) and Copy Link address.


Download thold plugin with wget command.

wget https://github.com/Cacti/plugin_thold/archive/v1.3.3.zip

Unzip the file with unzip command.

unzip v1.3.2.zip

Move to the right path and name it as thold.

mv plugin_thold-1.3.2 /var/www/html/cacti/plugins/thold

Chang ownership of that directory to apache user.

chown apache.apache -R /var/www/html/cacti/plugins/thold

Install thold plugin
Go to Configuration ->  Plugins click on setting sign.


Now, the thold plugin is installed, click on tick sign to enable it.


Now, we can install the Monitor plugin after the thold plugin is installed. Follow the same step of thold plugin.


Click on the tick sign to enable it.



Check Result

We see that Monitor Plugin tab is shown, and we see that below monitor icons about all devices  and devices are up.


Weathermap Plugin

Weathermap plugin allow us to draw network diagram with the graph view of each link. To install weathermap plugin follow the step below.

git clone https://github.com/thurban/plugin_weathermap.git

Copy to the right directory in Cacti location.

mv plugin_weathermap/ /var/www/html/cacti/plugins/weathermap

Change ownership to apache user.

chown apache.apache -R /var/www/html/cacti/plugins/weathermap

To install Weathermap plugin, we follow the same way as thold and monitor plugin.
Go to Configuration -> Plugins -> 


Click on tick sign to enable it.


Check the Results

We can see that new Weathermap plugin is shown on top of the page.


Conclusion

I hope you all be able to understand this post well. If you have any problem, recommend, suggestion don't hesitate to tell me for the future development.
You may also like:

READ: How to install Cacti on Centos 7 
READ: How to install Cacti specific version on Centos 7 
READ: How to add Windows and Linux host to Cacti
READ: How to create Graph Tree on Cacti

How to create Graph Tree on Cacti

Cacti not only provides the powerful features like monitor network traffic, CPU, resources utilization, and Cacti also offer Graph Tree feature that allow us to categorize the tree view of the graph based on device role, device type, device location and so on. In this post, we will show about how to create graph tree on it.

Graph Tree 

Cacti comes with the default graph trees, for the real work we need to customize the default based on our requirements.


I have added five devices their names based on the some provinces in Cambodia. We will create new graph tree according to these names.


Create Graph Tree

To create graph tree, go to Management -> Trees -> plus sign + on the top right side.



 Give the friendly name of new graph tree Provinces and choose the Sorting Type. Sorting Type is how the graph tree organized and click on Create.


 Now, we see all the available sites, available Devices, available graphs which we can drag and drop. Click on Edit button to edit this tree.


To make it easy to understand let drag and drop SIEM-REAP device to the graph tree. To publish the new graph tree change Publish option to active, Save and Finish Editing Tree.


Check Result

Go to Graphs tab, we see the new graph tree Provinces is published  and device SIEM-REAP is under it.


Graph Tree Branch

We are done for creating new graph tree. For best practice in the real work, we should categorize our graph tree based on the device roles, device type, location and so on. We will create graph tree branches according to the province names. Go to Management -> Tree and click on Province because we will add new branch on this graph tree.


 Click on Edit Tree button.


Click on Add Root Branch and put the name for the new branch SR, drag and drop device SIEM-REAP under it. Save -> Finish Editing Tree. For the other provinces we can do the same step.
   

Check Result

Go to Graphs tab again we now see the branches of Provinces graph tree are shown here.
   


Conclusion

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:

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