![]() |
I need to write a shell script that gathers performance statistics such as CPU utilization, memory usage, pf usage, disk, etc. and format the results in an XML file. My problem is (besides being new to Linux/Unix) I don't know how to gather this information in a format suitable to re-format into XML. I know about the 'top' command, but wouldnt know how to programatically extract this information. Does anyone out there have any sample scripts that do something similar? Thanks in advance to anyone who points me in the right direction!
-Tony |
Redirecting the output of 'top' to another steam would be the solution. Something like
:
$ top > file |
That is the definitely the way I do similar scripts. Redirect the program's output to a file... within the same script, read that file back in using Sed or Awk, line by line... assigning values to variables where needed and output the XML formatted variables and values to another file, then deleting the temporary file.
|
top is the way to go man, it'll tell you everything you want to know.
|
Thanks, everyone. That was very helpful! Top was definitely the way to go.
|
| All times are GMT -5. The time now is 1:04 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC