Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Troubleshooting CentOS
Troubleshooting CentOS

Troubleshooting CentOS: A practical guide to troubleshooting the CentOS 7 community-based enterprise server

eBook
$17.99 $25.99
Paperback
$32.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Troubleshooting CentOS

Chapter 2. Troubleshooting Active Processes

A deeper understanding of the underlying active processes in CentOS 7 is an essential skill for any troubleshooter. From high load averages to slow response times, system overloads to dead and dying processes, there comes a time when every server may start to feel sluggish, act impoverished, or fail to respond, and as a consequence, it will require your immediate attention.

In this chapter, we will:

  • Learn about memory management, swap, swappiness, and thrashing
  • Learn how to analyze active processes using the vmstat, top, and ps commands
  • Learn how to monitor the server with iotop, iostat, and lsof
  • Learn about system load and systemd
  • Learn how to find process IDs, identify parent process IDs and orphaned processes, and initiate the various forms of the kill signal

Tuning server performance with memory management and swap

Regardless of how you look at it, the question of memory usage remains critical to the life cycle of a system, and whether you are maintaining system health or troubleshooting a particular service or application, you will always need to remember that the use of memory is a critical resource to your system. For this reason, we will begin by calling the free command in the following way:

# free -m

The main elements of the preceding command will look similar to this:

         Total    used    free    shared    buffers    cached
Mem:      1837     274    1563         8          0       108
-/+ buffers/cache: 164    1673
Swap:     2063       0    2063

In the example shown, I have used the -m option to ensure that the output is formatted in megabytes. This makes it easier to read, but for the sake of troubleshooting, rather than trying to understand every numeric value shown, let's reduce the scope of the original output to highlight...

Managing memory with vmstat

A different aspect of memory management can be achieved by using the vmstat command. Considered to be a summary reporting feature associated with memory, processes, and paging, vmstat can be seen in action by typing:

# vmstat -a

Having used the -a option to call on all active and inactive memory, the most endearing columns shown under vmstat's output are best described as follows:

  • si: This column shows the value swapped in from disk
  • so: This column shows the value swapped out to disk
  • bi: This column shows the value sent to block devices
  • bo: This column shows the value received from block devices
  • us: This column shows the user time
  • sy: This column shows the system time
  • id: This column shows the idle time

The display does look quite confusing to begin with, but for our purposes, we want to concentrate on the following columns contained under the swap column:

free           si   so
1645452          0    0

Where free shows the current allocation of free memory, si shows...

Checking the system load with the top command

The top command can be called at any time by typing:

# top

The top command is the standard command for checking system load (RAM/MEM and CPU). It contains a lot of information related to tasks associated with the kernel; the display is updated in real-time and the highest load factors are expressed as a percentage of CPU or MEM. However, it is important to realize that top may take these values above the expected percentile range. This is because all individual cores are expressed as a percentage and multiple instances of these cores are totaled. For example, a dual core system may have the first core at 70 percent and the second core at 60 percent, and in this instance, top may show a combined result of 130 percent, but you will not know the individual values.

You can use the M key to sort top by memory, but as you will see, rather than simply showing the amount of free memory (as seen with the free command), top will provide the swap details...

Monitoring disk I/O with iotop

Every administrator knows that a system can begin to slow down as a result of heavy disk I/O activities. However, in the role of a troubleshooter you will probably want to know which processes or (in the case of multi-user systems) which users are the culprits that and it is for this reason, you will want to turn to iotop—a tool that shows a list of the most I/O intensive processes in real time in a top-like interface.

To begin with, you will need to install iotop by typing:

# yum install iotop

The download is only small, and to start a discovery session, simply use the following command:

# iotop

Running iotop without any arguments will result in a list of all existing processes regardless of their disk I/O activities, so if you want iotop to only report on processes that are committed to disk I/O activity, you should use the following instead:

# iotop –o

The output is verbose as it works in a way similar to the top command, so familiarity should...

Checking processes with the ps command

For most troubleshooters who want a more complete picture of the processes running on their system, we can employ the ps command in the following way:

# ps aux | less

Alternatively, the information can be displayed in a user-friendly, tree-view mode like this:

# ps axjf | less

If you prefer a little less detail, try:

# ps auxf | less

Of course, there are always a lot more options that we can use with ps. For example, the command can be piped and applied with grep or tail, and you can use explicit statements such as ps -e (to show every process on the system). Alternatively, you can target a specific process by typing the following command:

# ps aux | grep <process_name>

Moreover, you can even extend its usage to show every process (except those running as root) with the following variation:

# ps -U root -u root -N

For a specific user, you can use:

# ps -u <username> u

Finally, you can then obtain additional security information and output the...

Tuning server performance with memory management and swap


Regardless of how you look at it, the question of memory usage remains critical to the life cycle of a system, and whether you are maintaining system health or troubleshooting a particular service or application, you will always need to remember that the use of memory is a critical resource to your system. For this reason, we will begin by calling the free command in the following way:

# free -m

The main elements of the preceding command will look similar to this:

         Total    used    free    shared    buffers    cached
Mem:      1837     274    1563         8          0       108
-/+ buffers/cache: 164    1673
Swap:     2063       0    2063

In the example shown, I have used the -m option to ensure that the output is formatted in megabytes. This makes it easier to read, but for the sake of troubleshooting, rather than trying to understand every numeric value shown, let's reduce the scope of the original output to highlight the...

Managing memory with vmstat


A different aspect of memory management can be achieved by using the vmstat command. Considered to be a summary reporting feature associated with memory, processes, and paging, vmstat can be seen in action by typing:

# vmstat -a

Having used the -a option to call on all active and inactive memory, the most endearing columns shown under vmstat's output are best described as follows:

  • si: This column shows the value swapped in from disk

  • so: This column shows the value swapped out to disk

  • bi: This column shows the value sent to block devices

  • bo: This column shows the value received from block devices

  • us: This column shows the user time

  • sy: This column shows the system time

  • id: This column shows the idle time

The display does look quite confusing to begin with, but for our purposes, we want to concentrate on the following columns contained under the swap column:

free           si   so
1645452          0    0

Where free shows the current allocation of free memory, si shows page...

Checking the system load with the top command


The top command can be called at any time by typing:

# top

The top command is the standard command for checking system load (RAM/MEM and CPU). It contains a lot of information related to tasks associated with the kernel; the display is updated in real-time and the highest load factors are expressed as a percentage of CPU or MEM. However, it is important to realize that top may take these values above the expected percentile range. This is because all individual cores are expressed as a percentage and multiple instances of these cores are totaled. For example, a dual core system may have the first core at 70 percent and the second core at 60 percent, and in this instance, top may show a combined result of 130 percent, but you will not know the individual values.

You can use the M key to sort top by memory, but as you will see, rather than simply showing the amount of free memory (as seen with the free command), top will provide the swap details...

Monitoring disk I/O with iotop


Every administrator knows that a system can begin to slow down as a result of heavy disk I/O activities. However, in the role of a troubleshooter you will probably want to know which processes or (in the case of multi-user systems) which users are the culprits that and it is for this reason, you will want to turn to iotop—a tool that shows a list of the most I/O intensive processes in real time in a top-like interface.

To begin with, you will need to install iotop by typing:

# yum install iotop

The download is only small, and to start a discovery session, simply use the following command:

# iotop

Running iotop without any arguments will result in a list of all existing processes regardless of their disk I/O activities, so if you want iotop to only report on processes that are committed to disk I/O activity, you should use the following instead:

# iotop –o

The output is verbose as it works in a way similar to the top command, so familiarity should make you feel...

Checking processes with the ps command


For most troubleshooters who want a more complete picture of the processes running on their system, we can employ the ps command in the following way:

# ps aux | less

Alternatively, the information can be displayed in a user-friendly, tree-view mode like this:

# ps axjf | less

If you prefer a little less detail, try:

# ps auxf | less

Of course, there are always a lot more options that we can use with ps. For example, the command can be piped and applied with grep or tail, and you can use explicit statements such as ps -e (to show every process on the system). Alternatively, you can target a specific process by typing the following command:

# ps aux | grep <process_name>

Moreover, you can even extend its usage to show every process (except those running as root) with the following variation:

# ps -U root -u root -N

For a specific user, you can use:

# ps -u <username> u

Finally, you can then obtain additional security information and output...

Checking performance with iostat and lsof


Having already discovered how vmstat can be used to provide statistics related to memory management, when troubleshooting performance-related issues an overburdened CPU is yet another area of concern. For this purpose, we can use the iostat command like this:

# iostat

However, to display a more interactive CPU utilization report, you can use the –c option (and provide a numeric value measured in seconds, such as 5 seconds) like this:

# iostat –c 5

Most of the columns should be self-explanatory, but if the system is getting busy, you will see an increase in %iowait, which is used to report on an increase in waiting time for any I/O requests to be completed. Based on this, if the server is transferring or copying a large amount of files, you may also notice additional time being spent at the system level as files will be moved in and out of relevant disk partitions. A feature that is particularly useful when attempting to monitor storage devices in...

Calculating the system load


The system load is a measure of the amount of processing a computer system is currently performing. It is not the perfect way to measure computer performance, but it does provide the troubleshooter with the additional evidence they need to fix a system.

The expression most commonly associated with calculating load is:

Actual Load = Total Load (uptime) / Number of CPUs

As you probably know the number of CPUs, you can calculate the uptime by reviewing the results of the top command or by typing:

# uptime

The output of the preceding command may look like this:

09:59:41 up  2:36,  1 user,  load average: 0.01, 0.02, 0.05

The server load is expressed as a value based on 1 minute, 5 minute, and 15 minute read times. So, by looking at the final three values in the preceding output, we can see that, for this system, the average load was 0.01 (at 1 minute), 0.02 (at 5 minutes), and 0.05 (at 15 minutes).

At this current time, the example system shows no sign of fatigue, but...

Discovering process IDs with pgrep and systemctl


Rather than using ps, another way of discovering a specific process ID is to use the pgrep command like this:

# pgrep <servicename>

In most cases, the use of this command will reveal the process ID or PID. However, by using this approach, it is also possible that the output will provide more than one value. So remember, if an application (such as httpd or ssh) provides one or more process IDs, you can safely assume that the lowest number (which represents the first PID generated by the system) is the most important. This value is known as the PPID or parent process ID.

On the other hand, a more succinct method could be based on taking advantage of systemd by using the following command:

# systemctl status <service_name>.service

The output of the preceding command will look similar to the following sample, and as we can see, the main PID for Apache is 2413:

httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd...
Left arrow icon Right arrow icon

Description

It is assumed that you will already have a server up and running, you have a good working knowledge of CentOS, and you are comfortable with the concept of working with those services used by your server.

Who is this book for?

It is assumed that you will already have a server up and running, you have a good working knowledge of CentOS, and you are comfortable with the concept of working with those services used by your server.

What you will learn

  • Consider the need to understand, manipulate, and make use of the relevant system log files
  • Analyze, review, and make decisions regarding how and what to do with troublesome active processes on a CentOS server
  • Discover how to approach issues regarding the network environment
  • Approach issues regarding package management and learn how to make the necessary steps to diagnose and fix the problems found in relation to their YUM and RPMbased needs
  • Diagnose and troubleshoot issues related to Samba, NFS, and various external storage methods
  • Diagnose and troubleshoot issues related to iptables, SELinux, some common firewalls, shell access, and SSH

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 24, 2015
Length: 190 pages
Edition : 1st
Language : English
ISBN-13 : 9781785281778
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jun 24, 2015
Length: 190 pages
Edition : 1st
Language : English
ISBN-13 : 9781785281778
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 142.97
Mastering CentOS 7 Linux Server
$54.99
CentOS 7 Linux Server Cookbook, Second Edition
$54.99
Troubleshooting CentOS
$32.99
Total $ 142.97 Stars icon
Banner background image

Table of Contents

11 Chapters
1. Basics of Troubleshooting CentOS Chevron down icon Chevron up icon
2. Troubleshooting Active Processes Chevron down icon Chevron up icon
3. Troubleshooting the Network Environment Chevron down icon Chevron up icon
4. Troubleshooting Package Management and System Upgrades Chevron down icon Chevron up icon
5. Troubleshooting Users, Directories, and Files Chevron down icon Chevron up icon
6. Troubleshooting Shared Resources Chevron down icon Chevron up icon
7. Troubleshooting Security Issues Chevron down icon Chevron up icon
8. Troubleshooting Database Services Chevron down icon Chevron up icon
9. Troubleshooting Web Services Chevron down icon Chevron up icon
10. Troubleshooting DNS Services Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(3 Ratings)
5 star 33.3%
4 star 33.3%
3 star 33.3%
2 star 0%
1 star 0%
Amazon Customer Mar 12, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Awesome book!
Amazon Verified review Amazon
Ed P Jul 10, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Jonathan Hobson's book is a handy intro to troubleshooting a variety of issues that CentOS system admins may encounter. In addition he covers some basic information on installing and configuring some of the more popular Linux services, like MySQL/MariaDB, file shares and DNS services. While not exhaustive in any one area, it does provide a place to start when trying to resolve problems on the operating system.
Amazon Verified review Amazon
Human Jan 29, 2017
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
This book mainly seems to be composed of various basic Linux commands with a few examples. I have a few months experience supporting small web servers (mainly VPS's) with no prior server experience and I don't feel that I learned a lot from this, though it probably would have been an OK way to get started when I was first trying to learn if this wasn't covered in the training I got.I need much more detail than this for work.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.