how to find out cpu and disk usage in linux

how to find out cpu and disk usage in linux

When you are running any script on server or running any application you want to know how much memory or disk uses is happened by application.

how to find out cpu and disk usage in linux

how to find out cpu and disk usage in linux
how to find out cpu and disk usage in linux

When you are doing load testing this time this kind of applications are very useful to check the server status. Create file name CPU-Disk.sh and put following content in that.

01#!/bin/sh
02 
03# Change this as needed
04 
05OUTPUT_FILE=file.txt
06 
07# Initially delete old output file if needed.
08 
09/bin/rm -f $OUTPUT_FILE
10 
11while [ 1 -eq 1 ]; do
12 
13date >> $OUTPUT_FILE
14 
15echo "------------------------" >> $OUTPUT_FILE
16 
17cat /proc/meminfo >> $OUTPUT_FILE
18 
19echo "------------------------" >> $OUTPUT_FILE
20 
21df -k >> $OUTPUT_FILE
22 
23echo "------------------------" >> $OUTPUT_FILE
24 
25top -b -i -n 1 >> $OUTPUT_FILE
26 
27# Record terminator. Add more === if needed :)
28 
29echo "========================" >> $OUTPUT_FILE
30 
31sleep 60
32 
33done

This command is useful to create the sh file executable in linux

#chmod +x /YOURPATH/CPU-Disk.sh

when you need to check the server status you need to run the this file using this command

#CPU-Disk

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.