How to Install and Use ApacheTop

Reading Time: 4 minutes

What is ApacheTop?

ApacheTop is an uncomplicated command line (CLI) utility that is used to monitor http traffic in real-time. It achieves this task by analyzing the incoming apache logs and based on that data presents understandable output to our screen. It can be configured to output X number of hits, or output X number of hits within X seconds.

Introduction to ApacheTop

Website owners and administrators oftentimes find themselves interested in the traffic for a specific website or multiple websites on the server. They might need this information in order to troubleshoot a high load issue on the server, or simply to learn the traffic pattern of a website, which is crucial for running a business. This information is logged in the web server’s access logs, and we can look through them to learn about the website’s traffic that has occurred in the past. Parsing through these logs to make most sense of them requires some basic skills in Bash, though, so it is not always very convenient.

However, we might want to learn more about the traffic in real-time in cases of currently high load on the server or issues with a website. In this case, we can use a monitoring tool called ApacheTop, which shows traffic in real-time. Furthermore, it collects the information from the web server’s access log and parses through it so that it generates human-readable output. This way, we can see what pages are being seen on the server in real-time, but we also do not need any Bash skills to parse through the output. It displays the information such as requests per second, bytes per second and URLs that are being requested, and its display is modelled after the standard top utility.

ApacheTop keeps a table of information by containing all the relevant data about the requests it has collected, but it can only be of a certain finite size. By default, it will show the data within the 30-second time frame, but we can define its size in a couple of ways. This can be done by making it remember a certain number of hits, or a certain number of seconds, after which it resets. We should also note that ApacheTop tool uses Apache’s default access log file for the traffic information, however, in case of a custom log path, we can also specify which log file to look through.

Installation

We can install ApacheTop like any other package, but we need to have the EPEL repository installed first.

CentOS Based Systems

yum install epel-release
yum install apachetop

Debian Based Systems

On Debian/Ubuntu based systems, we can use apt-get to install apachetop

apt-get install apachetop

Using ApacheTop

In order to use ApacheTop, we can simply run the command apachetop from the command line. This will, without specifying anything else, by default use the Apache access log and display information within a 30-second timeframe.

Flags

If we want to use a custom log path, we can specify it with the -f flag:

apachetop -f /path/to/the/log/file

In order to change the default 30 second time range for showing data, we can do so with one of the following flags:

  • H – This flag specifies the number of hits we want ApacheTop to display. The following example will show the last 100 hits
    apachetop -H 100 
  • T – This flag specifies the number of seconds for how long ApacheTop will keep track of the data. In the following example, ApacheTop will be showing hits in the last 60 seconds:
    apachetop -T 60

Some of the additional flags that we can also use include the following.

  • – q – This flag instructs ApacheTop to keep the query strings, instead of removing them
  • – l – This flag instructs ApacheTop to use all lowercase URLs, which causes it to accumulate the same statistics for both uppercase and lowercase URL
  • – s segments: This flag instructs ApacheTop to keep only the first parts of the path, which causes the statistics to be merged for each truncated URL
  • – p – protocol: This flag is kept at the front of its referrer strings. By default, it is removed to give more room to more useful information
  • – r secs: This flag sets the default refresh delay in seconds

Reading the Output

When we run the apachetop command, at the top of the screen we can see a summary of the statistics, as is shown in the image below. 

1 Last hit

The first line shows the time of the last hit, ApacheTop running time and the current time of the server.

The second and third lines show the statistics of all the visits since ApacheTop started running. On the second line we can see the total number of requests, along with the number of requests per second; total size of all requests with the number of bytes per second; and the average size of each request. The third line shows the number of requests that are returning 2xx, 3xx, 4xx and 5xx web server response codes.

The fourth and fifth lines show the same statistics as the second and the third respectively, but they only display the information within the specified, or default, time range.

Below these top five lines, we have the list of URLs that are being requested, with the total number of hits for each, and the size of the request in question, as can be seen in the image below.

2 URL List

The star (*) symbol next to the URL specifies which request is selected. We can select different requests by moving with the Up and Down arrow keys. Once we reach the request we are interested in, we can press the Right arrow key, which will take us to the page with details for that request. The details include the hosts requesting that URL and the referrers. To return to the main list, we can use the Left arrow key.

We can also switch the main view from showing the URLs, to show Hosts, or Referrers instead, by pressing the d key. In the image below, we are currently seeing the hosts instead of the URLs:

3 Hosts

Filters

We can also choose what to see in the view by using filters. We can access those by pressing the f key, and we will be presented with three options:

  • add
  • clear
  • show active

Pressing each of the letters will activate the corresponding action. If we want to add a filter, we would press the a key, and then we can choose if we want to filter by

  • url
  • referrer
  • hosts.

Pressing the corresponding key would let us enter which URL, or referrer or host we want to filter by. Once we enter the information, the view will only show the requests that fit the entered criteria.

Conclusion

The ApacheTop utility is an extremely useful monitoring tool that is easy to use while providing human-readable information that can help pinpoint the cause of certain server and website issues. However, one should keep in mind not to monitor the traffic with an extended time frame or too many hits, as that would use too many CPU and memory resources, which could only add to the problem at hand.

How to Install Graylog Sidecar

Reading Time: 4 minutes

What is Graylog Sidecar?

Graylog Sidecar is a nimble configuration management framework for various log collectors called backends. The Graylog master node acts as a centrally located hub that contains the configurations of the log collectors. Sidecar can run as a service on both Windows and Linux servers.

Continue reading “How to Install Graylog Sidecar”

How to Install and Configuring NTP on CentOS and Ubuntu

Reading Time: 8 minutes

Introduction

In this article we will learn what the Network Time protocol (NTP) is and how to install it on the two Linux distributions most commonly used on Liquid Web’s servers. We will be focusing on using CentOS 7 and Ubuntu 18.04 servers, but the process is largely the same on other recent versions of each. Before we start, make sure we are familiar with using SSH (Secure Shell) as we’ll need it to connect to the server. Here’s a link to one of our articles on the basics of SSH if you are unfamiliar with its usage.

Continue reading “How to Install and Configuring NTP on CentOS and Ubuntu”

How to Install Keras

Reading Time: 6 minutes
keras.logo.3.12.20

Keras is a Python-based high-level neural networks API that is capable of running on top TensorFlow, CNTK, or Theano frameworks used for machine learning. It can be said that Keras acts as the Python Deep Learning Library. Keras was created with emphasis on being user-friendly since the main principle behind it is “designed for human beings, not machines.” The core data structure of Keras is a model, or a way to organize layers.

Continue reading “How to Install Keras”

How To Install The Latest Kernel Version

Reading Time: 7 minutes

In this tutorial, we will learn how to install the latest kernel version on multiple Linux distributions. 

What Is A Kernel

terminal.cli.2.20.20

First, let’s define what a kernel is defined as. The Linux kernel is basically the brain of your hardware. Its main purpose is to facilitate communications between your hardware and software. As an example, if an application needs to make a change (say switching the screen resolution of your monitor), the software submits a request to the kernel, and the kernel uses the available video driver options to modify the resolution. 

Continue reading “How To Install The Latest Kernel Version”

How To Use The YUM History Command

Reading Time: 6 minutes

Have you ever wanted to review past updates or roll back an update that broke your sites or negatively affected some aspect of your server’s operations? Well, you can accomplish this easily by using the yum history command.

Continue reading “How To Use The YUM History Command”

How To Create A Software Install List

Reading Time: 3 minutes

Purpose

The purpose of this article is to describe and explore ways to copy or backup your currently existing installed software titles into a single file for later use. We can then use this file to reinstall the software onto another system or clone the existing software across multiple Linux systems on or across a network. This method also prevents the need to install software titles one by one.

Continue reading “How To Create A Software Install List”

Update: WHMCS CURL Bug

Reading Time: 2 minutes

WHMCS has discovered a problem in an earlier EA4 Curl Package introduced on CentOS servers.

Update!

UPDATE: This is reportedly fixed in ea-libcurl-7.67.0-2.2.1, so it should no longer be necessary to downgrade. (https://github.com/CpanelInc/libcurl/commit/7ca2bbb724ac54a3c41950c8736076953bf1429b)

Working versions:
* ea-libcurl-7.66.0-1.1.2.cpanel.x86_64
* ea-libcurl-7.67.0-2.2.1.cpanel.x86_64

Buggy version:
*ea-libcurl-7.67.0-1.1.2.cpanel.x86_64

Per https://forums.cpanel.net/threads/cpanel-curl-update-breaks-whmcs-enom-module.663449/ it may be necessary to restart PHP-FPM to apply the changes to the running PHP binaries.

Continue reading “Update: WHMCS CURL Bug”

Top 5 Reasons To Use CentOS 7

Reading Time: 4 minutesWhen you’re considering which Operating System to use for web hosting, there are many options available to you. We’re going to discuss 5 reasons you should choose CentOS 7 and the strengths of the platform. CentOS has been the preferred Linux distribution in the hosting industry for many years, and it was only recently that this distro was overtaken by Ubuntu Server as the primary OS used for web hosting.

Continue reading “Top 5 Reasons To Use CentOS 7”

DNF (Dandified Yum) Commands Explained!

Reading Time: < 1 minute

DNF (Dandified Yum) 101: Basic Package Manager Interaction
I. What is DNF (Dandified Yum)?
II. DNF Examples: Install, Remove, Upgrade, and Downgrade

Continue reading “DNF (Dandified Yum) Commands Explained!”