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.

In reply to Re^2: Memory Monitoring by steelrose
in thread Memory Monitoring by steelrose

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.