Solved

How to measure CPU/Memory usage?

Posted on 2008-10-07
9
2,495 Views
Last Modified: 2013-12-26
Hi,

I'm working on a project that one of its tasks is to measure the average memory and cpu usage for the passed X minutes. The plan is to cover tier 1 Unix/Linux OS,

I'm a programmer and not very familiar with the different technical aspects of cpu and memory but I do know that these is no single number that represents them.
I found out in Unix the command "vmstat" that gives information about memory, cpu, page fault and other system parameters but I'm not sure this is the right tool. I mean, there is user cpu usage and system cpu usage. How do you figure out a single number that represents the overall cpu usage? The same goes for memory, there is phisical memory, and virtual memory and some other memory related parameters.
And what happen if you have 16 cpus? Can you boil it down to a single number?

The design is that a user will define a minimum free cpu usage and a minimum available memory, and if these conditions are met, only then other tasks will be performed. This is to prevent a situation in which a task is submitted to a machine that is already overloaded.

How would you approach such a task?
Do you know of any 3rd parties softwares or utilities that yield such information?

Thanks.
0
Comment
Question by:nivo_Z
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
Use top command for real time monitoring ... top -b gives you periodic snapshots ... man top for more info
Also look into time command to time the execution of your program ... and of course there are profilers for memory and CPU e.g. memprof, valgind, gprof etc.
0
 

Author Comment

by:nivo_Z
Comment Utility
Thanks fpr your reply.
Top is not necessarily installed, the solution should be generic and sould use tools that exist by default.
0
 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
what all tools are available?
0
 
LVL 4

Accepted Solution

by:
tjilp earned 55 total points
Comment Utility
How about something simple like "ps".
ps has an option  that allows you to format it's output.
online man page example : http://www.netadmintools.com/html/1ps.man.html
or better try : man ps

for instance "ps -eo pid,pcpu,comm,args" gives you the pid , the processor usage, process name and it´s arguments

Cheers
Tjilp
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 61

Expert Comment

by:gheist
Comment Utility
SNMP agent is existent on all platforms. read host mib.
0
 

Assisted Solution

by:deloptes
deloptes earned 80 total points
Comment Utility
how to mesure the memory usage of a perl script?

this can not be caught with top, ps and /usr/bin/time -v prints everywhere a 0.

time prints
real    0m0.608s
user    0m0.523s
sys     0m0.033s

/usr/bin/time -v
        Command being timed: "perl app.pl"
        User time (seconds): 0.51
        System time (seconds): 0.03
        Percent of CPU this job got: 81%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.66
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 0
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 3764
        Voluntary context switches: 147
        Involuntary context switches: 180
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0


thanks
0
 
LVL 61

Assisted Solution

by:gheist
gheist earned 40 total points
Comment Utility
You should use process accounting. most likely psacct package contains sa, sar and accton tools and google will show you enough guidance for your purpose.
0
 

Assisted Solution

by:deloptes
deloptes earned 80 total points
Comment Utility
Hello, thank zou for the answer. I was googleing for about an hour but couldnät find anzthing usable, also non of the mentioned programs has ever appeared upto page #5 in google :-) so I sould try something you've mentioned google about it and read the man page

thanks and regards
0
 
LVL 61

Expert Comment

by:gheist
Comment Utility
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 125
Perl Awk Need Help 3 94
lucky13 challenge 11 111
Problem to event 3 48
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now