One of the problems with the psinfo struct in Solaris is that the args (i.e. the command line you would see with "ps -ef") are limited to 80 characters.
This proved to be problematic today because we need to monitor 3 separate Java (surprise, surprise) processes. However, their command line strings are so long that, after the 80 character truncation, the strings are identical. This means that there's no way to tell the difference between them from a monitoring point of view (using the pid is too unreliable btw, since we have no idea when they might restart). I checked the latest version of Proc::ProcessTable to see if Dan Urist had already dealt with this but, alas, no.
There are a couple of workarounds. First, we could parse "/usr/ucb/ps -auxww", which is different than your standard 'ps' command. The 'ww' widens the command line string as wide as it will go. The second option, and the one I favor, is to modify my C source. After some extensive searching, I found a handy snippet of C code that does what I need (in addition to providing ENV info, which is nice).
There are some caveats to this. It's possible for a program to create false information its own command line options or environment information. Generally this is done as a security precaution to prevent you from picking up something critical (like a password). Most programs (at least not the ones I'm dealing with) aren't that security conscious, however, so it shouldn't be an issue.
In other news, I discovered that gooogle.com takes you to google.com. I suffered a brief moment of panic at work when I realized what I had done, thinking it might take me to a porn site. *Whew*.
Need to do the same thing.. parse the psinfo structure. An additional complication is that it also needs to run, almost out of the box, in a Linux machine (and I find that the
My solution, for now, is to actually install Proc::ProcessTable on the server, do a shell call from inside C to a script, parse the output from the script and then pack and send onto the client (this is for server process information). sysinfo (native C call) had possibilities, but didnt give enough information to be really useful.
Any pointers appreciated..
Re:where/how, please ?
djberg96 on 2003-07-14T15:12:33
I found two good links. The first is a little C program called "qps" by Kurt Vogel (if I've read the attribution correctly). You can find that one here. I built it fine on my Solaris 9 box. Works fine - just make sure to run with the -A option to see for yourself that it does, indeed, extend past 80 characters.The other link, which I haven't looked at in depth yet but which looked promising, can be found here. It's from a Sun support forum and I think they took a different approach.
Enjoy!
Re:where/how, please ?
djberg96 on 2003-07-14T17:24:49
As a followup to my own followup, I should mention (and you'll discover pretty quick) that the code snippets I gave you were for Solaris only. I wasn't aware of the Linux limitation, nor do I know how to solve the problem on Linux, though I haven't searched at all.