Associating a PID with a Service

The question of how to associate a process id with a SMF service recently came across an internal alias and I thought it was worth sharing.

Take this generic looking Java process:

bleonard@opensolaris:/system$ ps -fp 949
     UID   PID  PPID   C    STIME TTY         TIME CMD
    root   949   947   0   Oct 11 ?           3:46 /usr/jdk/jdk1.6.0_13/bin/java -Xms4M -Xmx128M -Dcom.sun.management.jmxremote -D

If I'd like to trace back to which SMF service started this process, I start by getting the process' contract ID:

bleonard@opensolaris:/system$ ps -o ctid -p 949
 CTID
   59

I can then use the ctstat command to cross reference the contract ID to the SMF service:

bleonard@opensolaris:/system$ ctstat -vi 59
CTID    ZONEID  TYPE    STATE   HOLDER  EVENTS  QTIME   NTIME   
59      0       process owned   7       0       -       -       
	cookie:                0x20
	informative event set: none
	critical event set:    core signal hwerr empty
	fatal event set:       none
	parameter set:         inherit regent
	member processes:      947 949
	inherited contracts:   none
	service fmri:          svc:/application/management/common-agent-container-1:default
	service fmri ctid:     59
	creator:               svc.startd
	aux:                   start

And just to go full circle:

bleonard@opensolaris:/system$ svcs -lp  common-agent-container-1
fmri         svc:/application/management/common-agent-container-1:default
name         Cacao, a common Java container for JDMK/JMX based management solution
enabled      true
state        online
next_state   none
state_time   Mon Oct 11 12:54:59 2010
logfile      /var/svc/log/application-management-common-agent-container-1:default.log
restarter    svc:/system/svc/restarter:default
contract_id  59 
dependency   require_all/none svc:/system/filesystem/local (online)
dependency   require_all/none svc:/network/initial (online)
process      947 /usr/lib/cacao/lib/tools/launch -w /var/run/cacao/instances/default/run -L 1638
process      949 /usr/jdk/jdk1.6.0_13/bin/java -Xms4M -Xmx128M -Dcom.sun.management.jmxremote -D

For a nice little tutorial on contracts, check out this Contract Subsystem Lab.

Comments:

Thanks - very interesting post.
Unfortunately ctstat -vi doesn't give the service fmri on Solaris 10 so I guess this is an Opensolaris feature only at the moment?

Posted by Richard on October 19, 2010 at 01:06 AM GMT #

Yes, OpenSolaris only feature. I'm not aware of any plans to back port it to Solaris 10.

Posted by W Brian Leonard on October 19, 2010 at 03:22 AM GMT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

The Observatory is a blog for users of Oracle Solaris. Tune in here for tips, tricks and more as we explore the Solaris operating system from Oracle.

Connect with Oracle Solaris:


Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today