Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Memory Monitoring

by steelrose (Scribe)
on Apr 29, 2005 at 15:15 UTC ( #452633=note: print w/ replies, xml ) Need Help??


in reply to Re: Memory Monitoring
in thread Memory Monitoring

Last week I tried the Proc::ProcessTable() module. Unfortunately in its build package, it installs an executable. This is bad, because were not supposed to install executables on our production system.

In the /proc/<pid>/psinfo file, the pr_psargs is an 80 character string that contains the complete command line. The pr_psargv and pr_envp fields are memory addresses that are basically offsets inside the /proc/<pid>/as file (address space).

The reason I need the complete command line are for java apps. Imagine having a classpath and env vars. You can see how quickly your command line grows above the 80 characters. In these cases, doing a grep to kill particular processes can be very dangerous.

Anyway, the /proc/<pid>/as file is only readable by the person who owns the process. /usr/ucb/ps is owned by root and can read anyfile, so it doesn't have a problem.

I really wasn't trying to "Reinvent the wheel" as your post was saying. Just trying to use what we have available and won't cause a problem with the Unix admins.

So I went back to the simpliest way to do it. A pgrep with a /usr/ucb/ps -auxww <pid>. Then I parse out the memory and cpu statistics. Not happy about the solution, but it works...

And now I know more about the internals of Solaris's proc directory :)

Thanks to all the Monks who replied.

If you give a man a fish he will eat for a day.
If you teach a man to fish he will buy an ugly hat.
If you talk about fish to a starving man, you're a consultant.


Comment on Re^2: Memory Monitoring
Re^3: Memory Monitoring
by naChoZ (Curate) on Apr 29, 2005 at 15:52 UTC

    Unfortunately my sparc is tucked behind a firewall at home and I can't reach it and try this out at the moment. I think the berkely ps in solaris can take a -p option. So you can do something like this to display the cli for a specific pid:

    /usr/ucb/ps -o command -p 12345

    --
    "This alcoholism thing, I think it's just clever propaganda produced by people who want you to buy more bottled water." -- pedestrianwolf

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://452633]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (17)
As of 2014-07-29 13:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (217 votes), past polls