Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Memory Monitoring

by naChoZ (Curate)
on Apr 26, 2005 at 02:14 UTC ( #451405=note: print w/ replies, xml ) Need Help??


in reply to Memory Monitoring

I'm curious, what is the end result you're try to accomplish? Instead of reinventing the wheel, you could (amongst other possibilities) install the set of nagios plugins. They work on a large number of different platforms. I believe check_vsz (not perl) is their native plugin to monitor what you want, but there's other stuff for nagios people have written, including a fair number of perl scripts.

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


Comment on Re: Memory Monitoring
Re^2: Memory Monitoring
by steelrose (Scribe) on Apr 29, 2005 at 15:15 UTC
    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.

      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://451405]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-09-16 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (158 votes), past polls