Links

   Quran Explorer - Interactive Audio Recitations & Translations

Wednesday, September 1, 2010

Solaris SMF - processes comprising a service

Another common task is to list the processes comprising a service. In this example, we will look at the Apache2 service.

First, check if the service is running, using the svcs command:

my-system# svcs apache2
STATE STIME FMRI
online 11:25:33 svc:/network/http:apache2

To list the process IDs of this service, use the svcs command with the -p option.
my-system# svcs -p apache2
STATE STIME FMRI
online 11:25:33 svc:/network/http:apache2
11:25:33 2438 httpd
11:25:34 2439 httpd
11:25:34 2440 httpd
11:25:34 2441 httpd
11:25:34 2442 httpd
11:25:34 2443 httpd

Viewing all Service Information 

To view all available information about a particular service, use the svcs command with the -l option, specifying the service by name:
my-system# svcs -l apache2
fmri svc:/network/http:apache2
name Apache 2 HTTP server
enabled true
state online
next_state none
state_time Wed Jun 07 11:47:04 2006
logfile /var/svc/log/network-http:apache2.log
restarter svc:/system/svc/restarter:default
contract_id 297
dependency require_all/error svc:/network/loopback:default (online)
dependency optional_all/error svc:/network/physical:default (online)

This option gives a number of useful details about the service. For example, the service is enabled, is online, and has been online since June 7 11:47:04 2006. The logfile, the restarter, and the service dependencies are given as well.

Common Administrative Tasks

This examples starts the Apache2 service and performs some common administrative tasks on the service.

To start the apache2 service, use the svcadm command with the enable option:
my-system# svcadm enable apache2

To display its status, use the svcs command:
my-system# svcs http
STATE STIME FMRI
online 11:26:46 svc:/network/http:apache2

To examine the process IDs associated with the service, use the scvs command with the -p option
my-system# svcs -p http
STATE STIME FMRI
online 11:26:46 svc:/network/http:apache2
11:26:46 2463 httpd
11:26:47 2464 httpd
11:26:47 2465 httpd
11:26:47 2466 httpd
11:26:47 2467 httpd
11:26:47 2468 httpd

To kill the service, use the pkill command. Then check the status again:
my-system# pkill http

my-system# svcs http
STATE STIME FMRI
online 11:28:05 svc:/network/http:apache2

Note that in this example the service did indeed stop, but was restarted automatically. STIME in the two cases are different indicating that the service was restarted. SMF increases the uptime of the service and also makes this information easy to retrieve.

Get more information using the -x option.
my-system# svcs -x http
svc:/network/http:apache2 (Apache 2 HTTP server)
State: online since Tue Jun 06 11:28:05 2006
See: apache2(1M)
See: /var/svc/log/network-http:apache2.log
Impact: None.

With SMF it is easy to get additional information about services using the -x and -v options of the svcs(1) command. This is particularly helpful when you are investigating the reason why a particular service has failed.

Option
Description
-x
Displays explanations for service states
-v
With -x, displays extra information for each explanation

No comments:

Post a Comment

Feel free to leave a comment