Show System Statistics from /proc Filesystem Using procinfo


Are you a Linux user or system administrator looking for a quick and easy way to access system statistics on your machine? Look no further than the procinfo command, a dominant advantage that allows you to access key information about your system's performance from the /proc filesystem.

With procinfo, you can quickly and easily monitor important metrics like CPU usage, memory usage, and process information, all from the comfort of your terminal. Whether you're trying to diagnose a performance issue or simply want to keep tabs on your system's health, procinfo is an essential tool for any Linux user or administrator.

In this article, we'll take a closer look at how to use procinfo to access and view system statistics from the /proc filesystem. We'll cover everything from basic usage to some of the most important metrics that procinfo provides, so you can start monitoring your system like a pro in no time.

Installation Method

You can install ‘procinfo’ using the package manager specific to your distribution. Here are some examples −

1. Ubuntu/Debian

To install procinfo on Ubuntu or Debian-based systems, open a terminal and run the following command 

sudo apt-get install procinfo

2. CentOS/RHEL

On CentOS or RHEL-based systems, use the following command −

sudo yum install procinfo-ng

3. Fedora

For Fedora-based systems, use the following command −

sudo dnf install procinfo-ng

4. Arch Linux

On Arch Linux, use the following command −

sudo pacman -S procinfo-ng

5. Gentoo

For Gentoo-based systems, use the following command −

sudo emerge procinfo-ng

After installing procinfo, you can run it from the terminal by typing procinfo. If it's not in your system path, you may need to specify the full path to the executable, which is typically /usr/bin/procinfo.

As you run the command procinfo, it’ll give output similar to this −

System Status:   Linux mycomputer 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64
Kernel Version:  #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64
Memory:           Total   Used    Free   Shared  Buffers Cached
                  Mem:    327948  247776  80172   21236   66772   96880
                  Swap:   0       0       0
Bootup:           Fri Jun 12 16:16:03 2020   Load average:      0.18 0.15 0.10 2/146 3413
User:             1 user    System:  0.60 seconds   Uptime:          0 days 01h 18m 55s
Processes:        146 running, 395 total,  1 zombie, 0 dead, 0 orphaned
CPU:              0.0% user,  0.0% nice,  0.0% system,  0.0% idle,  100% IO-wait
CPU0:             0.0% user,  0.0% nice,  0.0% system,  0.0% idle,  100% IO-wait
CPU1:             0.0% user,  0.0% nice,  0.0% system,  0.0% idle,  100% IO-wait
CPU2:             0.0% user,  0.0% nice,  0.0% system,  0.0% idle,  100% IO-wait
CPU3:             0.0% user,  0.0% nice,  0.0% system,  0.0% idle,  100% IO-wait
CPU4:             0.0% user,  0.0% nice,  0.0% system,  0.0% idle,  100% IO-wait
CPU5:             0.0% user,  0.0% nice,  0.0% system,  0.0% idle,  100% IO-wait
CPU6:             0.0% user,  0.0% nice,  0.0% system,  0.0% idle,  100% IO-wait
CPU7:             0.0% user,  0.0% nice,  0.0% system,  0.0% idle,  100% IO-wait

Displaying Memory Usage

In Linux, obtaining information about memory usage is an important for both users and administrators to monitor and optimize the use of memory resources. This crucial system statistic can be obtained from the /proc/meminfo file, which provides details about the current memory usage of the system, including the total amount of memory, available free memory, and memory used by running processes.

To display memory usage information using the procinfo command, simply run the command with the -m option. In the output you’ll get below information 

  • Memory Total  The total amount of memory available on the system.

  • Memory Used  The amount of memory currently in use by the system.

  • Memory Free  The amount of memory currently available for use by the system.

  • Shared Memory  The amount of memory being used by shared memory objects.

  • Buffers  The amount of memory being used by buffer caches.

  • Cached Memory  The amount of memory being used by page cache and slab cache.

For example, the output of the procinfo command with the -m option may look like this −

Memory:  Total   Used    Free   Shared  Buffers Cached
          Mem:   7948   7191     757      416     3077   2399
          Swap:  8191   1287    6904

In this example, we can see that the total amount of memory available on the system is 7948 MB, with 7191 MB currently in use and 757 MB available for use. We can also see that there is 416 MB being used by shared memory objects, 3077 MB being used by buffer caches, and 2399 MB being used by page cache and slab cache.

Displaying CPU Usage

The proc filesystem is also a great source of information on CPU usage, with the /proc/stat file containing data on the system's CPU utilization, such as the duration spent in user mode, system mode, and idle mode. To present this information in a more user-friendly format, the procinfo command comes in handy and useful.

To display CPU usage information, simply run the procinfo command with the -c option, like so −

$ procinfo -c

Here is an example of the output −

CPU Usage:  user  nice   sys   idle   irq
           2.4   0.0    1.0   95.1   1.4

The generated result demonstrates the proportion of time that the CPU is dedicated to user mode, system mode, and idle mode. User mode duration indicates the time that the CPU spends executing user-space processes, whereas system mode duration indicates the time that the CPU spends executing kernel code.

Displaying Process Information

Detailed information about the running processes on a Linux system can be obtained from the proc filesystem. The /proc/[pid]/stat file is a specific file within this filesystem that contains valuable information about a particular process, such as its process ID, parent process ID, CPU usage, and memory usage. By using the procinfo command, this information can be displayed in a user-friendly format.

To display process information, simply run the procinfo command with the -p option, followed by the process ID, like so −

$ procinfo -p 1234

Here is an example of the output −

Process Information:
 PID     PPID    CPU%    MEM%   VSZ    RSS    TTY  STAT  START  TIME    COMMAND
 1234    1       2.4     0.2    12856  8464   ?     S     17:50  0:05    firefox

The displayed output provides comprehensive details about the designated process, consisting of its process ID, parent process ID, CPU utilization, and memory usage. Additionally, the output presents the virtual memory size (VSZ) and resident set size (RSS) of the process, which are crucial indicators of the process's memory consumption.

Conclusion

To sum up, utilizing the proc filesystem with the procinfo command is an excellent way to gather important system statistics in a Linux operating system. With procinfo, system administrators can easily access and display essential information such as memory usage, CPU usage, and process details.

Through the utilization of the proc filesystem, administrators can gain valuable insights into the performance of their Linux systems and detect any potential issues. With this information, they can optimize the system's performance and resolve any problems that may arise.

Overall, procinfo is a must-have tool for any Linux administrator. Its ability to provide clear and concise system statistics in a user-friendly format makes it an invaluable asset in managing and maintaining Linux systems.

Updated on: 28-Jul-2023

46 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements