Monitoring Tools https://www.linuxtechi.com Tue, 06 Apr 2021 06:15:38 +0000 en-US hourly 1 https://www.linuxtechi.com/wp-content/uploads/2020/02/cropped-linuxtechi-favicon-32x32.png Monitoring Tools https://www.linuxtechi.com 32 32 Top 12 Command Line Tools to Monitor Linux https://www.linuxtechi.com/command-line-tools-to-monitor-linux/ https://www.linuxtechi.com/command-line-tools-to-monitor-linux/#comments Mon, 14 Sep 2020 02:11:15 +0000 https://www.linuxtechi.com/?p=11235 Being a Linux administrator is not an easy job. It takes lot of time, patience, and hard work to keep the systems up and running. But Linux System Admins can take some breather as they have some help in the form of command line monitoring ... Read more

The post Top 12 Command Line Tools to Monitor Linux first appeared on LinuxTechi.]]>
Being a Linux administrator is not an easy job. It takes lot of time, patience, and hard work to keep the systems up and running. But Linux System Admins can take some breather as they have some help in the form of command line monitoring tools. These tools help them to keep a tab on the Linux server performances and fix anything if found abnormal. In this article, we will look at the top 12 command line tools to monitor Linux performance.

1) Top

Without any doubt the top command is the number one command line tool to monitor Linux. It is one of the most widely used commands by Linux system administrators all over the world. It quickly provides details about all running processes in an ordered list. The list also keeps updating in real time. Not only the process names, it also displays the memory usage and CPU usage etc.

top-command-line-tool-monitor-linux

Also Read: 25 Top Command Examples to Monitor Linux Server Performance

2 ) vmstat

vmstst is the command line utility that occupies the 2nd position in our list. Its main task is used to display virtual memory statistics. It also helps you to display various information including all system processes, CPU activity, paging, block IO, kernel threads and disks etc. vmstat is the part of default installation in almost all the Linux distribution, so it is available straight way after the installation.

vmstat-command-output-linux

3) lsof

If you want to look at all the files currently opened in the system, then you need to make use of the lsof command. It is also used to monitor all processes currently in use. One of the major advantages of this command is that it helps administrators to see the files currently in use when a disk cannot be unmounted. Using this command, these files can be identified easily. lsof command is not available after the default Linux OS installation, so first we have to install it using following command:

For CentOS / RHEL

$ sudo yum install -y lsof              // CentOS 7 / RHEL 7 or before
$ sudo dnf install -y lsof              // CentOS 8 / RHEL 8

For Ubuntu / Debian

$ apt-get install -y lsof
Or
$ apt-get install -y lsof

To use lsof commmand, type lsof and hit enter

lsof-command-output-linux

Also Read : 18 Quick ‘lsof’ command examples for Linux Geeks

4) tcpdump

Tcpdump is another command line utility that allows Linux system administrators and network engineers to monitor all TCP/IP packets transferred over a network. Using tcpdump, one can also save all the packets in a separate file for analysis in the future.

Tcpdump is not part of default OS installation, so before start using it first install via following commands:

$ sudo yum install tcpdump -y    // CentOS 7 / RHEL 7 or before
$ sudo dnf install tcpdump -y    //CentOS 8 / RHEL 8
$ sudo apt install tcpdump -y    // Ubuntu / Debian

To Start capturing the packets on specific interface, run the following command,

# tcpdump -i enp0s3

tcpdump-command-line-tool-linux

Also Read: How to capture and analyze packets with tcpdump command on Linux

5) netstat

Netstat is one of the oldest command line utility used for network troubleshooting. Using netstat we can easily find network connections, routing tables, Ethernet card statistics and masquerade connections.  In other words, we can say, it also helps you troubleshoot any network related issues quickly. In the latest Linux distributions, netstat is not the part of default installation. Use beneath command to install it on different Linux distributions.

For CentOS 8 / RHEL 8

$ sudo dnf install net-tools -y

For Ubuntu / Debian

$ sudo apt install -y net-tools

Run following command to list all tcp connections on your Linux system,

# netstat -tunlp

netstat-command-linux

6) htop

htop command is another feature-rich command line utility that offers real-time monitoring of various vital resources in the Linux system. Compared to the top command, htop is a much-improvised version and even provides color coded output for easier understanding. It also supports both horizontal and vertical viewing and also allows administrators to manage processes as well.

To Install htop on Linux systems, execute following command,

$ sudo yum install -y htop              // CentOS 7 / RHEL 7 or before
$ sudo dnf install -y htop              // CentOS 8 / RHEL 8 or before
$ sudo apt install -y htop              // Ubuntu / Debian

Sample output of htop command:

$ htop

htop-command-output-linux

7) iotop

iotop is another free command line utility that allows admins to monitor disk I/O usage details. Even though it is similar to the top and htop command, one of the main advantages of iotop is that it provides a detail for a specific thread or a process in the system. Hence, system administrators can easily identify the process that is causing a lot of I/O rewrites to the server.

To Install iotop on different Linux distributions, run

$ sudo dnf install -y iotop    // CentOS 8 / RHEL 8
$ sudo yum install -y iotop    // CentOS 7 / RHEL 7
$ sudo apt install -y iotop    // Ubuntu / Debian

To start using iotop utility, type iotop on command line and hit enter,

$ iotop

iotop-command-line-output-linux

8) iostat

As the name suggests, iostat is a Linux command line tool that provides detailed statistics about the systems input/output for both devices and partitions. Linux system administrators can also use this command line tool to monitor the performance of both local and remote disks (NFS) as well.

Sample output of iostat is shown below:

$ iostat

iostat-commant-output-linux

9)  goaccess

Goaccess is an open-source real time log viewer and analyzer command line tool. It is available for almost all Linux distributions. It is can used to view real time logs for all web servers (Nginx , Apache, Amazon S3 and CloudFront etc).

Installation of Goaccess on CentOS 8 / RHEL 8

$ wget https://pkgs.dyn.su/el8/base/x86_64/goaccess-1.3-3.el8.x86_64.rpm
$ sudo dnf localinstall goaccess-1.3-3.el8.x86_64.rpm  -y

For Ubuntu / Debian

$ sudo apt get install goaccess

To analyze real time Apache web server’s log , run following goaccess command

$ sudo goaccess /var/log/httpd/access_log --log-format=COMBINED

goaccess-dashboard-linux

10) glances

Glances is a free and cross-platform command line tool to monitor linux system. Glances is available for almost all the Linux distributions and can collect system statistics apart from the monitoring. It is written in python and makes use of psutil library to retrieve useful information from the system. Glances can be used in three different ways:

  • Standalone command line utility
  • Client and Server
  • Web Server

To Install glances on CentOS / RHEL system, run

$ sudo dnf install -y glances            // CentOS 8 / RHEL 8
$ sudo yum install -y glances            // CentOS 7 / RHEL 7

To Install Glances on Ubuntu / Debian system, run

$ sudo apt get install -y glances

To start using glances, type glances command,

$ glances

Glances-command-output-linux

11) iptraf

Next in our list is iptraf, a command line utility that provides real time monitoring of Ethernet cards and networks. Using iptraf, system and network admins can gather a lot of details including:

  • TCP traffic summary
  • ICMP
  • IP traffic
  • UDP traffic
  • Interface activity
  • Statistical breakdowns
  • Detailed interface statistics

Compared to other commands like iftop, we can say that iptraf provides a more detailed breakdown and statistics. Iptraf is not the part of default OS installation, so to install it run following command,

For CentOS / RHEL

$ sudo dnf install -y iptraf-ng
Or
$ sudo yum install -y iptraf-ng

For Ubuntu / Debian

$ sudo apt install -y iptraf-ng

To start iptraf utility, type iptraf-ng command and choose the ethernet card,

$ iptraf-ng

iptraf-ng-command-output-linux

12) Iftop

The command line tool that occupies the 12th position in our list is the iftop tool. It is a simple command line tool that shows you bandwidth usage on the Ethernet cards of your Linux system. System and network admins use this tool for bandwidth monitoring. With iftop you can view both the source and destination in the first network interface it listens to.

To install iftop on CentOS / RHEL systems, run following command

$ sudo dnf install -y iftop
$ sudo yum install -y iftop

For Ubuntu / Debian systems, run

$ sudo apt install -y iftop

Type iftop to start this utility, example is shown below:

$ iftop

iftop-command-output-linux

Read Also : 20 Awesome Nmap Command Examples in Linux

The post Top 12 Command Line Tools to Monitor Linux first appeared on LinuxTechi.]]>
https://www.linuxtechi.com/command-line-tools-to-monitor-linux/feed/ 3
How to Install Cacti Monitoring Tool on CentOS 8 / RHEL 8 https://www.linuxtechi.com/install-cacti-monitoring-tool-centos-8-rhel-8/ https://www.linuxtechi.com/install-cacti-monitoring-tool-centos-8-rhel-8/#comments Wed, 02 Sep 2020 07:18:13 +0000 https://www.linuxtechi.com/?p=11145 Cacti is a free and open source front-end network monitoring tool used to monitor and graph time-series metrics of various IT resources in your LAN. It uses the RRDtool to poll services at specified intervals and thereafter represent them on intuitive graphs. Cacti monitors various ... Read more

The post How to Install Cacti Monitoring Tool on CentOS 8 / RHEL 8 first appeared on LinuxTechi.]]>
Cacti is a free and open source front-end network monitoring tool used to monitor and graph time-series metrics of various IT resources in your LAN. It uses the RRDtool to poll services at specified intervals and thereafter represent them on intuitive graphs.

Cacti monitors various metrics such as CPU, memory and bandwidth utilization, disk space, filesystems and running processes to mention a few. You can monitor devices such as servers, routers, switches and even firewalls. Additionally, you can configure alerts such that in case of system downtime, you can receive notifications on email. In this guide, we will walk you through the installation of the Cacti monitoring tool on CentOS 8 / RHEL 8. At the time of penning down this tutorial, the latest Cacti version is version 1.2.14.

Step 1) Install Apache web server

Cacti is a web-based graphing tool, and therefore, we need to install a web server on which the monitoring tool will run on. Here, we are going to install the Apache web server. To do so, execute the command:

$ sudo dnf install httpd -y

Step 2 ) Install PHP and additional PHP extensions

The front-end of the Cacti monitoring tool is purely PHP driven and with that, we need to install PHP and the required PHP modules. Therefore, execute the command:

$ sudo dnf install -y php php-xml php-session php-sockets php-ldap php-gd php-json php-mysqlnd php-gmp php-mbstring php-posix php-snmp php-intl

Step 3) Install MariaDB database server

During installation, Cacti requires its own database to store its files. Additionally, it needs a database for storing all the required data that is needed in populating graphs.

MariaDB is a fork and a drop-in replacement for MySQL. It’s considered more robust and feature-rich and while MySQL would still work, MariaDB comes highly recommended. To install the MariaDB server, run the command:

$ sudo dnf install -y mariadb-server mariadb

Step 4) Install SNMP and RRD tool

Next, we are going to install SNMP and RRDtool which are essential in gathering and processing system metrics.

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

Step 5)  Start and enable services

Having installed all the necessary services required for Cacti to run, we are going to start them as shown:

$ sudo systemctl start httpd
$ sudo systemctl start snmpd
$ sudo systemctl start mariadb

Additionally, ensure to enable them on boot, such that they automatically start upon booting or a reboot.

$ sudo systemctl enable httpd
$ sudo systemctl enable snmpd
$ sudo systemctl enable mariadb

Step 6) Create a database for Cacti

In this step, we are going to create a database and user for cacti and later grant all privileges to the cacti user. Run the following commands:

CREATE DATABASE cactidb;
GRANT ALL ON cactidb.* TO cacti_user@localhost IDENTIFIED  BY ‘cactipassword’;
FLUSH PRIVILEGES;
EXIT;

Be sure to note down the database name, user and password as these will be required later on in the installation process.

Create-Cactidb-CentOS8

Next, we need to import the mysql_test_data_timezone.sql to mysql database as shown.

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

Then log in to mysql database and grant the cacti user access to the mysql.time_zone_name table.

GRANT SELECT ON mysql.time_zone_name TO cacti_user@localhost;
FLUSH PRIVILEGES;
EXIT;

Grant-access-cacti-user-centos8

Some database tuning is recommended for optimum performance. Append the following lines in the mariadb-server.cnf file under the [ mysqld ] section as shown.

$ sudo vi /etc/my.cnf.d/mariadb-server.cnf
............
collation-server=utf8mb4_unicode_ci
character-set-server=utf8mb4
max_heap_table_size=32M
tmp_table_size=32M
join_buffer_size=64M
# 25% Of Total System Memory
innodb_buffer_pool_size=1GB
# pool_size/128 for less than 1GB of memory
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_file_format=Barracuda
innodb_large_prefix=1
innodb_io_capacity_max=10000
..............

Save and exit the configuration file

Optimize-Cactidb-CentOS8

Step 7) Installing and configuring Cacti monitoring tool

With the database in place and all the other prerequisites having been fulfilled, let’s now install Cacti.

Cacti package is not available in default CentOS 8 / RHEL 8 repositories, it is available in EPEL repository. So run below command to enable epel repo

$ sudo dnf install epel-release -y

To install Cacti monitoring tool, run the command:

$ sudo dnf install cacti -y

After the installation, you can confirm the installation of cacti by running the command:

$ rpm -qi cacti

You should get a detailed output showing the version, release, size and Vendor to mention a few of the Cacti package.

Cacti-rpm-info-centos8

Next, import the default cacti database tables to the cacti database that was created earlier in step 6. To find out the path of the default database, run:

$ rpm -ql cacti | grep cacti.sql

Once you get the path, import the default database using the command:

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

Import-default-CactiDB-CentOS8

Next, edit the cacti configuration file and specify the database details as shown:

$ sudo vim /usr/share/cacti/include/config.php

Set the database name, username and password and leave the rest of the options as they are.

Cacti-Configuration-CentOS8-RHEL8

Save the changes and exit the configuration file. Thereafter, set the timezone by editing the php.ini file as shown.

$ sudo vim /etc/php.ini
................................. 
date.timezone = Asia/Dubai
memory_limit = 512M
max_execution_style = 60
.................................

Save and exit the file.

Next, edit the cron entry as shown

$ sudo vim /etc/cron.d/cacti

Uncomment this line to ensure the Cacti polls data every 5 minutes and save the configuration

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

Next, modify Apache’s configuration file to enable remote installation of Cacti.

$ sudo vim /etc/httpd/conf.d/cacti.conf

Modify the following httpd ACLs to grant access to remote users

Change Require host localhost to Require all granted

Modify Allow from localhost to Allow from [network subnet]

For the network subnet, be sure to specify your own network subnet. For our case, the subnet is 192.168.2.0/24

Allow-Cacti-Subnet-httpd-centos8

For all the changes made to come into effect, execute:

$ sudo systemctl restart httpd
$ sudo systemctl restart php-fpm

Step 8) Configure firewall rules for Cacti

Before finally setting up Cacti, allow HTTP service on your firewall as shown:

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

Step 9) Set up Cacti via the browser

To finish setting up Cacti, visit your server’s IP as shown

http://server-ip/cacti

You will get the page displayed as shown. Log in using the credentials shown

Username: admin

Password: admin

Click ‘Login’ to proceed.

Cacti-Login-Page-CentOS8-RHEL8

Next, you will be required to change the default login password by providing a password of your own. Be sure that you provide a strong password (with a combination of uppercase, lowercase, numeric and special characters). Then click ‘Save’.

Change-Cacti-Password-CentOS8

In the next step, check off the ‘Accept GPL license agreement’ checkbox and click on ‘Begin’.

Accept-GPL-License-Cacti-CentOS8

Cacti will perform pre-installation checks, confirming if the required PHP modules are installed and the correct database settings have been configured. If everything looks good, click on ‘Next’. If something’s amiss, click on the ‘Previous’ button and go back to the configuration file and add what’s missing.

Pre-Installation-Checks-Cacti-Wizard-CentOS8

Thereafter, select the ‘New Primary Server’ option for installation and also ensure that the database connection details are correct before proceeding.

Choose-Cacti-Installation-type-CentOS8

The next step probes for any directory issues and ensures that the correct permissions are in place. If all is good, click ‘Next’, otherwise click ‘Previous’ and rectify any issues.

Directory-Permissions-check-Cacti-CentOS8

Next, the installer checks to see if all the binary paths of the necessary packages are installed.

Verify-binary-path-cacti-installation-wizard-centos8

The latest version of Cacti has introduced another crucial step and that is the validation of data input methods. This gives you a few steps to follow after the installation of cacti to whitelist data input methods. Read through the instructions carefully and check the ‘I have read this statement’ button.

Input-Validation-whitelist-Cacti-Installation-CentOS8

In the next step, select the cron interval for scanning devices and define your network subnet as shown. Then click ‘Next’.

Cacti-Automation-Subnet-Installation-Wizard-CentOS8

Cacti ships with templates that give you the ability to monitor and graph an assortment of devices in your network including Cisco devices (routers and switches), Linux and Windows machines. By default, all options are checked to include all the templates that you would require. If you are happy with that, simply click ‘Next’.

Template-Setup-Cacti-Installation-CentOS8

Thereafter, the installer will check if the database collation is UTF8 compliant. Click ‘Next’.

UTF8-Compliant-Cacti-CentOS8

To begin the installation, click on the ‘Confirm Installation’ checkbox and click on ‘Install’.

Choose-Confirm-Installation-Cacti-CentOS8

The installation of Cacti will begin and will take roughly 5 minutes. Feel free to take a break and do a bit of stretching,

Cacti-Installation-Progress-CentOS8

Once the installation of the required packages is complete, click on the ‘Get Started’ button.

Choose-Get-Started-after-Cacti-Installation

This will take you directly to the Cacti dashboard as shown.

Cacti-Dashboard-CentOS8

Cacti will, by default, create resource utilization graphs for your local server on which Cacti is installed. To access the graphs, navigate through:

Graph –> Default Tree –> Local –> Choose Your Device.

Wait for about 10 minutes for the graphs to be populated.

Graphs-Cacti-dashboard-CentOS8

And this brings us to the end of this tutorial. Personally, I have used Cacti to monitor a range of devices and I can attest to its efficiency in monitoring several devices and sending alerts in the event of system downtime.

Read Also : How to Install Zabbix Monitoring Tool on CentOS 8/RHEL 8

The post How to Install Cacti Monitoring Tool on CentOS 8 / RHEL 8 first appeared on LinuxTechi.]]>
https://www.linuxtechi.com/install-cacti-monitoring-tool-centos-8-rhel-8/feed/ 5
How to Install and Configure Checkmk on CentOS 8 / RHEL 8 https://www.linuxtechi.com/install-configure-checkmk-centos-8-rhel-8/ https://www.linuxtechi.com/install-configure-checkmk-centos-8-rhel-8/#comments Wed, 05 Aug 2020 04:21:12 +0000 https://www.linuxtechi.com/?p=10964 Developed in Python & C++ languages, Checkmk is an open-source monitoring server that is an improvement of Nagios operating system with enhanced plugins and monitoring capabilities. Checkmk uses agents to collect and ship remote systems’ metrics to the server. The agents are available for both ... Read more

The post How to Install and Configure Checkmk on CentOS 8 / RHEL 8 first appeared on LinuxTechi.]]>
Developed in Python & C++ languages, Checkmk is an open-source monitoring server that is an improvement of Nagios operating system with enhanced plugins and monitoring capabilities. Checkmk uses agents to collect and ship remote systems’ metrics to the server. The agents are available for both Linux and Windows systems in 32 & 64-bit architectures.

Checkmk is used in monitoring applications, servers and even cloud infrastructure such as AWS and Azure. In this guide, we will walk you through how to install and configure Checkmk on CentOS 8 and later on, see how you can add both Linux and Windows hosts to checkmk server for monitoring.

We will install Checkmk using the OMD (Open Monitoring Distribution) bundle. This bundle ships with Nagios and all the necessary plugins required for monitoring various services.

Lab Setup details for Checkmk

This will be our set up

  • Checkmk Server – CentOS 8
  • Host 1 – CentOS  8
  • Host 2 – Windows Server 2019

Step 1) Update the system

To start off, it’s always advisable to update your package lists to start on a clean slate. Therefore, log in to the Checkmk server and run the off command below.

$ sudo dnf update -y

Once the update is completed successfully and reboot the system once.

Step 2) Install prerequisite packages

Once the update is complete, you need to install a couple of packages for the installation of Checkmk monitoring tool to go smoothly.

First, you need to install EPEL. This is short for Extra Packages for Enterprise Linux. This is a package repository that provides additional packages that are not present in the default AppStream repositories for CentOS 8. This will prove beneficial as some of the packages required by OMD are contained in EPEL.

To install the EPEL repository, execute the command:

$ sudo dnf install epel-release

install-epel-release-centos8-rhel8

Press ‘y’ on the keyboard and hit ENTER to proceed with the installation.

Next, ensure that you install xinetd and OpenSSL packages. Therefore, run the command:

$ sudo dnf install xinetd openssl -y

Also, ensure that Python 3 is installed (It comes preinstalled by default on CentOS 8). In case it is not installed on your CentOS 8 / RHEL 8 system then run following command to install it,

$ sudo dnf install python3 -y

Run following command to verify the python version

[linuxtechi@checkmk ~]$ python3 -V
Python 3.6.8
[linuxtechi@checkmk ~]$

Don not forget to install ‘graphiz-gd’ package from PowerTools repository, run the following dnf command

$ sudo dnf --enablerepo=PowerTools install graphviz-gd -y

Step 3) Set SELinux and firewall rules for checkmk

SELinux is a kernel security module that enhances the security of your CentOS 8 and RHEL 8 system. Set the following selinux rule to allow web server to access network interfaces,

$ sudo setsebool -P httpd_can_network_connect 1

Now allow http service or its port in firewall, run

$ sudo firewall-cmd --zone=public --add-service=http --permanent
$ sudo firewall-cmd --reload

Note: You can skip this only if Selinux and firewalld is disabled on your system.

Step 4) Installing Checkmk monitoring tool

With all the prerequisites out of the way, it’s time now to install Checkmk First, download the RPM package from the Official site.

$ wget https://checkmk.com/support/1.6.0p14/check-mk-raw-1.6.0p14-el8-38.x86_64.rpm

Download-check-mk-raw-package-centos8-wget-coomand

Once downloaded install Checkmk rpm package with –nogpgcheck option to avoid signing of the package which might result in errors later on during the installation process.

$ sudo dnf install --nogpgcheck check-mk-raw-1.6.0p14-el8-38.x86_64.rpm -y

dnf-localinstall-checkmk-centos8

The next thing you need to do is to create an OMD instance. We are going to create one for testing purpose (sandbox).

Note: You can replace the OMD instance name that suits to your setup.

$ sudo omd create sandbox

You should get the output shown below:

omd-create-checkmk-centos8

What the command does is that it creates a new omd instance together with a user and a group called ‘sandbox’ alongside the user’s home directory which is created in the ‘/omd/sites/sandbox’ path.

To start the instance, switch to either the omd user or the root user and run the command:

$ omd start

omd-start-checkmk-centos8

To access the Check_MK front end interface, open your web browser and browser the URL shown:

http://server-IP/sandbox

Sign in using the username cmkadmin and password provided when creating the omd instance, in this case, Ha3QLQr1

checkmk-login-screen-centos8-rhel8

Click the ‘Login’ button to access the dashboard which is shown below.

checkmk-dashboard-centos8-rhel8

Step 5) Add a remote Linux host to Checkmk for monitoring

Having successfully installed and set up Checkmk, We are going to demonstrate how you can monitor various hosts. First, we are going to add a Linux host, in this case, a CentOS 8 system, which requires you to install the Checkmk agent.

There are 2 ways to go about this. You can download the Checkmk agent from the server by browsing shown.

http://server-ip/sandbox/check_mk/agents

checkmk-agent-centos8

Append the agent’s name to the URL and download using the wget command as shown

$ wget http://server-ip/sandbox/check_mk/agents/check-mk-agent-1.6.0p14-1.noarch.rpm

Replace the server-ip that suits to your setup, in my case it would be ’35.222.59.10

The other way is to directly download the agent from the official site.

$ wget https://checkmk.com/support/1.6.0p14/check-mk-raw-1.6.0p14-el8-38.x86_64.rpm

Once you have downloaded the agent, install it using the rpm command as shown:

$ rpm -ivh check-mk-agent-1.6.0p14-1.noarch.rpm

Then install xinetd daemon.

$ sudo dnf install xinetd -y

The Checkmk agent listens on port 6556, and so we need to open the port on the firewall so that it can ship the Linux host’s metrics to the Checkmk server.

To open the port and effect the changes on the firewall, run the command:

$ sudo firewall-cmd --permanent --add-port=6556/tcp
$ sudo firewall-cmd --reload

Now head over to the Checkmk dashboard and navigate to ‘WATO Configuration’ –> ‘Hosts’ –> ‘Create New Host

Create-new-host-checkmk-centos8

In the next page, fill out the details of the host such as the hostname, IP address, and remember to check off the checkmk agent checkbox.

Remote-LinuxHost-details-checkmk-dashboard

Then click on ‘Save and Finish

Save-Changes-Remote-LinuxHost-Details-Checkmk

Shortly after, a list of the host’s services will be populated as shown

Remote-LinuxHost-Monitoring-details-checkmk

Let’s now have a look at how you can add a Windows host system.

Step 6) Add a remote Windows host to checkmk for monitoring

Adding a Windows host is very similar to adding a Linux host. To get started, browse the following URL

http://server-ip/sandbox/check_mk/agents/windows/

To download the Windows agent, click on either check_mk_agent.msi or check_mk_agent-64.exe package.

Download-checkmk-agent-windows-from-checkmk-server

Once downloaded, run the installer as shown using the install Wizard.

Start-CheckMK-agent-installation-wizard-windows

Once done, head over to the services Window and confirm that the agent is running as shown.

Verify-CheckMK-agent-Service-status-Windows

Equally important, ensure that you have allowed the checkmk service across Windows Firewall as shown.

Allow-Checkmk-agent-windows-firewall

Finally, head over to the Checkmk server and add the Windows host system the same way we added the Linux host.  When you are done, the host’s services will be populated as shown,

Windows-Host-Monotoring-Details-Checkmk

Awesome! We have managed to install the Checkmk monitoring server and successfully managed to add the Linux and Windows host systems for monitoring. We hope this guide was beneficial. The ball is now in your court. Give it a try and let us know how it went.

Read Also : How to Install Zabbix Monitoring Tool on CentOS 8/RHEL 8

The post How to Install and Configure Checkmk on CentOS 8 / RHEL 8 first appeared on LinuxTechi.]]>
https://www.linuxtechi.com/install-configure-checkmk-centos-8-rhel-8/feed/ 1
How to Add Windows Host to Zabbix Server for Monitoring https://www.linuxtechi.com/add-windows-host-zabbix-server-for-monitoring/ https://www.linuxtechi.com/add-windows-host-zabbix-server-for-monitoring/#respond Fri, 19 Jun 2020 16:18:09 +0000 https://www.linuxtechi.com/?p=10690 In the previous article, we looked at how you can add Linux servers on the Zabbix server for monitoring. In this guide, we switch gears and focus our spotlight on how you can add a Windows host system to the Zabbix server for monitoring. For ... Read more

The post How to Add Windows Host to Zabbix Server for Monitoring first appeared on LinuxTechi.]]>
In the previous article, we looked at how you can add Linux servers on the Zabbix server for monitoring. In this guide, we switch gears and focus our spotlight on how you can add a Windows host system to the Zabbix server for monitoring.

For this tutorial, we will add the Windows server 2019 datacenter edition to Zabbix Server.

Step 1) Download Zabbix Agent for Windows Server

As we saw when adding Linux hosts, the first step when adding a host to the Zabbix server is to install the Zabbix agent on the host system first. With that in mind, head out to the official Zabbix agents download page and download the Zabbix Window’s agent.

By default, this will download it in the ‘Downloads’ folder as shown.

Download-Zabbix-agent-for-Windows

Once downloaded, right-click on the zipped file and select ‘Extract All’ to unzip it as shown.

This unzips it into 2 folders: bin and conf folder. The bin folder contains the Zabbix agent executable file while the conf folder contains the Zabbix agent configuration file – zabbix.agentd.conf

Extracted-Zabbix-agent-windows-host

Step 2) Edit the Zabbix configuration file

We need to make a few changes to the zabbix configuration file for the Zabbix agent to communicate with the Zabbix server. Therefore, open the zabbix configuration file – zabbix.agentd.conf – and modify the parameters as shown:

Server=<IP address of the Zabbix server>
ServerActive=<IP address of the Zabbix server>
Hostname=<The FQDN of the Windows server>

Save the changes and exit the file.

Step 3) Install and start Zabbix Agent on Windows server

With all the configurations in order, run command prompt as administrator and install Zabbix using the syntax as shown:

C:\> {full system path to zabbix_agentd.exe) –config  {full system path to zabbix_agentd.win.conf} –install

In my case, the command will be:

C:\>C:\Users\winnie95atieno\Downloads\bin\zabbix_agentd.exe --config C:\Users\winnie95atieno\Downloads\conf\zabbix_agentd.conf --install

Install-Zabbix-agent-conf-windows

From the output, we can see that the Zabbix agent has successfully been installed.

To start Zabbix, use the syntax:

C:\> {full system path to zabbix_agentd.exe) –start

The command will therefore be:

C:\>C:\Users\winnie95atieno\Downloads\bin\zabbix_agentd.exe --start

Start-Zabbix-Agent-Windows-Host

To confirm that the Zabbix agent is running, head out to the ‘Windows Services’ application and confirm that the Zabbix agent is up and running.

Verify-Zabbix-Agent-Service-Windows

Step 4) Configure Windows firewall for Zabbix Agent

By default, the Windows firewall is enabled and blocks incoming and going connections. We are therefore going to make a few changes to allow traffic from the Windows Server host to the Zabbix server.

First, we are going to allow ICMP protocol for the Zabbix server to establish network communication with the Windows host and report any errors when they occur. Therefore, run Windows Powershell with Administrative privileges and execute the command as shown:

netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol="icmpv4:8,any" dir=in action=allow

Next, allows port 10050 – which is the default port that Zabbix listens to  – on the firewall.

netsh advfirewall firewall add rule name="Open Port 10050" dir=in action=allow protocol=TCP localport=10050

Allow-Zabbix-agent-ports-firewall-windows

To this point, we have successfully installed and configured the Zabbix agent on the Windows host system. The Zabbix agent should be sending system metrics to the Zabbix server. Let’s now go over and see how you can add the Windows host on the Zabbix server.

Step 5)  Add a Windows host on Zabbix Server

To add a Windows host, go to Configuration –> Host –> Create Host

Create-Windows-Host-Zabbix-Server

On the next screen, fill out the Windows host details such as hostname, visible name and IP address.

Specify-Windows-Host-Details-Zabbix-Server

For the ‘Groups’ section, click on the ‘Select’ button and click on the ‘Templates/Operating system’ option.

Choose-Operating-System-Template-Zabbix-Server

Next, click on the ‘Templates’ tab on the menu and click ‘Template OS Windows by Zabbix agent’. Finally, click on the ‘Select’ button.

Choose-Windows-OS-Template-Zabbix-Agent

On the dashboard, check the Windows host listed as shown below. Note that the state is indicated ‘Enabled’ with the Zabbix icon ‘ZBX’ in green color.

Windows-Server-Added-Zabbix-Server

To graph the metrics associated with the Windows host system, click on ‘Monitoring’ –>  ‘Hosts’. Click on the Windows host and select ‘Graphs’.

Windows-Hosts-Graph-Zabbix-Server

Finally, the Zabbix server will start graphing the system metrics shipped by the Zabbix agent which is residing on the Windows server host system. There are various metrics that you can monitor including network Interface statistics, CPU usage and utilization, Disk space usage and Memory utilization to mention a few.

Windows-Server-Network-Graph-Zabbix-Server Windows-Host-Disk-Graph-Zabbix-Server

And this brings us to the end of this topic. It’s our hope that you can now comfortably add a Windows host on the Zabbix server for monitoring.

The post How to Add Windows Host to Zabbix Server for Monitoring first appeared on LinuxTechi.]]>
https://www.linuxtechi.com/add-windows-host-zabbix-server-for-monitoring/feed/ 0
How to Add Linux Host in Zabbix Server for Monitoring https://www.linuxtechi.com/add-linux-host-zabbix-server-for-monitoring/ https://www.linuxtechi.com/add-linux-host-zabbix-server-for-monitoring/#comments Wed, 17 Jun 2020 06:26:12 +0000 https://www.linuxtechi.com/?p=10667 In the previous article, we have covered how to Install Zabbix Server on CentOS 8. In this guide, we go a step further and show you how you can add a Linux host to the Zabbix Server so that we can monitor various metrics such ... Read more

The post How to Add Linux Host in Zabbix Server for Monitoring first appeared on LinuxTechi.]]>
In the previous article, we have covered how to Install Zabbix Server on CentOS 8. In this guide, we go a step further and show you how you can add a Linux host to the Zabbix Server so that we can monitor various metrics such as CPU load, memory utilization, swap usage, and disk utilization to mention a few.

But first, we need to install the Zabbix Agent on the remote host which is going to ship the metrics of the remote system to the Zabbix server for monitoring. In this guide, we will install the Zabbix agent on Ubuntu 20.04 LTS and CentOS 8.

How to Install Zabbix agent on Ubuntu Linux?

To get started with the installation of Zabbix agent, follow the steps below:

Step 1) Adding the Zabbix repository and Installing Zabbix agent

By default, the Zabbix repository is not included in the Ubuntu repository.  We, therefore, need to manually add it before installing the Zabbix agent. At the time of penning down this guide, the latest version of Zabbix is Zabbix 5.0. Therefore, we are going to add the Zabbix agent that corresponds to that version.

To so do, first download the repository’s Debian package:

For Ubuntu 20.04 (Focal Fossa)

$ wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1%2Bfocal_all.deb

After the package is downloaded, update the package list and install  the zabbix-agent using the dpkg package manager as shown:

$ sudo apt update
$ sudo dpkg -i zabbix-release_5.0-1+focal_all.deb
or 
$ sudo apt install -y zabbix-agent

For Ubuntu 18.04 (Bionic Beaver)

For Ubuntu 18.04, execute the commands below to add the repository

$ wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1%2Bbionic_all.deb
$ sudo apt update
$ sudo dpkg -i zabbix-release_5.0-1+bionic_all.deb
or 
$ sudo apt install -y zabbix-agent

For Ubuntu 16.04 (Xenial Xerus)

$ wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1%2Bxenial_all.deb
$ sudo apt update
$ sudo dpkg -i zabbix-release_5.0-1+xenial_all.deb
or
$ sudo apt-get install -y zabbix-agent

Step 2) Configure Zabbix agent

With the successful installation of the Zabbix agent, we need to make a couple of tweaks for the remote system to communicate with the Zabbix server. We are going to make a few adjustments in the configuration file which is /etc/zabbix/zabbix_agentd.conf

In the file locate the Server and hostname attributes and set them to correspond to the server’s parameters. In our case, we have:

Server=10.128.0.10
hostname=ubuntu20-04

Once done, save & exit the configuration file.

Also, ensure that you can reach the Zabbix server by pinging its IP address and hostname.

For the changes to come into effect, restart the Zabbix-agent as shown:

$ sudo systemctl restart zabbix-agent

To ensure it is running, check its status using the command:

$ sudo systemctl status zabbix-agent

Zabbix-agent-status-ubuntu-linux

From the output, it’s clear that the Zabbix agent is up and running.

Step 3) Configure the firewall rules for zabbix-agent

Finally, we need to configure the firewall to open port 10050 which the zabbix-agent listens on. Therefore, run the commands below:

$ sudo ufw allow 10050/tcp
$ sudo ufw reload

To confirm that the port is open, run:

$ sudo ufw status

Ufw-zabbix-agent-rules-ubuntu-linux

Up to this mark, you have successfully installed the Zabbix agent on Ubuntu and your system is ready to be added to the Zabbix server for monitoring.

How to install zabbix agent on CentOS 8 / RHEL 8?

For CentOS 8 / RHEL 8 systems, the steps for installing the Zabbix agent are pretty much similar.

Step 1) Adding the Zabbix repository

Begin by manually adding the repository since the Zabbix repository is not included by default on AppStream repo.

$ sudo dnf install https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-agent-5.0.0-1.el8.x86_64.rpm

Install-Zabbix-agent-CentOS8

Press Y to finish the installation.

Run below command to install Zabbix Agent on CentOS 8 / RHEL 8

$ sudo dnf install -y zabbix-agent

Step 2) Configure zabbix agent

As demonstrated earlier, a few changes need to be made in the agent’s configuration which is /etc/zabbix/zabbix_agentd.conf

As before, set the  Server and hostname directives to match the Zabbix server’s parameters as shown:

Server=10.128.0.10
hostname=centos-8

Once done, save & exit the configuration file. Next, restart the Zabbix-agent daemon and confirm whether it’s running:

$ sudo systemctl restart zabbix-agent
$ sudo systemctl status zabbix-agent

Zabbix-Agent-Status-CentOS8

Step 3) Configure the firewall rule for zabbix-agent

Finally, to allow Zabbix-agent to establish communication with the Zabbix Server and vice versa ,  configure the firewall by running  the commands as shown:

$ sudo firewalld --add-port=10050/tcp --permanent
$ sudo firewalld --reload

Adding or Registering Remote Linux Host in Zabbix Server

Login to your Zabbix Server portal using admin user’s credentials .To add a host on the Zabbix server, click on Configuration –> Hosts.

On the far top- right end, click on the ‘Create host’ button

Create-Host-Entries-Zabbix-Portal

On the page that appears, fill out the remote Linux’s details as listed:

  • Hostname
  • Visible name
  • IP address
  • Description

Specify-Linux-Server-Details-Zabbix-Portal

Next, click on the ‘select’ button next to the ‘Groups’ text field. On the ‘Host groups’ list, click on ‘Linux servers’ and then click ‘Select’.

Choose-Linux-Servers-Host-Groups-Zabbix

As you can see, the group has been added.

Linux-Servers-Group-Zabbix

We also need to add a template for our server. So, click on the ‘Templates’ menu option.

Hosts-Templates-Zabbix

On the ‘Templates’ list that appears, click on ‘Template OS Linux by Zabbix agent’ and hit the ‘Select’ button.

Choose-Template-OS-Linux-Zabbix-Agent

This takes you back to the home screen and there you can see that your new host system has been added.

Ubuntu-20-04-added-Zabbix-Portal

To add the CentOS-8 system, repeat the same steps described.

Graphing statistics of the remote hosts

To represent system metrics in a graphical form, click on ‘Monitoring’  –> ‘Hosts

Next, click on the host you want to graph and select the ‘graph’ option from the pull-up menu.

Host-Monitoring-Graph-Option-Zabbix-Portal

Zabbix server will begin generating various graphs representing various system metrics such as Processes, CPU load, and network traffic statistics to mention a few.

Host-Process-Graph-Zabbix-Server

Scroll down to view other graphs displaying various metrics as shown below.

Host-Network-Graph-Zabbix-Server

We have successfully added 2 Linux host systems to the Zabbix server and managed to graph various system metrics. We appreciate your feedback. Give it a try and let us know your experience.

The post How to Add Linux Host in Zabbix Server for Monitoring first appeared on LinuxTechi.]]>
https://www.linuxtechi.com/add-linux-host-zabbix-server-for-monitoring/feed/ 3
How to Install Zabbix Monitoring Tool on CentOS 8/RHEL 8 https://www.linuxtechi.com/install-zabbix-monitroing-tool-centos-8-rhel-8/ https://www.linuxtechi.com/install-zabbix-monitroing-tool-centos-8-rhel-8/#comments Wed, 10 Jun 2020 14:27:35 +0000 https://www.linuxtechi.com/?p=10623 Zabbix is an open source monitoring tool that can be deployed on-premises or on the cloud depending on that you intend to monitor. With Zabbix, you can monitor a variety of devices: from physical servers, and network devices such as routers and switches on your ... Read more

The post How to Install Zabbix Monitoring Tool on CentOS 8/RHEL 8 first appeared on LinuxTechi.]]>
Zabbix is an open source monitoring tool that can be deployed on-premises or on the cloud depending on that you intend to monitor. With Zabbix, you can monitor a variety of devices: from physical servers, and network devices such as routers and switches on your IT infrastructure as well as cloud infrastructure.

The latest release of Zabbix is Zabbix 5.0 LTS. Zabbix gives users the ability to perform the following tasks:

  • Monitor web services
  • Monitor multiple network devices using the  SNMP protocol.
  • Monitor various database servers such as Oracle, PostgreSQL, MySQL and Microsoft SQL Server.
  • Monitor virtual machines and Hypervisor platforms such as VMware vCenter
  • Monitor crucial system metrics such as CPU load, network utilization and available disk space.

In this guide, we will discuss how to install and configure Zabbix monitoring tool on CentOS 8 / RHEL 8.

Prerequisites:

Before getting started, ensure that the following requirements are fulfilled:

  • An instance of CentOS 8 with a minimum of 2GB RAM and 10 GB available disk space.
  • A regular login user with sudo privileges
  • Stable Internet Connection

Let’s now jump in and get on with the installation.

Step 1) Apply Updates and Disable / Turn off SELinux

It is always recommended to apply all the available updates before starting Zabbix installation, so run the following dnf command:

$ sudo dnf update -y

For Zabbix to run smoothly without any issues, it’s recommended that you turn off SELinux. SELinux is enabled by default and you can check the status by running the command:

$ sestatus

To disable SELinux, run the following sed command:

$ sudo sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux

Reboot your CentOS 8 or RHEL 8 system for the changes to come to effect.

$ sudo reboot

Step 2) Install LAMP stack

Zabbix is both a front-end and back-end tool and requires a web server, a database engine and PHP installed to function. All these components comprise a LAMP stack. You will, therefore, need to install Apache web server, a database engine (MariaDB is preferred), PHP and requisite PHP modules as shown:

$ sudo dnf install -y httpd mariadb-server php php-cli php-common php-mbstring php-mysqlnd php-xml php-bcmath php-devel php-pear php-gd

Install-httpd-mariadb-php-centos8

Once above packages have been installed successfully then start the webserver and MariaDB database engine as shown

$ sudo systemctl enable httpd --now
$ sudo systemctl enable mariadb --now

Step 3) Create a database for Zabbix

Once the LAMP stack is in place, you need to configure a database for Zabbix server to store its files.

Before setting up the database for Zabbix, first set mysql root password, disable remote root logins and delete test database. Execute “mysql_secure_installation” command, example is shown below:

$ sudo mysql_secure_installation

mysql-secure-installation-zabbix-centos8

mysql-secure-installation-changes-centos8

Now, log in to MariaDB server

$ mysql -u root -p

Use the same root password that you have set in above command.

To create and configure database (zabbix_db), run the command:

CREATE DATABASE zabbix_db CHARACTER SET utf8 collate utf8_bin;

The create a database user (zabbix_user) and grant then grant all rights on the database.

GRANT ALL ON zabbix_db.* TO 'zabbix_user'@'localhost' IDENTIFIED BY 'P@ssw0rd@123#';

Finally, reload the grants table for the changes to take effect and exit

FLUSH PRIVILEGES;
EXIT;

Zabbix-Database-CentOS8

The database for Zabbix is in place, now configure Zabbix repository and install Zabbix server in next steps.

Step 4) Configure Zabbix Repository

Zabbix repository is not included by default, and for that reason, you need to manually add it on your system. To accomplish this, execute

$ sudo rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm

Step 5) Install Zabbix Server

With Zabbix repository in place, now proceed and install Zabbix and associated packages by running the command below:

$ sudo dnf install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-apache-conf

Install-Zabbix-Server-dnf-command-CentOS8

You will get the output below as a confirmation that Zabbix and associated dependencies have been installed

Successfully-Installed-Zabbix-Packages-CentOS8

You can now proceed and start Zabbix server, agent, Apache web server and PHP-FPM

$ sudo systemctl start zabbix-server zabbix-agent php-fpm httpd

Next, enable the services to start upon a reboot or on boot:

$ sudo systemctl enable zabbix-server zabbix-agent php-fpm

By default, Zabbix server listens on port 10050 while the Zabbix agent listens on port 10051. You can confirm if the 2 services are listening by running the netstat command as shown:

Note: If netstat command is not installed on your system then first installed it using the command :

$ sudo dnf install net-tools -y
$ sudo netstat -tunlp

netstat-zabbix-server-centos8

Step 6) Configure Zabbix Server

The first step in configuring Zabbix is to import the database schema into the database that was created for Zabbix in step 2.  So run the commands below:

$ cd /usr/share/doc/zabbix-server-mysql/
$ sudo zcat create.sql.gz | mysql -u zabbix_user -p zabbix_db

In above command specify the zabbix_user password that we have created during Zabbix database creation. (In my case zabbix_user password would be P@ssw0rd@123#)

Next, specify the Zabbix database information in the zabbix.conf file as shown

$ sudo vi /etc/zabbix/zabbix_server.conf

Be on the lookout for the following Database attributes – DBHost, DBName, DBUser and DBPassword and fill them out according to the database credentials.

DBHost=localhost
DBName=zabbix_db
DBUser=zabbix_user
DBPassword=P@ssw0rd@123#

Save and exit the file.

Finally, Set the timezone by editing the file  zabbix.conf in /etc/php-fpm.d/zabbix.conf.

For example, to set timezone in London, Europe, edit the file as shown

php_value[date.timezone] = Europe/London

Here are additional timezones that you can use.

Once you are done, save and exit. Then, restart the Zabbix services and PHP-FPM to effect the changes made.

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

Step 7)  Configure the Firewall Rules for Zabbix

To allow Zabbix agent from other servers to access the Zabbix Server, you need to open the Zabbix ports and port 80 associated with Apache web server on the firewall.  Therefore, run the commands below:

$ sudo firewall-cmd --permanent --add-port=10050/tcp
$ sudo firewall-cmd --permanent --add-port=10051/tcp
$ sudo firewall-cmd --permanent --add-port=80/tcp

To save the changes, reload the firewall

$ sudo firewall-cmd --reload

Step 8) Finalize Zabbix installation via a browser

With all the configurations in place, the only thing left to do is to finalize the installation via a browser. Therefore, fire up your browser and browse the server’s address as shown:

http://server-ip/zabbix

You will get a ‘Welcome’ page as shown: Click ‘Next Step’ to proceed to the next step

Zabbix-Server-Setup-Page-CentOS8

The next page displays all the prerequisites needed for the installation of Zabbix. If some errors are displayed, click on the ‘Back’ button and install what’s missing. If there are no errors as shown, click ‘Next step’ to go ahead with the installation.

Pre-requisites-check-zabbix-gui-centos8

In the next step, provide the database details as shown and click ‘Next step

Zabbix-Database-Details-GUI-CentOS8

Next, specify the name of your database server as indicated in the ‘Name’ text field.  Leave other details just as they are and click ‘Next Step

Zabbix-Server-Details-CentOS8

The next page presents you with a summary of the database information that you have provided. If all is good, click ‘Next Step’. Else go back and make corrections if need be.

Pre-Installation-Summary-CentOS8

If the details you provided are correct, you will get a notification below indicating that you have successfully installed Zabbix server. Click ‘Finish’.

Zabbix-Successfull-installation-CentOS8

A login page will be displayed below: Use Admin as the username and zabbix as the password to sign in.

Zabbix-Login-Page-CentOS8

Finally, you will get the dashboard displayed as shown.

Dashboard-Zabbix-Server-CentOS8

Bravo! you have successfully managed to install Zabbix server on CentOS 8.

Also Read: How to Add Linux Host in Zabbix Server for Monitoring

Also Read: How to Add Windows Host to Zabbix Server for Monitoring

The post How to Install Zabbix Monitoring Tool on CentOS 8/RHEL 8 first appeared on LinuxTechi.]]>
https://www.linuxtechi.com/install-zabbix-monitroing-tool-centos-8-rhel-8/feed/ 1
How to Integrate Grafana with Prometheus for Monitoring https://www.linuxtechi.com/integrate-grafana-prometheus-monitoring/ https://www.linuxtechi.com/integrate-grafana-prometheus-monitoring/#comments Mon, 13 Jan 2020 04:31:45 +0000 http://www.linuxtechi.com/?p=9577 Grafana is a free and opensource tool for querying, analyzing and visualizing metrics from an array of multiple data sources whether physical or from the cloud. With Grafana, you can create, explore and share beautiful and intuitive dashboards from different data sources without a hassle. ... Read more

The post How to Integrate Grafana with Prometheus for Monitoring first appeared on LinuxTechi.]]>
Grafana is a free and opensource tool for querying, analyzing and visualizing metrics from an array of multiple data sources whether physical or from the cloud. With Grafana, you can create, explore and share beautiful and intuitive dashboards from different data sources without a hassle. Some of the data sources it connects with include MySQL server, Graphite, PostgreSQL, InfluxDB, Elasticsearch, and Prometheus. In this guide, we will demonstrate how you can integrate Prometheus with Grafana. But first, we are going to Install Grafana. Check out our previous topic to see how you can install Prometheus on CentOS 8.

Installing Grafana on CentOS 8 / RHEL 8

We are going to install Grafana from the YUM/ DNF repository as it is much easier compared to downloading and running the .rpm package.

Step 1) Enable the DNF (or Yum) repository for Grafana

To begin with, add Grafana’s yum repository by creating a repository file as shown as root user

[root@grafana ~]# vi /etc/yum.repos.d/grafana.repo
[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

save and exit the file

Run below dnf command to view all enabled package repositories, in the output we should see Grafana repository too.

[root@grafana ~]# dnf repolist

dnf-repolist-grafana-centos8

Step 2)  Install Grafana Monitoring tool

To install Grafana, use the DNF package manager as follows:

[root@grafana ~]# dnf install grafana -y

You can verify that Grafana is installed using the rpm command as shown

[root@grafana ~]# rpm -qa | grep grafana
grafana-6.5.2-1.x86_64
[root@grafana ~]#

To gather more information about Grafana such as the version, architecture and license, run the command:

[root@grafana ~]# rpm -qi grafana

grafana-rpm-qf-centos8

Step 3) Start and enable Grafana service

With Grafana successfully installed, we need to start the Grafana service and ensure it is running. So to start Grafana, run the command:

[root@grafana ~]# systemctl daemon-reload
[root@grafana ~]# systemctl start grafana-server

To enable Grafana on boot run:

[root@grafana ~]# systemctl enable grafana-server

You can verify that Grafana is running by executing the command:

[root@grafana ~]# systemctl status grafana-server

Grafana-service-status-centos8

Additionally, you can use the netstat command to verify if Grafana is listening on its default port, which is port 3000.

grafana-port-netstat-output-centos8

Step 4) Open the port for Grafana in the Firewall

If you have a firewall running on your system, you need to allow port 3000 for external users to access Grafana on the browser. To open port 3000, execute the command:

[root@grafana ~]# firewall-cmd --add-port=3000/tcp --permanent
success
[root@grafana ~]#

Then reload the firewall to effect the changes

[root@grafana ~]# firewall-cmd --reload
success
[root@grafana ~]#

Step 5) Accessing Grafana

With all the configuration done, head over to your browser and visit your Grafana server’s URL as shown:  http://server-ip:3000/

Grafana-Login-Page-CentOS8

Login using the default credentials as shown:

  • Username: admin
  • Password: admin

Grafana will then prompt you to set a strong password for obvious reasons. Type the new password and confirm it and finally click on the ‘Save’ button to save the changes made to your password.

Change-Password-Grafana-Admin-User

This ushers you to Grafana’s dashboard.

Grafana-Dashboard-CentOS8

We have successfully installed the Grafana monitoring server. Now it’s time to switch gears and integrate Grafana with the Prometheus server which we installed in our last topic.

Integrate Grafana with Prometheus for Monitoring

While Prometheus can display accurate system metrics, Grafana is the better of the two giving you intuitive and visually appealing dashboards that display a wide array of metrics as you will see. Additionally, you can customize, query and save the dashboards and even share them with other users.

In this section, we demonstrate how you can integrate Prometheus with Grafana. On the dashboard, click on the  ‘Add data source’ option

Add-Source-Grafana-Dashboard

A list of data sources will be displayed that you can integrate with. Because we are interested in Prometheus integration, simply click on the ‘Prometheus’ option

Add-Prometheus-Grafana-Dashboard

Type the Prometheus server address in the URL text field

http://prometheus-server-ip:9090/

Prometheus-Server-Settings-Grafana

Click the  ‘Save and Test’ button and you should get the output indicating ‘Data source is working’.

Data-Source-Working-Grafana

To create a dashboard for visualizing metrics, click on the plus sign on the left sidebar and click on ‘import

Import-Data-Grafana-Dashboard

You will be required to fill out the URL of a dashboard from Grafana’s repository. So, head out to Grafana’s official dashboards page and right-click on a node_exporter dashboard ( I have selected the first one because of its good reviews and many downloads) and copy its link.

discover-share-dashboards-Grafana

Paste the link in the URL section

Grafana-Prometheus-dashboard-Jason

Once you paste the link, wait a few seconds and the data below will be generated. Change the Prometheus Data Source Name as “Prometheus-1” and then Click on ‘Import

Import-Dashboard-Grafana-Json-File

Grafana will begin fetching the metrics from the Prometheus server and visualize then in colorful and intuitive dashboards.

Node-Exporter-Prometheus-Dashboard-Grafana

You can select a dashboard for a specific component and view it on full screen mode.

Specific-Component-Dashboard-Grafana

This wraps up our tutorial today, We hope you can now integrate Prometheus and Grafana and enjoy stunning and beautiful visualizations.

The post How to Integrate Grafana with Prometheus for Monitoring first appeared on LinuxTechi.]]>
https://www.linuxtechi.com/integrate-grafana-prometheus-monitoring/feed/ 3
How to Install Prometheus on CentOS 8 / RHEL 8 https://www.linuxtechi.com/install-prometheus-monitoring-tool-centos-8-rhel-8/ https://www.linuxtechi.com/install-prometheus-monitoring-tool-centos-8-rhel-8/#comments Fri, 10 Jan 2020 04:53:15 +0000 http://www.linuxtechi.com/?p=9541 Prometheus is an open source monitoring, querying and alerting tool. Originally built by Soundcloud in 2012, the feature-rich tool has been adopted by several companies to monitor their IT infrastructure and ensure all systems are running smoothly. Prometheus allows you to query and pull time-series ... Read more

The post How to Install Prometheus on CentOS 8 / RHEL 8 first appeared on LinuxTechi.]]>
Prometheus is an open source monitoring, querying and alerting tool. Originally built by Soundcloud in 2012, the feature-rich tool has been adopted by several companies to monitor their IT infrastructure and ensure all systems are running smoothly. Prometheus allows you to query and pull time-series metrics such as CPU & memory utilization over HTTP protocol and visualize them on real-time graphs. You can also configure Prometheus to push alerts in the event of a node or service downtime and integrate it with other third-party monitoring tools such as Grafana for enhanced data visualization. In this guide, we will look at the installation of Prometheus on the CentOS 8 /RHEL 8 system.

Step1) Creating a Prometheus user and group

To start off, we are going to create a system user for Prometheus. Execute the command below to achieve this.

[root@prometheus ~]# useradd -m -s /bin/false prometheus
[root@prometheus ~]# id prometheus
uid=1002(prometheus) gid=1002(prometheus) groups=1002(prometheus)
[root@prometheus ~]#

As you may have noted, the system user has no login permissions as specified in the /bin/false option

Step 2) Creating configuration directories for Prometheus

Once the user for Prometheus has been created, we are then going to create configuration directories in the /etc and /var directories which will store Prometheus configuration files and data. So run the commands below:

[root@prometheus ~]# mkdir /etc/prometheus
[root@prometheus ~]# mkdir /var/lib/prometheus

Set the ownership on /var/lib/prometheus

[root@prometheus ~]# chown prometheus /var/lib/prometheus/

Step 3) Downloading Prometheus tar file

With the directories in place, we can now download the Prometheus. To get the latest version, head out to the Download page to obtain the latest version for your environment. At the time of penning down this article, the latest version was v 2.14.0. Alternatively, just run the command below

[root@prometheus ~]# dnf install wget -y
[root@prometheus ~]# wget https://github.com/prometheus/prometheus/releases/download/v2.14.0/prometheus-2.14.0.linux-amd64.tar.gz -P /tmp

Once the download is complete, extract the tarball file as shown

[root@prometheus tmp]# tar -zxpvf prometheus-2.14.0.linux-amd64.tar.gz

This will leave you with a directory called prometheus-2.14.0.linux-amd64

Use tree command to view directory structure,

prometheus-directory-structure

The extracted directory contains 2 binary files  prometheus & promtool and that we need to copy to the /usr/local/bin path.

So, navigate to the extracted directory and copy them using the command:

[root@prometheus ~]# cd /tmp/prometheus-2.14.0.linux-amd64
[root@prometheus prometheus-2.14.0.linux-amd64]# cp prometheus  /usr/local/bin

Do likewise to the other binary file

[root@prometheus prometheus-2.14.0.linux-amd64]# cp promtool  /usr/local/bin

Step 4) Creating a configuration file for Prometheus

To start off with the configuration, create a file /etc/prometheus/prometheus.yml and paste the configuration in the file

[root@prometheus ~]# vi /etc/prometheus/prometheus.yml
# Global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 
  scrape_timeout: 15s  # scrape_timeout is set to the global default (10s).
# A scrape configuration containing exactly one endpoint to scrape:# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['localhost:9090']

This will only monitor your local system only ( Prometheus Server).

Next, adjust the firewall as follows to allow external connections to the server via port 9090

[root@prometheus ~]# firewall-cmd --add-port=9090/tcp --permanent
success
[root@prometheus ~]# firewall-cmd --reload
success
[root@prometheus ~]#

Step 5) Creating a Systemd service file for Prometheus Server

For us to manage Prometheus as a service using systemd, we need to create a system file for it. So, create the file as shown and paste the content,

[root@prometheus ~]# vi /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Time Series Collection and Processing Server
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
    --config.file /etc/prometheus/prometheus.yml \
    --storage.tsdb.path /var/lib/prometheus/ \
    --web.console.templates=/etc/prometheus/consoles \
    --web.console.libraries=/etc/prometheus/console_libraries

[Install]
WantedBy=multi-user.target

For the changes to take effect, reload the systemctl,

[root@prometheus ~]# systemctl daemon-reload

Now start and enable Prometheus to run on boot

[root@prometheus ~]# systemctl start prometheus
[root@prometheus ~]# systemctl enable prometheus

Just to be certain that Prometheus is running, run the command:

[root@prometheus ~]# systemctl status prometheus

prometheus-service-status-centos8

From the output displayed, we can clearly see that Prometheus is running as expected with no errors. Also, you can use the netstat utility to check is the service is listening on port 9090.

[root@prometheus ~]# netstat -tunlp

netstat-prometheus-centos8

That’s great! Prometheus is running on port 9090 as expected. Now head to your browser as browse your server’s IP as shown

http://server-ip:9090

Prometheus-dashboard-CentOS8-RHEL8

Click on the ‘Status’ tab and then click on ‘Targets

Target-Option-Prometheus-Dashboard

Your system will be displayed as shown

Prometheus-Target-Node-dashboard-CentOS8

Step 6) Install & configure node_exporter

Node exporter is a utility that collects and ships a vast array of Linux system metrics such as CPU, memory usage, filesystems and network statistics. In this section, we are going to install node_exporter on the Prometheus server and on a remote CentOS 8 Linux host and monitor system metrics on the two hosts.

On the Prometheus node, we are going to create a system user for node_exporter.

[root@prometheus ~]# useradd -m -s /bin/false node_exporter

Next, head out to the downloads Page of Prometheus and download the node_exporter tarball or use below wget to command to downlond it from command line,

[root@prometheus ~]# wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz

Upon downloading the node_exporter file, proceed and extract it as shown

[root@prometheus ~]# tar -zxpvf node_exporter-0.18.1.linux-amd64.tar.gz

You can check the contents of the extracted folder using the tree command as shown

[root@prometheus ~]# tree node_exporter-0.18.1.linux-amd64

Extract-Node-Exporter-CentOS8

Next, copy the binary file called node_exporter to /usr/local/bin path

[root@prometheus ~]# cp node_exporter-0.18.1.linux-amd64/node_exporter /usr/local/bin

Next, set the file permissions of the node_exporter file which has been copied as shown

[root@prometheus ~]# chown node_exporter:node_exporter /usr/local/bin/node_exporter

Next, we need to configure node_exporter to run as a service. So, proceed and create a systemd service file as shown

[root@prometheus ~]# vi /etc/systemd/system/node_exporter.service

Then paste the configuration shown below and save the file

[Unit]
Description=Prometheus Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=multi-user.target

For the changes to take effect, reload systemd manager with the command:

[root@prometheus ~]# systemctl daemon-reload

Next, start and enable node_exporter service

[root@prometheus ~]# systemctl start node_exporter
[root@prometheus ~]# systemctl enable node_exporter

Just to be sure that the service is running, execute:

[root@prometheus ~]# systemctl status node_exporter

node-exporter-service-status

Just to be sure that the service is running, use the netstat utility to check if it’s listening on port 9100 as is expected by default.

[root@prometheus ~]# netstat -pnltu | grep 9100
tcp6       0      0 :::9100       :::*          LISTEN      3472/node_exporter
[root@prometheus ~]#

Perfect! Node_exporter service is running as expected.

Next, open port 9100 in firewall as shown

[root@prometheus ~]# firewall-cmd --add-port=9100/tcp  --permanent
success
[root@prometheus ~]# firewall-cmd --reload
success
[root@prometheus ~]#

Repeat the steps outlined for the remote CentOS 8 Linux system as well.

Finally, you need to add the node_exporter target to the prometheus.yml file. Append the lines below to define node_exporter for the Prometheus server

[root@prometheus ~]# vi /etc/prometheus/prometheus.yml
---------
 - job_name: 'node_exporter'
   static_configs:
   - targets: ['localhost:9100']

Localhost-node-exporter-Prometheus-CentOS8

Restart Prometheus service

[root@prometheus ~]# systemctl restart prometheus

Once again,  head out to your browser, click on the ‘Status’ tab and click on ‘Targets

Be sure to observe a new endpoint on the browser called node_exporter  for the Prometheus server

Node-Exporter-Prometheus-Dashboard

To add an endpoint for the remote Linux system head back to the prometheus.yml file and append the line below

– targets: [‘192.168.10.90:9100’]

The node_exporter section should now look like this

 - job_name: 'node_exporter'
   static_configs:
   - targets: ['localhost:9100']
   - targets: ['192.168.10.90:9100']

Save the changes and restart Prometheus service

[root@prometheus ~]# systemctl restart prometheus

Refresh the browser and notice the second endpoint that has been added for the remote CentOS Linux system

CentOS8-Remote-Host-Node-Exporter-Prometheus

To ensure that you are receiving metrics, from your configured nodes. simply use the curl command as follows:

# curl http://node-ip:9100/metrics

For example, to display metrics from the Prometheus server run:

[root@prometheus ~]# curl http://localhost:9100/metrics

Localhost-Metrics-curl-prometheus-centos8

For the remote CentOS 8 host, I executed the command:

[root@prometheus ~]# curl http://192.168.10.90:9100/metrics

Remote-CentOS8-Host-Metrics-Prometheus

This can also be achieved by opening a browser and browsing the URL

http://192.168.10.90:9100/metrics

Remote-Metrics-GUI-Prometheus

You can also choose to graph the metrics that you want. Simply go to the home page pf the Prometheus server, and click on the drop-down menu labeled ‘insert metric at cursor’.

Insert-Metric-Cursor-Prometheus-CentOS8

Select the metric you want to graph,

Choose-node-memory-active-prometheus

Click on the ‘Execute’ button and click on the ‘graph’ tab just below to reveal the graph

Graph-Creation-Prometheus-CentOS8

And this brings us to the end of this topic. You have successfully installed and configured Prometheus to monitor system metrics on both your server and remote host. In our next guide, we will integrate Prometheus with Grafana for better visualization and analysis of metrics. Feel free to share your feedback with us and share the article with a friend.

Also Read : How to Integrate Grafana with Prometheus for Monitoring

The post How to Install Prometheus on CentOS 8 / RHEL 8 first appeared on LinuxTechi.]]>
https://www.linuxtechi.com/install-prometheus-monitoring-tool-centos-8-rhel-8/feed/ 4
25 Top Command Examples to Monitor Linux Server Performance https://www.linuxtechi.com/top-command-monitor-linux-server/ https://www.linuxtechi.com/top-command-monitor-linux-server/#respond Sun, 08 Dec 2019 15:16:11 +0000 http://www.linuxtechi.com/?p=9362 The Top utility tool is a handy tool that gives Linux users a peek at the performance statistics on their systems. You can use it to monitor resource metrics such as memory usage, CPU, load average, uptime and processes that are running on the system. ... Read more

The post 25 Top Command Examples to Monitor Linux Server Performance first appeared on LinuxTechi.]]>
The Top utility tool is a handy tool that gives Linux users a peek at the performance statistics on their systems. You can use it to monitor resource metrics such as memory usage, CPU, load average, uptime and processes that are running on the system.

Top utility tool gives the user an overview of the system’s crucial performance statistics. The image below is a screenshot of the terminal showing the system’s statistics such as users logged in, tasks, uptime, CPU utilization, memory utilization and swap usage.

top-command-linux-output

Every column above represents different information as the horizontal lines indicate a summary of the different areas running in the system. Let us analyze some of the columns for better understanding.

PID –  This stands for Process ID. Every running process on the Linux systems bears a PID

USER – This is the user running the process or use that the process is running under.

PR – Indicates process priority from the Linux Kernel

NI –  represents the nice value that matches the user space. The value ranges from -20 as the highest figure, 0 the default, and +19 as the lowest. There is a relationship between nice value and priority which is PR = 20 + NI

VIRT – represents the amount of virtual memory the process is using. It also describes the virtual size of a process.

RES – Defines the resident memory capacity.

SHR – This refers to shared memory that a process is assigned.  It also indicates how much of the VIRT is available for sharing in terms of libraries or memory.

  • S – Represents the status of a particular process that has the following values:
  • D – A process waiting for something to happen
  • R – Ready to run the process
  • S – Process sleep state waiting for a trigger
  • T – Indicates a traced or stopped process
  • Z – Indicates a dead process (Zombie process) or one that has completed execution

%CPU – time the task has been using since the last update. On machines with more than CPU, the percentage can be more than 100%

%MEM – a percentage of the available physical memory a process is using

TIME+ – Represents the total time a task is utilizing since it was started

COMMAND – Represents the actual process or command currently running

Other output on the command line following the top command may not be visible on the first page. They include:

  • Uptime and load average
  • CPU states
  • Tasks
  • Memory usage

1) Using Top Help Menu

The interactive nature of the help menu gives options on the number of commands administrators use. To get help using the top utility, simply type h or the question mark symbol ?

help-top-command-linux

2) Manual Display Refresh

By default, the top command displays information on a 3 seconds interval. To get the manual refresh mode use the ENTER or SPACE keys.

3) Changing Display Mode

Instead of using a single-window to analyze your system, you can set the output to display four windows each with a different field or group using the names:

  • Mem : sort by %MEM
  • Def : Sort by %CPU
  • Job : sort by PID
  • Usr : Sort by User field

The Alternative Display Mode is achieved by pressing A, giving each field a unique summary.

display4-columns-top-command

Toggling between windows is possible through a (next) and w (previous) keys. Additionally, you can press g  and enter between 1 to 4 to toggle between the windows.

4) Display in Bold

The use of letter B changes the output to bold. When the B is ON and is in monochrome mode, the whole screen will appear as normal unless the x and y are on reverse mode giving no visual display

5) Set the Time Interval

Use the d or the s keys to change the output delay time frame. When you enter either d or s, you will get a prompt to enter a value, which the display will pick as its interval in seconds

Change-time-interval-top-command

6) Shifting Load, Memory, and Task info

The keys m, t, l toggles the memory info, task or CPU status, and load average, respectively.

7) Display Field Management

Use F to choose the field you want to use on the screen. To select a field, press the SPACE or the d keys until you see the fields with an Asterix (*) are selected. Once you are done, quit using the q or ESC key.

Press-F-select-fields-top-command

Manipulating the above output use, the < or > keys to manipulate the above output either to the left or to the right.

8) Reverse Sorting

The default order of sorting takes place in descending order. Use R to reverse the order. The use of this interaction highlights processes that consume the least amount of CPU at the top.

9) Show the full path of command

You will use C to get the full path alongside the command line arguments in its column as shown

Press-c-top-command

10) Idle Tasks

The i key displays all the active tasks. When it is off no task that has not been used will be displayed. However, when %CPU and TIME+ fields come into focus, some processes may show but with no CPU allocated time or usage.

11) Forest View

Use the V key to display processes in a hierarchical manner

v-option-top-command

12) Changing Color Map

Press the Z key to get a screen that allows you to change colors. Z brings another screen that manipulates the color of the present window or all four windows. You will see four uppercase letters that give an option of selecting eight numbers to get the color you want.

Color-mapping-using-Z-top-command

13)  Toggle Color

To turn on /off the screen output, use z to switch the active window to the last color scheme. The command alters the summary and the task area.

14)  Change the Highlight of the Sort Field and Active Tasks

Hit the x  key for the columns toggle changes. A particular sort field may not be visible due to insufficient screen size, and at the same time, the iterative f command is off.

15) Show User Specific Processes

Pressing the letter u will prompt for a user and later display the processes associated with the user.

Prompt-for-user-top-command

The output below lists processes by the user linuxtechi

Show-processes-user-top-command

16) The Number of Tasks Displayed

Use n or # prompts you to enter the maximum number of tasks to be displayed.

Prompt-maximum number-tasks-top

The screen output below shows the number of tasks (10) to display.

top-ten-tasks-top-command

17) Kill Tasks

To kill a task, simply hit the k key on the keyboard. This prompts for the PID of the process you wish to end.  If no PID is provided, the default signal will be ended.

Press-letter-k-prompt-pid-top-command

18)  Renice Task

Administrators use the r option to change process priority and may reschedule its priority. When using r, you will get a prompt for the PID and a value to nice it. A negative number or no PID entry defaults to the first task on the output. Enter a 0 if you want to renice the top command, while at the same time keying in a positive PID leads to loss of priority, and a negative one will gain favor in the kernel.

The default case of renicing allows the user to increase but not lower the nice value. Abort any of the renice processes using:

  • At the PID prompt, specify an invalid number
  • At the nice prompt key in ENTER
  • At any prompt, use ESC key

Renice-top-command

19) Separate CPU States

To issue the above command, you must know that keying in t affects how the CPU state appears. You will note the %CPU in the summary area.

20) Summarize the CPU State

Use the number 2 as the command to toggle between CPU summary display (obtained by 1) or the summary in addition to statistics for each node.

21) Use top command to send output to another file

If you wish to save the output of top command onto another file, use the -b option.

$ top -b -n 1 > output.txt$ cat output.txt

redirect-top-output-file

22) Idle Process Toggle in Command Line

The i option sets the top command with its last state

top-with-i-option

23) Set the Number of Iterations in Command Line

Use the -n option to set the number of iterations the top command goes through before it exits

top-n-iterations

24) Monitor Specific PIDs

As an Administrator, you may want to follow a particular PID using the -p option. A value of 0 focuses on the command (top) itself.

Use the following syntax

$ top -p pid_value

For example,

$ top -p 3520

Follow-specific-PID-top-command

25) Check the Version of Top Command

System Administrators can use -v option to view top command version

top-v-check-version

Conclusion

As you have seen, using the top utility to monitor your systems’ performance is quite easy. The tool gives you a glance of what’s happening on your system and can be an excellent tool for troubleshooting purposes especially when your system slows down due to a process hogging the system’s resources.

Also ReadHow to Use htop to Monitor Linux System Processes

The post 25 Top Command Examples to Monitor Linux Server Performance first appeared on LinuxTechi.]]>
https://www.linuxtechi.com/top-command-monitor-linux-server/feed/ 0
How to Install and Configure Nagios Core on CentOS 8 / RHEL 8 https://www.linuxtechi.com/install-nagios-core-rhel-8-centos-8/ https://www.linuxtechi.com/install-nagios-core-rhel-8-centos-8/#comments Sun, 27 Oct 2019 15:18:04 +0000 https://www.linuxtechi.com/?p=9106 Nagios is a free and opensource network and alerting engine used to monitor various devices, such as network devices, and servers in a network. It supports both Linux and Windows OS and provides an intuitive web interface that allows you to easily monitor network resources. ... Read more

The post How to Install and Configure Nagios Core on CentOS 8 / RHEL 8 first appeared on LinuxTechi.]]>
Nagios is a free and opensource network and alerting engine used to monitor various devices, such as network devices, and servers in a network. It supports both Linux and Windows OS and provides an intuitive web interface that allows you to easily monitor network resources. When professionally configured, it can alert you in the event a server or a network device goes down or malfunctions via email alerts. In this topic, we shed light on how you can install and configure Nagios core on RHEL 8 / CentOS 8.

Install-Nagios-Core-RHEL8-CentOS8

Prerequisites of Nagios Core

Before we begin, perform a flight check and ensure you have the following:

  • An instance of RHEL 8 / CentOS 8
  • SSH access to the instance
  • A fast and stable internet connection

With the above requirements in check, let’s roll our sleeves!

Step 1: Install LAMP Stack

For Nagios to work as expected, you need to install LAMP stack or any other web hosting stack since it’s going to run on a browser. To achieve this, execute the command:

# dnf install httpd mariadb-server php-mysqlnd php-fpm

Install-LAMP-stack-CentOS8

You need to ensure that Apache web server is up and running. To do so, start and enable Apache server using the commands:

# systemctl start httpd
# systemctl enable httpd

Start-enable-httpd-centos8

To check the status of Apache server run

# systemctl status httpd

Check-status-httpd-centos8

Next, we need to start and enable MariaDB server, run the following commands

# systemctl start mariadb
# systemctl enable mariadb

Start-enable-MariaDB-CentOS8

To check MariaDB status run:

# systemctl status mariadb

Check-MariaDB-status-CentOS8

Also, you might consider hardening or securing your server and making it less susceptible to unauthorized access. To secure your server, run the command:

# mysql_secure_installation

Be sure to set a strong password for your MySQL instance. For the subsequent prompts, Type Yes and hit ENTER

Secure-MySQL-server-CentOS8

Step 2: Install Required packages

Apart from installing the LAMP server, some additional packages are needed for the installation and proper configuration of Nagios. Therefore, install the packages as shown below:

# dnf install gcc glibc glibc-common wget gd gd-devel perl postfix

Install-requisite-packages-CentOS8

Step 3: Create a Nagios user account

Next, we need to create a user account for the Nagios user. To achieve this , run the command:

# adduser nagios
# passwd nagios

Create-new-user-for-Nagios

Now, we need to create a group for Nagios and add the Nagios user to this group.

# groupadd nagiosxi

Now add the Nagios user to the group

# usermod -aG nagiosxi nagios

Also, add Apache user to the Nagios group

# usermod -aG nagiosxi apache

Add-Nagios-group-user

Step 4: Download and install Nagios core

We can now proceed and install Nagios Core. The latest stable version in Nagios 4.4.5 which was released on August 19, 2019.  But first, download the Nagios tarball file from its official site.

To download Nagios core, first head to the tmp directory

# cd /tmp

Next download the tarball file

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

Download-Nagios-CentOS8

After downloading the tarball file, extract it using the command:

# tar -xvf nagios-4.4.5.tar.gz

Next, navigate to the uncompressed folder

# cd nagios-4.4.5

Run the commands below in this order

# ./configure --with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-daemoninit
# make install-config
# make install-commandmode
# make install-exfoliation

To setup Apache configuration issue the command:

# make install-webconf

Step 5: Configure Apache Web Server Authentication

Next, we are going to setup authentication for the user nagiosadmin. Please be mindful not to change the username or else, you may be required to perform further configuration which may be quite tedious.

To set up authentication run the command:

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

Configure-Apache-webserver-authentication-CentOS8

You will be prompted for the password of the nagiosadmin user. Enter and confirm the password as requested. This is the user that you will use to login to Nagios towards the end of this tutorial.

For the changes to come into effect, restart your web server.

# systemctl restart httpd

Step 6: Download & install Nagios Plugins

Plugins will extend the functionality of the Nagios Server. They will help you monitor various services, network devices, and applications. To download the plugin tarball file run the command:

# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz

Next, extract the tarball file and navigate to the uncompressed plugin folder

# tar -xvf nagios-plugins-2.2.1.tar.gz
# cd nagios-plugins-2.2.1

To install the plugins compile the source code as shown

# ./configure --with-nagios-user=nagios --with-nagios-group=nagiosxi
# make
# make install

Step 7: Verify and Start Nagios

After the successful installation of Nagios plugins, verify the Nagios configuration to ensure that all is well and there is no error in the configuration:

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Verify-Nagios-settings-CentOS8

Next, start Nagios and verify its status

# systemctl start nagios
# systemctl status nagios

Start-check-status-Nagios-CentOS8

In case Firewall is running on system then allow “80” using the following command

# firewall-cmd --permanent --add-port=80/tcp
# firewall-cmd --reload

Step 8: Access Nagios dashboard via the web browser

To access Nagios, browse your server’s IP address as shown

http://server-ip/nagios

A pop-up will appear prompting for the username and the password of the user we created earlier in Step 5. Enter the credentials and hit ‘Sign In

Access-Nagios-via-web-browser-CentOS8

This ushers you to the Nagios dashboard as shown below

Nagios-dashboard-CentOS8

We have finally successfully installed and configured Nagios Core on CentOS 8 / RHEL 8. Your feedback is most welcome.

Also Read : How to Add Windows and Linux host to Nagios Server for Monitoring

Also Read :  How to Setup Multi Node Elastic Stack Cluster on RHEL 8 / CentOS 8

The post How to Install and Configure Nagios Core on CentOS 8 / RHEL 8 first appeared on LinuxTechi.]]>
https://www.linuxtechi.com/install-nagios-core-rhel-8-centos-8/feed/ 12