Automating System Monitoring: Check Free Memory with a Simple Script
Er Virendra Giri
DevOps Engineer | Automating Continuous Delivery, Infrastructure, and Collaboration| AWS | Docker | Kubernetes | Jenkins | Python | Linux| CloudWatch
As a developer, systems administrator, or DevOps engineer, keeping an eye on system performance is crucial for maintaining smooth operations. One essential metric is memory usage, as excessive memory consumption can lead to performance degradation or even crashes.
Here’s a simple script in Bash that allows you to check the free memory on your system. Whether you're troubleshooting or simply monitoring resources, this can be a quick and easy way to keep tabs on your machine's health.
Bash Script to Check Free Memory
# memUsed= 'free -m | head -2 | tail -1 | awk ' { print $3 } ' '
#totalMem= 'free -m | head -2 | tail -1 | awk ' { print $2 } ' '
#memUsedPercentage=' expr $memUsed \* 100 / $totalmem '
How It Works:
Why This Is Useful:
By incorporating simple scripts like these into your monitoring processes, you can save valuable time and keep your systems running efficiently.
Feel free to modify and integrate this script into your workflow!