problems in redirecting TOP


 
Thread Tools Search this Thread
Operating Systems Solaris problems in redirecting TOP
# 1  
Old 07-07-2006
Error problems in redirecting TOP

Hi All,
I am trying to run top in crontab, but I am getting problem while trying to redirecting the output of top cmd.
I am getting the process part but the CPU states, user, kernel, iowait, swap part is not showing.

While trying top > some_file_name the output i'm getting,

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

Is that the problem or there is any other way i can get that data directed as well.

Thanks,
Ran
# 2  
Old 07-07-2006
I take it you don't have any problems running from command-line?


top:

-bash-3.00$ top -d 1 > /tmp/top.lst
-bash-3.00$ cat /tmp/top.lst
load averages: 0.28, 0.39, 0.40 14:58:39
42 processes: 41 sleeping, 1 on cpu

Memory: 16G real, 9929M free, 6067M swap in use, 12G swap free


PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND
18827 cquest 115 26 11 0K 0K sleep 77:32 2.66% java
24109 jmcontre 1 59 0 3784K 1536K cpu/1 0:00 0.02% top
24085 jmcontre 1 49 0 3000K 2392K sleep 0:00 0.02% bash
24083 jmcontre 1 59 0 8232K 2736K sleep 0:00 0.02% sshd
99 root 6 59 0 3896K 3088K sleep 0:44 0.00% picld
627 root 1 100 -20 2304K 1552K sleep 0:37 0.00% xntpd
24080 root 1 59 0 8448K 4864K sleep 0:00 0.00% sshd
7 root 13 59 0 8864K 7848K sleep 0:24 0.00% svc.startd
113 root 25 59 0 3856K 2936K sleep 0:23 0.00% nscd
9 root 16 59 0 9648K 8696K sleep 0:12 0.00% svc.configd
1 root 1 59 0 2392K 1392K sleep 0:08 0.00% init
220 root 4 59 0 4792K 3816K sleep 0:07 0.00% inetd
207 root 1 60 0 2696K 1336K sleep 0:07 0.00% cron
354 root 12 59 0 5712K 5016K sleep 0:06 0.00% fmd
535 root 1 59 0 0K 0K sleep 0:04 0.00% snmpd


prstat:

-bash-3.00$ prstat 1 1 > /tmp/top.lst
-bash-3.00$ cat /tmp/top.lst
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
18827 cquest 6154M 5590M sleep 26 11 1:17:35 1.6% java/115
24111 jmcontre 1624K 1272K cpu1 49 0 0:00:00 0.0% prstat/1
24085 jmcontre 3000K 2392K sleep 49 0 0:00:00 0.0% bash/1
24083 jmcontre 8232K 2736K sleep 59 0 0:00:00 0.0% sshd/1
627 root 2304K 1552K sleep 100 - 0:00:37 0.0% xntpd/1
99 root 3896K 3088K sleep 59 0 0:00:44 0.0% picld/6
223 root 2136K 1440K sleep 59 0 0:00:00 0.0% ttymon/1
209 daemon 2608K 1528K sleep 59 0 0:00:00 0.0% rpcbind/1
224 root 2104K 1360K sleep 59 0 0:00:00 0.0% ttymon/1
212 daemon 2656K 1936K sleep 59 0 0:00:00 0.0% statd/1
323 root 4600K 2208K sleep 59 0 0:00:00 0.0% syslogd/19
131 root 2720K 1936K sleep 59 0 0:00:00 0.0% devfsadm/6
126 root 2344K 1360K sleep 59 0 0:00:00 0.0% powerd/3
213 root 2000K 1248K sleep 59 0 0:00:00 0.0% sac/1
207 root 2696K 1336K sleep 60 0 0:00:07 0.0% cron/1
Total: 42 processes, 271 lwps, load averages: 0.17, 0.34, 0.38
# 3  
Old 07-10-2006
That didn't work, the problem i mentioned still persistes.
# 4  
Old 07-10-2006
Seems like permisson issue. Try running as root and see if it works..
# 5  
Old 07-10-2006
Doesn't looks like a permission issue, because when i run it from the cmd prompt, it is apperaring fine. Problem is occuring only in case of redirecing.
# 6  
Old 07-10-2006
Quote:
Originally Posted by rana_d
Doesn't looks like a permission issue, because when i run it from the cmd prompt, it is apperaring fine. Problem is occuring only in case of redirecing.
Actually it does look like a permission problem. What happens when you do this:
Code:
top -n 1 2> /tmp/top_errors
cat /tmp/top_errors

I'm guessing /tmp/top_errors contains:
top: cannot open /dev/kmem
kvm_open: Permission denied

No need to worry about that, top has other ways of getting the information it needs, but if you really want to grab that as well

Code:
top > some file 2>&1

# 7  
Old 07-23-2006
MySQL Top in cron

Dear Friend,

Type the following in a shell script to get the top output.

top -d 8 -s 600 >> pvpk_240706.top

Explanation:
It keeps appending top into a file pvpk_240706.top

Option d : Number of Displays. In this example you get 8 Top displays. with
10 top process.

Option s: Number of SECONDS to delay for each display.

You need to ignore the first output as it doesnt capture the CPU states.


I am sure this is what you were looking for.

With warm regards,
Pavan Kumar.
This User Gave Thanks to pvpavankumar For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Clarification about redirecting

Hi AM Using Unix Aix Used ${CMD} 2> ${ERR} Dont get what above statement works . SCRIPT=`basename $0` ERR=$PWD/$SCRIPT.err DATE=`date +"%d/%m/%Y"` CMD=2 ${CMD} 2> ${ERR} if then echo "SUCCESS" else echo "FAILURE" fi (1 Reply)
Discussion started by: Venkatesh1
1 Replies

2. Shell Programming and Scripting

redirecting help

I am trying to create the file and redirect the output in the same command line which is line 4 in the below program. #!/bin/bash read -p "Enter File Name:" value1 echo "Your File Name is $value1" sed 's/abcd/'$value1'/g' abcd_calls > $value1_calls This is the error it generates ... (3 Replies)
Discussion started by: learnbash
3 Replies

3. AIX

Need a list of top 10 CPU using processes (also top 10 memory hogs, separately)

Okay, I am trying to come up with a multi-platform script to report top ten CPU and memory hog processes, which will be run by our enterprise monitoring application as an auto-action item when the CPU and Memory utilization gets reported as higher than a certain threshold I use top on other... (5 Replies)
Discussion started by: thenomad
5 Replies

4. Shell Programming and Scripting

Redirecting stdin from fd 3-9?

Hi I'm trying to do something on the bash command line that I will later put into a bash shell script. I'm trying to take a program that reads stdin (using getline) and be able to keep it running in the background and fire "commands" to it. So what I thought I should do was to try taking... (3 Replies)
Discussion started by: niceguyeddie
3 Replies

5. AIX

Top command in AIX 4.2 (no topas, no nmon, no top)?

Is there a 'top' command equivalent in AIX 4.2 ? I already checked and I do not see the following ones anywhere: top nmon topas (1 Reply)
Discussion started by: Browser_ice
1 Replies

6. Web Development

Apache redirecting

Dear All I need to redirect requests coming in on a second domain, to a page within an existing web site. So basicly http:\\webtest should be redirected to http:\\ustnd5\ukt\newsroom\newsroom.jsp I have the line ProxyPassReverse /ukt/newsroom/newsroom.jsp http://webtest:10080/ ... (1 Reply)
Discussion started by: wjones
1 Replies

7. UNIX for Advanced & Expert Users

MX redirecting

I in no means consider myself a expert in unix however my question is a little more complex. I am running a mac os 10 server and all web settings and email settings have been set up using the unix terminal. I am in the process or redirecting my mxrecords to a spam filtering company but i am... (11 Replies)
Discussion started by: nbredthauer
11 Replies

8. Solaris

Problems Installing Top

I've been trying to install Top on our Solaris box but it's giving me some trouble. The uname -a command shows SunOS servername 5.9 Generic sun4u sparc SUNW,Ultra-250 I downloaded Top form www.unixtop.com. On the initial install I got errors because I didn't have a C compiler installed.... (2 Replies)
Discussion started by: KenLynch
2 Replies

9. Programming

Redirecting

How to redirect the contents of a file to a command? The contents of the file are the arguments necessary for the command. thx in advance. bye svh (5 Replies)
Discussion started by: svh
5 Replies

10. UNIX for Dummies Questions & Answers

How Can I Have Top Display The Top 20 Processes??

how can i do that in a script withough havin the script halt at the section where the top command is located. am writign a script that will send me the out put of unx commands if the load average of a machine goes beyond the recommended number. top -n 20 i want to save this output to a file... (1 Reply)
Discussion started by: TRUEST
1 Replies
Login or Register to Ask a Question