Loading...

Lab 111: Proc CPU & Memory Exploration

Extract CPU and memory facts directly from /proc and validate them with standard tooling. Cross-check raw kernel state with lscpu and free -h so your findings are usable in tickets and capacity discussions.

troubleshooting performance core

Scenario

A teammate claims a host is under-provisioned and insists it has fewer CPU threads and less memory than expected. You need to validate the facts from the kernel’s source of truth and confirm them using standard utilities that other admins will recognize.

Operator context

Use /proc to verify claims quickly, then cross-check with higher-level tooling so your results are portable across teams, tickets, and incident notes.

Objective

  • Extract the CPU model name from /proc/cpuinfo.
  • Determine logical CPU count from /proc/cpuinfo.
  • Cross-check CPU facts with lscpu.
  • Read MemTotal and MemAvailable from /proc/meminfo.
  • Cross-check memory results using free -h.
  • Inspect hugepage configuration when present.

Concepts

  • /proc as the raw interface to live kernel state (CPU and memory).
  • Logical CPUs versus cores and sockets, and how that maps to lscpu output.
  • Memory reporting: MemTotal versus MemAvailable and why “available” is not “free.”
  • Cross-check methodology: confirm raw data, then present it using team-standard utilities.
  • Hugepages visibility for performance and virtualization contexts (/proc/meminfo).

Walkthrough

Step 1 : Print the CPU model name from /proc/cpuinfo.
Command
grep -m1 '^model name' /proc/cpuinfo

/proc/cpuinfo exposes CPU details reported by the kernel. The model name repeats for each logical processor, so pulling the first match is usually sufficient.

# Expected output format:
model name  : Intel(R) ...
Step 2 : Count logical processors from /proc/cpuinfo.
Command
grep -c '^processor' /proc/cpuinfo

Each processor line corresponds to one logical CPU as seen by the kernel. This count should match CPU(s) reported by lscpu .

# Example:
8
Step 3 : Cross-check CPU facts with lscpu.
Command
lscpu

lscpu summarizes CPU topology (threads per core, cores per socket, sockets). Use it to translate raw kernel data into the vocabulary your team expects in tickets and capacity notes.

# Key fields to compare:
CPU(s):                  8
Thread(s) per core:      2
Core(s) per socket:      4
Model name:              Intel(R) ...
Step 4 : Read memory totals from /proc/meminfo.
Command
grep -E '^(MemTotal|MemAvailable)' /proc/meminfo

MemTotal is total physical RAM detected by the kernel. MemAvailable is a best-effort estimate of memory available for new workloads without swapping, accounting for reclaimable cache.

# Example:
MemTotal:       ... kB
MemAvailable:   ... kB
Step 5 : Cross-check memory with free -h.
Command
free -h

free presents memory in a format most admins expect. Compare the total and available values to confirm they align with what you extracted from /proc/meminfo .

# Focus on:
total
available
Step 6 : Inspect hugepage settings when present.
Command
grep -E '^Huge' /proc/meminfo

Hugepages are common in performance and virtualization environments. Even when disabled, this confirms current hugepage size and whether any hugepages are reserved.

# Example:
HugePages_Total:       0
HugePages_Free:        0
Hugepagesize:       2048 kB

Common breakpoints

Values don’t match between /proc and tools

Confirm you are reading the correct fields and comparing the right units. /proc/meminfo reports values in kB, while free -h scales units for display.

CPU count confusion: cores vs threads

grep -c '^processor' reports logical CPUs. Cross-check with lscpu and report topology using threads per core, cores per socket, and sockets.

MemAvailable seems “too high” or “too low”

MemAvailable is an estimate that accounts for reclaimable cache and memory pressure. Use it as a capacity signal, not a strict “free RAM” number.

Hugepages fields missing or unexpected

Some environments expose different hugepage fields or defaults. If hugepages matter for the workload, confirm configuration via /proc/meminfo and align with the platform’s provisioning requirements.

Cleanup checklist

This lab is read-only. Your cleanup is capturing the verified CPU and memory facts for your ticket or incident notes.

Commands
grep -m1 '^model name' /proc/cpuinfo
grep -c '^processor' /proc/cpuinfo
lscpu
grep -E '^(MemTotal|MemAvailable)' /proc/meminfo
free -h
grep -E '^Huge' /proc/meminfo
Success signal

Your /proc extraction matches the summary values from lscpu and free -h, and you can report CPU and memory in a consistent format.

Reference

  • grep -m1 '^model name' /proc/cpuinfo : Prints the first CPU model name entry from kernel-exposed CPU information.
    • -m1 : Stops after the first match.
    • /proc/cpuinfo : Kernel-exposed CPU information (per-logical CPU details).
  • grep -c '^processor' /proc/cpuinfo : Counts logical CPUs as seen by the kernel.
    • -c : Prints the number of matching lines.
  • lscpu : Displays CPU architecture and topology (threads, cores, sockets, model name).
  • grep -E '^(MemTotal|MemAvailable)' /proc/meminfo : Extracts memory totals and available memory estimates from kernel accounting.
    • -E : Enables extended regular expressions.
    • /proc/meminfo : Kernel-exposed memory accounting (totals, available, caches, hugepages).
  • free -h : Shows memory summary in human-readable units.
    • -h : Scales units automatically.
  • grep -E '^Huge' /proc/meminfo : Shows hugepage-related fields when present.
    • ^Huge : Matches hugepage keys such as HugePages_Total and Hugepagesize .