473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

how to find the cpu utilisation ratio in linux

how to find the cpu utilisation ratio in linux and unix
Jun 28 '07 #1
2 2228
alcazar
10
Check out the /proc directory.This directory mostly consists of these system related info.There is one file called /proc/cpuinfo which gives physical parameters CPU info ,but thats not what you are looking for.

I am trying to find the answer to your question.

how to find the cpu utilisation ratio in linux and unix
Jun 28 '07 #2
prn
254 Expert 100+
The command "w" (/bin/w in Solaris, /usr/bin/w in Linux -- at least Fedora) will give you that information.

The first line of the output should look like:
08:58:53 up 75 days, 18:04, 3 users, load average: 0.03, 0.07, 0.02
or
8:55am up 38 day(s), 1 user, load average: 1.28, 1.37, 1.29

Depending on what you plan to do with it, you may need to parse out specific information. For example, I run the following script every half hour on one of the Solaris boxes I am responsible for:
Expand|Select|Wrap|Line Numbers
  1. #! /bin/perl
  2. use strict;
  3.  
  4. open IN, "/bin/w |" or die "could not run w to get load average: $!\n";
  5. my $line  = <IN>;
  6. close IN;
  7. chomp $line;
  8.  
  9. my ($junk,$avgs) = split /load average: /,$line;
  10. my ($min,$fivemin,$fifteenmin) = split /, /, $avgs;
  11. print scalar localtime(), "\t$min\t$fivemin\t$fifteenmin\n";
(My crontab includes a redirection to append the data to a file.)

HTH,
Paul
Jun 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: jong | last post by:
I have a problem with an C# application. The application is a 24x7 low volume message processing server. The server has a single thread of processing, running in a continuous loop, for each...
10
by: jong | last post by:
I have a problem with an C# application. The application is a 24x7 low volume message processing server. The server has a single thread of processing, running in a continuous loop, for each...
0
by: jong | last post by:
I have a problem with an C# application. The application is a 24x7 low volume message processing server. The server has a single thread of processing, running in a continuous loop, for each...
0
by: chrisguest | last post by:
I am looking into a replication strategies to improve performance and redundancy for a MySQL 4.1 database running on Linux/Apache2/mod_python. I am curious as to the standard way of obtaining a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.