OS Fundamentals
beginnerlinuxbashsystem-monitoring
Build a comprehensive system monitoring script to deepen OS knowledge
← Back to BeginnerLearning Objectives
- Understand core operating system components and their functions
- Learn to retrieve and interpret system information programmatically
- Develop skills in resource monitoring and analysis
- Implement process management techniques
- Create useful system reports for troubleshooting
Requirements
You are required to create a Bash script os-info.sh that gathers and displays detailed operating system information:
- System Identification
- OS distribution and version (
/etc/os-release) - Kernel version (
uname -r) - System architecture (
uname -m) - Hostname and network identity (
hostname,hostname -f)
- OS distribution and version (
- Runtime Statistics
- System uptime and load averages (
uptime) - Current date and time (
date) - Logged-in users (
who) - Last login information (
last | head -5)
- System uptime and load averages (
- Process Information
- Total running processes (
ps aux | wc -l) - Top 5 CPU-consuming processes (
ps aux --sort=-%cpu | head -6) - Top 5 memory-consuming processes (
ps aux --sort=-%mem | head -6) - Process tree of a specific service (
pstree -p $(pidof sshd))
- Total running processes (
- Memory Usage
- Total and available memory (
free -h) - Swap usage (
swapon --show) - Key stats from
/proc/meminfo
- Total and available memory (
- Storage Information
- Disk usage by filesystem (
df -h) - Disk usage by directory (
du -sh /var /home /opt) - Inode usage (
df -i)
- Disk usage by filesystem (
- Report Formatting
- Clear section headers
- Timestamp of report generation
- Both detailed and summary views
Stretch Goals
- Add resource usage trends over time using a cron job
- Add CPU temperature monitoring (if available)
- Implement color-coded output based on usage thresholds
- Include network interface statistics
Deliverables
os-info.shscript implementing all required sections- Example output from a real execution
- Documentation explaining what each metric means and how to interpret it
References
- Linux Procfs Documentation
- Understanding Linux Load Averages
- Linux Performance Analysis in 60s - Netflix
- Guide to /proc filesystem
- Linux Memory: linuxatemyram.com
Once you complete this task you will know how to programmatically retrieve system information for monitoring and debugging - essential knowledge for operating any server in a DevOps environment.
Submit Your Solution
Completed this project? Share your solution with the community!
- Push your code to a GitHub repository
- Open an issue on our GitHub repo with your solution link
- Share on X with the hashtag #DevOpsDiary
