Linux Command to Check Cpu Usage




How to Monitor CPU usage on Droplets DigitalOcean-amount of memory, cache size, speed of reading from and writing to the disk, the speed and processing power availability is a key element affecting the performance of Your server infrastructure. In this article, we will focus on the concept of CPU monitoring introduction and warning strategies. We will explain how to use two common Linux utility, uptime and top, to learn about load and CPU utilization, and how to organize DigitalOcean Alert Policies to notify you about significant changes that related to CPU Droplets.

Before we delve into the details of uptime, top and monitoring DigitalOcean, we will consider how the measured CPU usage and the type of the desired pattern.

CPU Load vs CPU Utilization
CPU Load and CPU Utilization are two different ways to look at the use of computer processing power.

For conceptualizing the main difference between the two, we can imagine the processor as the cashier at the grocery store and as a customer. CPU load is like having one line checkout where customers wait for the next available teller. The load is essentially the sum of the number of people there, including in the cash register. Increasingly long lines, the longer the wait. Instead, the CPU usage is only related to how busy the cashier and did not know how many customers are waiting in line.



More specifically, the task queue up to use the CPU of the server. When someone arrives at the top of the queue, scheduled to receive a certain amount of processing time. If complete, then exit; If not go back to the end of the queue. In both cases, the task of the next in line.

CPU load is the length of the queue, including a scheduled task that is being processed. The task can be switched in a matter of milliseconds, so a snippet from the load average is not as easy a few readings taken during a specific time period, so the value of the load is often given as the average load.

CPU load tells us about how much demand there is for CPU time. High demand can lead the debate for CPU time and performance is degraded.

CPU utilization, on the other hand, tells us how busy the CPU, without an awareness of how many processes are waiting. Monitoring of utilization can indicate trends over time, highlighting the surge, and helping identify unwanted activity,

The non-Normalized vs. Normalized Values
On a single processor system, the total capacity is always 1. On multiprocessor systems, the data can be displayed in two different ways. The combined capacity of all processors are counted 100% regardless of the number of processors, and is known as the normalized. Another option is to enumerate every processor as a single unit, so that the system processor is used 2 full capacity of 200%, the system 4 processors that are used are at full capacity of 400%, and so on.

To interpret correctly the number of CPU load or use, we need to know how many processors owned server.

Display CPU Information
We can use the nproc command with-the-all option to display the number of processors. Without the commandments-all, will display the number of processing units that are available to the current process, which will be less than the total number of processors if one is used.
nproc --all

On most modern Linux distributions, we can also use the "lscpu" command, which not only displays the number of the processor but also architecture, model name, speed, and more:
lscpu

What is the Optimal Value for Load and utilization?
Optimized CPU usage varies depending on the type of work the expected server. High CPU usage continues comes with a price of less responsive interactivity with the system. It is often appropriate for the application and the batch application intuitive consistently to run at or near full capacity. However, if the system is expected to present a web page or to deliver a responsive interactive sessions to services such as SSH, it may take some idle processing power available.

Like many aspects of performance, learn about the specific needs of the service on the system and monitoring of unexpected change is key to optimizing resources.

CPU Monitoring
There are many tools that can give insight into the status of CPU system. We will see two commands, uptime and top. Both are part of the default installation of the most popular Linux distribution and is typically used on demand to investigate the load and CPU utilization. In the following example, we will examine our core 2 Droplets record above.

Uptime
We'll start with the uptime command to see the CPU load while only displays the average CPU load basis, can help when the system is responding slowly due to interactive questions require less system resources.

The show uptime:
  1. Time the system at the time the command is executed
  2. How long the server has been running
  3. How many connections should be owned by the user of the machine
  4. The average CPU load over the past one, five, and fifteen minutes.
uptime

TOP
Such as uptime, top is available on Linux and Unix systems, but in addition to showing the average burden for historical intervals predetermined, it provides information on CPU usage with real-time and other related performance metrics. As for uptime goes in and out, the upper part remains in the foreground and refresh periodically.

Monitoring CPU Utilization to DigitalOcean
By default, all Droplets showing graphs of Bandwidth, CPU, and Disk I/O when you click the name of the Droplets in the Control Panel:

That graph visualises the use of respective resources for 6 hours, 24 hours, 7 days and 24 hours. The CPU graph provides information on CPU usage. The dark blue line shows the CPU usage by user processes. Light blue indicates the CPU usage by process systems. The value on the graph is normalized so that the details and the total capacity 100% regardless of the amount of the virtual cores.

The chart allows you to see if you experience intermittent or continuous use of changes and very helpful in seeing the changes on the server CPU usage patterns.

In addition to this default graph, you can install the Agent on the DigitalOcean Droplets to collect and display additional data. The agent also allows you to set the alert notification Policy for the system.

After the agent is installed, you can specify policy alerts to inform you about the use of resources. The threshold you select will depend on the workload.

An Example Of An Alert
Monitoring change: CPU in the top 1%
If you use the Droplets especially to integrate and soak testing code, you may set the warning that is only slightly above the historical patterns so as to detect whether the new code is pushed to the server has increased CPU usage. For the graphic above which CPU never reach 1%, 1% CPU usage threshold for 5 minutes can give early warning about changes that affect the use of code-based CPU.

On most systems, there is most likely a threshold this actually unsuitable, but by adjusting the duration and set the threshold slightly above the average load current, you can learn early on when the new code or a new service affects CPU utilization.

Monitoring of emergency situations: CPU utilization above 90%
You may also want to set a threshold far above average, which do you think is important and will require immediate investigation. For example, if the server that is experiencing continuous CPU usage of 50% during the five-minute interval quite regularly suddenly surged up to 90%, you might want to sign in immediately to investigate the situation. Once again, the specific thresholds for workload system.


Next
Previous
Click here for Comments

0 comments: