Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am working on a way of monitoring if my machine´s preformance since I am afraid the cpu wont be sufficient for the work its supposed to do..
What I basically wanto do is make some form of script/program/crontab job that:
1) gets current CPU-load (total all users), mem-usage and swap-usage
2) opens a file, puts this at last line, saves the file..
Then i can show this very nicely on some webpage using php or the like.
So I pretty much need help with what commands to use or how, then throwing it in a file for easier handling.
Aha there you go, putting the info into a file seemed a bit easier then I expected, all that is left is the nifty command that gives me all the info I need.. the search continues
note: ive found that uptime seems to give 3 values after "load average", but havent had time to read more about this, could be the golden command if its cpu and mem-usage, then that could be enough for me
Thanks lugoteehalt !
Edit: seems uptime only gives you cpu-usage, no mem or swap stats.
Did you try "top"? Top shows a lot of info.
But with top you will need some special arguments in order to make it behave correctly. Top won't exit until you tell him to exit. So, you have to issue the number of iterations top will perform.
Try:
top -n 1 >> topinfo.txt
Using two > chars, the command will append the new text into the file, whitout erasing the current content. Using only one, top will erase all prior content and paste new, each time you run the script. (like this: top -n 1 > topinfo.txt)
Hope it helps!
Last edited by bruno buys; 04-30-2004 at 12:36 PM.
I think top takes a bit to much out of the cpu, if I "run" it, without the -n 1, it takes about 0.1-20% cpu, I dont want something going off every 5th minute causing any form of preformance-decrease...
Maybe if I can get it to show without the actual PID-info and just the interesting info at the "top" () it will be very nice, from that I can just extract anything I want/need since its all there!
The following command produces top suitable for a text file and pulls off the top five lines:
top -b n 1|egrep 'average|zombie|nice|shrd|Swap'
There is a ??bug in my version of top so that the cpu usuage line's while usefull doesn't really make sence. Subsequent itterations, n 2, are allright.
If you have sysstat installed you could use sar
blink@insanity ~--> sar -u 10 5
Linux 2.4.20-30.9 (insanity) 05/14/2004
09:33:39 AM CPU %user %nice %system %idle
09:33:49 AM all 9.70 0.10 1.20 89.00
09:33:59 AM all 7.40 0.10 0.50 92.00
09:34:09 AM all 8.30 0.40 1.20 90.10
09:34:19 AM all 6.60 0.20 0.70 92.50
09:34:29 AM all 18.50 0.00 0.90 80.60
Average: all 10.10 0.16 0.90 88.84
blink@insanity ~-->
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.