How to calculate the average of cpu usage and memory usage over a period of time in ubuntu
You can use
cat /proc/loadavg
That gives you the 3 load average numbers for the period 1, 5, and 15 minutes.
Then the number of currently running processes and then the pid of the last called process.
I don't know what you mean with the median and deviation values.
But hopefully this is a start for you.
cat /proc/meminfo
gives you memory stats.
The /proc directory could give you more infos for your needs. Just cat /proc/xxxx the file you are interested in.
cat
is just a programm to show the contents of a file to your termial. Jo can use your javaprogramm or whatever to read those files and send the values to your database.
Related videos on Youtube
Comments
-
Akari over 1 year
I have to generate reports for the following :
1- cpu usage. 2- memory usage.
The generated reports must be looks like the following forms :
I've tried with more than one command to get system readings ... such as htop, atop and
dstat -ta --top-cpu
The result for htop was :
The result for atop was:
The result for dstat was :
which is the correct command should I use to gather the correct system readings in which I can calculate the average value,min value,max value,median value and deviation for the cpu usage,memory usage,open files count and open ports count as in the first and second picture ?
If any one can help me to decide the appropriate command ...I hope if he can also tell me what the important numbers from the resulting system readings should I take to calculate the columns in the first two pictures ?
The data must be stored in a database that consists of a specific tables while the reports can be generated with the help of a java application which is responsible to deal with the database and use the retrieved data to make calculations and generate reports ... now I'm trying to make the database model so I need to know the necessary columns in the tables so I need your help to start the actual work for me which is the java application ... just I want to know what data should I take in my consideration !
-
Akari about 10 yearswhat the 3 avg values refers to ?? thanks for ur help :))
-
Evenbit GmbH about 10 yearsI have edited the answer to make it clearer.