Issue 277 in psutil: Monitoring Java Servers On Mac OS Lion Causes Monitored Server To Segfault

18 views
Skip to first unread message

psu...@googlecode.com

unread,
Jun 9, 2012, 11:17:03 PM6/9/12
to psutil-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 277 by shane.c....@gmail.com: Monitoring Java Servers On Mac OS
Lion Causes Monitored Server To Segfault
http://code.google.com/p/psutil/issues/detail?id=277

What steps will reproduce the problem?

Running the following code to monitor a Java based server on Mac OS Lion
causes the monitored server to seg fault. I tried this with several
industrial grade servers (ActiveMQ, Tomcat etc) and each time the server
crashed after several minutes when the script is run on five second loop.

I want to be clear - it is not the python script that fails - it is the
java server process that is being monitored that consistently segfaults. I
tried with non-java processes (firefox etc) and did not observe the same
behavior.

{{{
#!/usr/bin/env python

import psutil
import sys

proc = None;

#find the server we are looking for
for ps in psutil.process_iter():
#print ps.name
try:
if( ps.name == "java" ):
for cmd in ps.cmdline:
if cmd.count("apache-activemq-5.4.2") > 0:
proc = ps;
break
if proc is not None:
break

except Exception, e:
pass

if not proc:
print "SERVER NOT RUNNING..."
sys.exit(1)


print " CPU: {0:15.1f}%".format(proc.get_cpu_percent())
print " U Time: {0:15.1f}s".format(proc.get_cpu_times().user)
print " S Time: {0:15.1f}s".format(proc.get_cpu_times().system)
print " Memory: {0:15.1f}%".format(proc.get_memory_percent())
print " Threads:{0:13d}".format( proc.get_num_threads() )
print " Files: {0:13d}".format( len(proc.get_open_files()) )
print " INET: {0:13d}".format( len(proc.get_connections()) )

}}}


What is the expected output?

The service being monitored should continue to run


What do you see instead?

Segmentation fault: 11

What version of psutil are you using? What Python version?

psutil 0.4.1
python 2.7

On what operating system? Is it 32bit or 64bit version?

Mac Lion - 64 bit

Please provide any additional information below.



psu...@googlecode.com

unread,
Jun 9, 2012, 11:57:46 PM6/9/12
to psutil-...@googlegroups.com

Comment #1 on issue 277 by jlo...@gmail.com: Monitoring Java Servers On Mac
OS Lion Causes Monitored Server To Segfault
http://code.google.com/p/psutil/issues/detail?id=277

Hi Shane,

Since you're able to reproduce the problem simply on your system, can you
try narrowing down the steps to reproduce to the smallest test case? For
example, does the problem happen due to use of one of these specific calls
below?

print " CPU: {0:15.1f}%".format(proc.get_cpu_percent())
print " U Time: {0:15.1f}s".format(proc.get_cpu_times().user)
print " S Time: {0:15.1f}s".format(proc.get_cpu_times().system)
print " Memory: {0:15.1f}%".format(proc.get_memory_percent())
print " Threads:{0:13d}".format( proc.get_num_threads() )
print " Files: {0:13d}".format( len(proc.get_open_files()) )
print " INET: {0:13d}".format( len(proc.get_connections()) )

It would be very helpful to determine specifically which feature of psutil
seems to be causing a problem for the Java process. If you are getting a
hotspot crash dump from the JVM that would also be helpful to include here.

Thanks

psu...@googlecode.com

unread,
Jun 10, 2012, 1:01:14 AM6/10/12
to psutil-...@googlegroups.com

Comment #2 on issue 277 by shane.c....@gmail.com: Monitoring Java Servers
On Mac OS Lion Causes Monitored Server To Segfault
http://code.google.com/p/psutil/issues/detail?id=277

Yes. I had actually been doing this in the background - I tried running
each one of these individually and could not reproduce the segfault after
running ~10 minutes each. Within minutes of starting them all again, the
segfault happened again. So, it appears to not be a single call, but some
combination of multiple. I will try combining and see what I can come up
with.

psu...@googlecode.com

unread,
Jun 10, 2012, 1:37:37 AM6/10/12
to psutil-...@googlegroups.com

Comment #3 on issue 277 by shane.c....@gmail.com: Monitoring Java Servers
On Mac OS Lion Causes Monitored Server To Segfault
http://code.google.com/p/psutil/issues/detail?id=277

OK - I have caused it to happen with this combination:

print " S Time: {0:15.1f}s".format(proc.get_cpu_times().system)
print " Memory: {0:15.1f}%".format(proc.get_memory_percent())
print " Threads:{0:13d}".format( proc.get_num_threads() )
print " Files: {0:13d}".format( len(proc.get_open_files()) )

This was the smallest combination that I could get it to happen with. Is it
possible that this is a timing issue - and not really dependent on what we
are doing - but how long we are doing it for (ie, the longer I spend
working with the proc object, the greater the chance that the error will
occur)? If so, I could reduce the amount of time by building the string and
then printing it all at once - but I don't like the idea that the thing I
am using to monitor my applications is the one that it murdering them :)

I will turn debugging on in the jvm and see if I can get more information
there.

psu...@googlecode.com

unread,
Feb 24, 2013, 4:59:56 PM2/24/13
to psutil-...@googlegroups.com

Comment #4 on issue 277 by g.rodola: Monitoring Java Servers On Mac OS Lion
Causes Monitored Server To Segfault
http://code.google.com/p/psutil/issues/detail?id=277

Any news about this?

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

psu...@googlecode.com

unread,
May 26, 2014, 11:17:06 AM5/26/14
to psutil-...@googlegroups.com

Comment #5 on issue 277 by g.rodola: Monitoring Java Servers On Mac OS Lion
Causes Monitored Server To Segfault
http://code.google.com/p/psutil/issues/detail?id=277

psutil has been migrated from Google Code to Github (see:
http://grodola.blogspot.com/2014/05/goodbye-google-code-im-moving-to-github.html).
Please do NOT reply here but use this instead:
https://github.com/giampaolo/psutil/issues/277
Reply all
Reply to author
Forward
0 new messages