LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   TOP problem (https://www.linuxquestions.org/questions/linux-newbie-8/top-problem-829923/)

babaqga 09-02-2010 06:46 AM

TOP problem
 
Hi guys,
I am new to Linux and I have the following problem:

I have the "top" command and I want to override its default behavior for every user, even for future users.

Writing with "W" in top is not an option as my top command somehow overrides the custom behavior per user and always turns to default behavior.

So, what I am asking for is, are there command line switches that override default behavior of top,
for example:

Code:

top -<BLABLA>
to show me the load average per core
which would be equivalent to starting top first and then pushing the key "1" on the keyboard.

Remember, writing to toprc is not an option for me as top for some reason ignores its config and just goes for default behavior.

Edit: it seems to me this is a bug in the procps package. That is why I updated it to the latest version for my distro
CentOS 5.5 and procps to the following
http://rpm.pbone.net/index.php3/stat...86_64.rpm.html
HOWEVER, it doesn't work even now.

I can't believe that nobody in this forum haven't seen the problem.

lurker79 09-02-2010 09:30 AM

This is potentially a bug in the version of top that you are running.
If it is not reading .toprc from the user's home directory then it could be related to the fix posted upstream at http://procps.cvs.sourceforge.net/vi...1.132&r2=1.134
It is worth filing a bug against centos 5.5

babaqga 09-02-2010 10:15 AM

Quote:

Originally Posted by lurker79 (Post 4086022)
This is potentially a bug in the version of top that you are running.
If it is not reading .toprc from the user's home directory then it could be related to the fix posted upstream at http://procps.cvs.sourceforge.net/vi...1.132&r2=1.134
It is worth filing a bug against centos 5.5

Already did that, but not with centOS, as it got shipped with an older package of procps that still doesnt' work. I installed the latest rpm
procps-3.2.7-16.el5
but it is the same story. The thing is it works perfectly when called locally by the script, but this same script, when called by the same user using nrpe, doesn't behave correctly. I am not really sure who is to blame.

To summarize:
Top behaves differently when called with the same user respectively from nrpe and from a locally residing script. I assume it SHOULD have the same config (/home/nagios/.toprc) but when called from nrpe, it ignores its home directory and switches to default. Any hints?

Soadyheid 09-02-2010 12:06 PM

Quote:

So, what I am asking for is, are there command line switches that override default behavior of top,
Have you tried checking the manual for switches?
Quote:

man top
Play Bonny! :hattip:

babaqga 09-03-2010 02:14 AM

Quote:

Originally Posted by Soadyheid (Post 4086166)
Have you tried checking the manual for switches?


Play Bonny! :hattip:

Are you actually serious with your question?
I hate derogatory remarks.

Did you at least read what I wrote above?
If you did you might wanna check YOUR top man and tell me why it behaves differently WHEN CALLED FROM THE SAME USER, although the /home/<user>/.toprc file exists?!

Is there anyone else who actually read my question?

djsmiley2k 09-03-2010 02:17 AM

Does the script change directory at all?

in the script, before you call top, get it to echo $PWD to see where the script is running.

babaqga 09-03-2010 02:26 AM

Quote:

Originally Posted by djsmiley2k (Post 4086769)
Does the script change directory at all?

in the script, before you call top, get it to echo $PWD to see where the script is running.

The script does change the directory, as I explained, however, sometimes unpredictably...

Here is the problem:

1. When called locally with user nagios, the script changes the directory as I wish, because it uses the top command for user nagios, which has its configuration file in /home/nagios/.toprc.

2. However, when called from a deamon (nrpe) with the same user (nagios), the script changes the directory in a different way, because top IGNORES its configuration file and switches to default.

P.S I am absolutely sure that the script is called with the same user on both occasions because I straced it, lsof-ed it and what else.


My question is the following: is there anything else besides user name that tells top where to find its config file. In the documentation it says there isn't. If that is so, top sometimes ignores its configuration file and that is a bug.

P.P.S. This was indeed a bug in procps library but in 2006. As far as I see in the bug fixes, this bug was addressed. However, I am with the newest release and it still bugs. Any hints?

P.P.P.S I am now actually even surer, as I made a "whoami" and in both cases the user is nagios. HINTS!?

djsmiley2k 09-03-2010 02:36 AM

All I know is I have the same bug in gentoo, with the newest version of top and its something to do with the way it writes out the config file.

However this doesn't explain the behaviour your seeing (as if its accessing two different versions of top

babaqga 09-03-2010 02:47 AM

Quote:

Originally Posted by djsmiley2k (Post 4086788)
All I know is I have the same bug in gentoo, with the newest version of top and its something to do with the way it writes out the config file.

However this doesn't explain the behaviour your seeing (as if its accessing two different versions of top

Yep, I wrote the guys at procps, but no reply so far.


All times are GMT -5. The time now is 12:50 AM.