![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2004
Posts: 3
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
Programmer
|
Redirecting the output of 'top' to another steam would be the solution. Something like
$ top > file
__________________
<span style='font-size:14pt;line-height:100%'><span style='color:red'>"Political power grows out of the barrel of a gun" - Mao Tse-Tung</span></span> |
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() ![]() |
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.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() |
top is the way to go man, it'll tell you everything you want to know.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Sep 2004
Posts: 3
Rep Power: 0
![]() |
Thanks, everyone. That was very helpful! Top was definitely the way to go.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|