Links

   Quran Explorer - Interactive Audio Recitations & Translations
Showing posts with label solaris. Show all posts
Showing posts with label solaris. Show all posts

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

Solaris - svc command options

Table 2—Useful options for svcs(1)

Note that a lowercase -d option and the uppercase -D option actually mean different things. The -d option results in a list of services on which the named service depends, while the -D option results in a list of services which depend upon the named service. Think of them as above and below the service on a dependency tree.
In Step 1, you used the -a option to list all services on the system. Now take a look at the list of services on which inetd depends.
To list the dependencies of the inetd service, use the svcs command, specifying the -d option:
my-system# svcs -d inetd
STATE STIME FMRI
disabled Apr_18 svc:/network/inetd-upgrade:default
online Apr_18 svc:/milestone/name-services:default
online Apr_18 svc:/network/loopback:default
online Apr_18 svc:/milestone/network:default
online Apr_18 svc:/system/filesystem/local:default
online Apr_18 svc:/network/rpc/bind:default
online Apr_18 svc:/milestone/sysconfig:default
As you can see, inetd depends upon a number of different services including inetd-upgrade and name-services. The same command can be used to find out if any one of these services depends upon other services. With the information gathered you can sketch out the dependency tree for inetd. Figure 1 shows a partial graph of the dependency tree for inetd.

Figure 1—Partial dependency tree for inetd (enlarge image)
To generate a similar list for Apache2, use the svcs command and the -d option, specifying Apache2 by name:
my-system# svcs -d apache2
STATE STIME FMRI
online Apr_18 svc:/network/loopback:default
online Apr_18 svc:/network/physical:default
Next, use the -D option to identify services which depend upon inetd and Apache.
To discover the services which depend upon inetd, use the svcs command with the -D option, specifying inetd by name:
my-system# svcs -D inetd
STATE STIME FMRI
online Apr_18 svc:/milestone/multi-user:default
In this example you can see that multi-user depends upon inetd.
Next, find the services which, in turn, depend upon multi-user.
To discover the services which depend upon multi-user, use the svcs command with the -D option, specifying multiuser by name:
my-system# svcs -D multi-user
STATE STIME FMRI
disabled Apr_18 svc:/network/dhcp-server:default
online Apr_18 svc:/milestone/multi-user-server:default
Notice that there are two services which depend upon multi-user, dhcp-server and multi-user-server.
Next, examine the dhcp-server.
To discover the services which depend upon dhcp-server, use the svcs command with the -D option, specifying dhcp-server by name. Follow through the whole dependency tree in the same way:


my-system# svcs -D dhcp-server
STATE STIME FMRI
online Apr_18 svc:/milestone/multi-user-server:default
Find the services which depend upon multi-user-server:
my-system# svcs -D multi-user-server
STATE STIME FMRI
online Apr_18 svc:/system/zones:default
Find services which depend upon zones:
my-system# svcs -D zones
STATE STIME FMRI
In this case, there are no services which depend on zones, so this is the end of the dependency tree. See the dependency tree below.
 Listing Service Processes

Solaris - Service Management Primer

SMF Commands

SMF has a limited yet powerful set of commands. Each command has several options which cover the tasks required to manage Solaris systems. The following table lists the SMF commands.

Command
Description
svcs
Reports service status
svcadm
Used for service management: e.g., starting, stopping and restoring services
svccfg
Used to list properties of a service
svcprop
Used to list properties of a service
inetadm
Used to manage inetd services


Table 1—SMF commands


This guide focuses on gathering information about the services running on a Solaris system and troubleshooting a failed service. These tasks are accomplished with the svcs and svcadm commands.
The other commands enable system administrators to manage, modify, and display service manifests. You can read more about them on docs.sun.com under the Solaris 10 Basic Administration Guide.




An Example
This example begins by looking at all the services currently running on your Solaris system and then examining a few of the services for more details. These details include the services upon which they depend and the services which depend upon them.
Displaying System Services Information

To display all services on your Solaris system with their state information, use the svcs command along with the -a option:
my-system# svcs -a

STATE STIME FMRI
legacy_run Apr_18 lrc:/etc/rcS_d/S51installupdates
legacy_run Apr_18 lrc:/etc/rc2_d/S47pppd
legacy_run Apr_18 lrc:/etc/rc2_d/S99audit
legacy_run Apr_18 lrc:/etc/rc3_d/S76snmpdx
legacy_run Apr_18 lrc:/etc/rc3_d/S90samba
disabled Apr_18 svc:/network/ipfilter:default
disabled Apr_18 svc:/network/rpc/keyserv:default
disabled Apr_18 svc:/network/rpc/nisplus:default
disabled Apr_18 svc:/application/print/server:default
disabled Apr_18 svc:/network/dhcp-server:default
disabled Apr_18 svc:/network/http:apache2
online Apr_18 svc:/system/svc/restarter:default
online Apr_18 svc:/network/pfil:default
online Apr_18 svc:/network/physical:default
online Apr_18 svc:/system/identity:domain
online Apr_18 svc:/system/cryptosvc:default
online Apr_18 svc:/network/inetd:default
online Apr_18 svc:/network/telnet:default
online Apr_18 svc:/network/ssh:default
online Apr_18 svc:/system/zones:default
online Apr_18 svc:/network/nfs/nlockmgr:default
offline Apr_18 svc:/application/print/ipp-listener:default
offline Apr_18 svc:/application/print/rfc1179:default
[Note: This is a truncated list] Displaying Individual Services

You can look at individual services as well. This is especially useful during troubleshooting or when examining what is going on with a particular service.
To display information about the inetd service, use the svcs command specifying the service by name:

my-system# svcs inetd
STATE STIME FMRI
online Apr_18 svc:/network/inetd:default
To display information about the Samba service, use the svcs command specifying the service by name:

my-system# svcs S90samba
STATE STIME FMRI
legacy_run Apr_18 lrc:/etc/rc3_d/S90samba
To display information about the Apache service, use the svcs command specifying the service by name:

my-system# svcs apache2
STATE STIME FMRI
disabled Apr_18 svc:/network/http:apache2 Retrieving Dependency Tree Information

SMF permits you to identify all the service dependencies for a given service. That is, the services upon which a given service depends, as well as the services that depend upon that service. The following options are used to provide additional detail on the services.

Option
Description
-a
Displays all services, including those which have been disabled
-d
Lists a service's dependencies
-D
Lists a service's dependents
-l
Displays all available information about the service
-p
Lists all processes (PID) associated with a service

Solaris - Network Interfaces

1. Ip Address basics
checking the config of a particular (configured) interface
- ifconfig e1000g0
Modifying
- ifconfig e1000g0 inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255

2. Network Interfaces
a. check configured (plumbed ??) interfaces
# ifconfig -a
b. to check all connected physical nic ports
# dladm show-dev
c. to mount(?) an interface (eg e1000g1) (before u can give it an ip)
# efconfig e1000g1 plumb
d. to give it an ip
#ifconfig e1000g1 inet 192.168.56.103 netmask 255.255.255.0 broadcast 192.168.56.255
e. to bring it up (make it usable)
#ifconfig e1000g1 up