Skip to content

A Linux-based C program that analyzes open file descriptors using /proc and displays customizable FD tables, with options to export data and compare output formats.

Notifications You must be signed in to change notification settings

7AbdUrRehman7/Linux-System-Wide-FD-Table-Monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Linux System-Wide File Descriptor (FD) Table Monitor

πŸ“Œ Overview

This C-based Linux utility explores how the operating system tracks open files. It extracts and displays various views of file descriptor data using the /proc virtual filesystem. Users can generate per-process, system-wide, vnode-based, and composite FD tables, save them to text or binary files, and evaluate performance based on output format.

πŸ‘€ Author

Abd-Ur-Rehman

🎯 Features

  • View per-process FD tables
  • Generate system-wide FD tables with filenames
  • Display vnode-based tables using inode numbers
  • Combine all views into a composite table
  • Show summary of FD counts per process
  • Highlight processes exceeding the FD threshold
  • Save the composite table to:
    • Plain text file
    • Binary file with custom serialization
  • Performance comparison between output formats

🧠 Approach

  • Command-line interface to select views and output options
  • Reads from /proc/[pid]/fd to extract FD metadata
  • Uses:
    • readlink() for filename resolution
    • stat() for inode retrieval
    • opendir() and readdir() for directory traversal
  • Modular function design for each table and file type
  • Composite view combines PID, FD, filename, and inode data
  • Output can be redirected to the screen, a text file, or a binary file

πŸ› οΈ Compilation Instructions

Run on a Linux system using:

gcc -Wall -Wextra -std=c99 -Werror -g -o FD_tables FD_tables.c

🚩 Supported Command-Line Arguments

πŸ”Ή Flagged Arguments

  • --per-process: Show only the process FD table.
  • --systemWide: Show only the system-wide FD table.
  • --Vnodes: Show only the Vnodes FD table.
  • --composite: Show only the composed FD table.
  • --summary: Show a summary of the number of FDs open per process.
  • --threshold=X: Show only processes with more than X FDs open.

πŸ“‹ Command-Line Usage Examples

Command Description
./FD_tables Displays the composite table by default
./FD_tables 1234 --per-process Shows FD table for PID 1234
./FD_tables --systemWide Displays system-wide FD table
./FD_tables --threshold=2 Lists processes with >2 FDs
./FD_tables --output_TXT Saves composite table to compositeTable.txt
./FD_tables 1234 --output_binary Saves PID 1234’s composite table to compositeTable.bin

πŸ§ͺ Testing

Tested various combinations of command-line arguments, including:

  • Valid/invalid PIDS
  • All flags together
  • File-saving with invalid file paths
  • Thresholds <= 0 and > 0

πŸ“Š Performance Evaluation (Bonus)

Case Avg Time (s) Text Size (bytes) Binary Size (bytes)
All Processes 0.023 11262 9238
Single PID 0.0166 2122.8 1595.8

Observations

  • Binary output saves more space than text
  • Processing time is dependent on data size, not output format
  • Output is consistent and reliable

⚠️ Disclaimers

  • Table formats follow Prof. Marcelo’s demo specifications
  • Tables for specific PIDS exclude row indices
  • Composite and threshold tables maintain consistent output order
  • #define _GNU_SOURCE is used to access DT_LNK and DT_DIR

πŸ“š References

About

A Linux-based C program that analyzes open file descriptors using /proc and displays customizable FD tables, with options to export data and compare output formats.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages