Piping output of "top" to a text file

 
Thread Tools Search this Thread
Operating Systems Linux Fedora Piping output of "top" to a text file
# 1  
Old 09-20-2006
Piping output of "top" to a texf file

I would like to pipe "top -n" to a text file, but I get an error:

top: cannot open /dev/kmem
kvm_open: Permission denied

I am a non-root user.

If I could find a way to get this type of output:
"Memory: 2048M real, 1516M free, 4099M swap free"
into a text file, I could further automate my daily system healthchecks.

Any ideas would be appreciated. Thanks so much.
# 2  
Old 09-20-2006
See this post and check your man page for top.
# 3  
Old 09-20-2006
Thanks, RTM, for your quick reply. I did search the forum before posting, but did not find the post you reference. I did also try man and google and the Sun site, but could not find the help I needed. (Just so you know, I am not a lazy newbie, just a clueless one!)

I do not have man pages for top on any of my five Solaris servers. This is probably because I rigged top to run by myself, as I couldn't get a unix admin who had time to do it. I copied an executable from somewhere else & got it to run. But I did not so an actual install.

These are the options I have for top on my machines:
Top version 3.5beta8
Usage: top-3.5b8-sun4u-5.9-64bit [-ISbinqu] [-d x] [-s x] [-o field] [-U username] [number]

I tried the "-f" option, even though it is not listed, but no success.

Any other ideas you have for me will be appreciated. Thanks so much.
# 4  
Old 09-20-2006
How about:

Code:
$ swap -s
total: 52056k bytes allocated + 28144k reserved = 80200k used, 1321528k available

Carl
# 5  
Old 09-20-2006
You could also try this:

Code:
$ vmstat 1 2 | tail -1
 0 0 0 1322760 331512 0   7  0  0  0  0  0  0  0  0  0  324  112  154  1  0 99

Position 4 ad 5 are swap and free.

Carl
# 6  
Old 09-20-2006
Carl,

Thanks so much for your replies.

These will only give me virtual memory, is that correct? Are there similar commands for physical memory usage? I have used vmstat before, but swap is new to me; I'm glad to learn of it.

I am a little embarrassed to be asking such elementary questions. Thanks again.

Shirley
# 7  
Old 09-20-2006
Code:
prtconf -v | grep -i mem

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Homework & Coursework Questions

Need help creating shell script with output that has 2014 calendar and 2 text items from a"fortune"

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am required to create a bash shell script with either emacs or vi. It must include the year 2014 calendar on... (9 Replies)
Discussion started by: dandanhelpmeman
9 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Retrieve RAM memory size from "top" command output

Hi, I am trying to get the system RAM size from "top" command's output by the following but it is not working. top | sed "s/^Mem.**\(*\), *//" (10 Replies)
Discussion started by: royalibrahim
10 Replies

6. Shell Programming and Scripting

"Join" or "Merge" more than 2 files into single output based on common key (column)

Hi All, I have working (Perl) code to combine 2 input files into a single output file using the join function that works to a point, but has the following limitations: 1. I am restrained to 2 input files only. 2. Only the "matched" fields are written out to the "matched" output file and... (1 Reply)
Discussion started by: Katabatic
1 Replies

7. AIX

AIX 5.3 - Discrepancies between "top" and "vmstat"

Can someone explain the differences I'm seeing below in TOP and VMSTAT commands on my AIX 5.3 server? Thanks! CPUs: 4; load averages: 0.86, 0.97, 0.97 18:09:26 926 processes: 4 stopped, 922 running CPU states: 78.4% idle, 8.5% user, 12.6% kernel, 0.3% wait Memory: 23680M Total.... (1 Reply)
Discussion started by: troym72
1 Replies

8. Debian

Debian: doubt in "top" %CPU and "sar" output

Hi All, I am running my application on a dual cpu debian linux 3.0 (2.4.19 kernel). For my application: <sar -U ALL> CPU %user %nice %system %idle ... 10:58:04 0 153.10 0.00 38.76 0.00 10:58:04 1 3.88 0.00 4.26 ... (0 Replies)
Discussion started by: jaduks
0 Replies

9. UNIX for Dummies Questions & Answers

Process seen in "ps aux" but not "top"

Hi, I have a process that can be seen after "ps aux" command. However when I do "top" command. This process cannot be seen. How can this happen? Is there anything wrong with my code? (3 Replies)
Discussion started by: monkfan
3 Replies

10. UNIX for Advanced & Expert Users

Commands on Digital Unix equivalent to for "top" and "sar" on other Unix flavour

Hi, We have a DEC Alpha 4100 Server with OSF1 Digital Unix 4.0. Can any one tell me, if there are any commands on this Unix which are equivalent to "top" and "sar" on HP-UX or Sun Solaris ? I am particularly interested in knowing the CPU Load, what process is running on which CPU, etc. ... (1 Reply)
Discussion started by: sameerdes
1 Replies
Login or Register to Ask a Question