compared with
Current by jason.davis@joyent.com
on Aug 07, 2012 20:50.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (22)

View Page History

Each service is identified by a Fault Management Resource Identifier (FMRI). For example, the FMRI for the Apache service is:
{code:lang=none}svc:/network/http:cswapache2{code}
The above FMRI breaks down in the following way:
|| String || Description ||
| {{:cswapache2}} | The service instance |
For example, this output shows that Apache was disabled on May 31st:
{code:lang=none}
$ svcs svc:/network/http:cswapache2
STATE STIME FMRI
{code}
An easy way of uncovering the FMRI for a service is by using {{grep}} in combination with {{svcs \-a}}. For example, using grep in the following exposes the FMRI of the MySQL service, which is {{cswmysql5}}:
{code:lang=none}
$ svcs -a | grep -i mysql
enabled May_31 svc:/network/cswmysql5:default

The {{svcadm}} command is used to enable, disable, restart, or refresh services. For example, this command enables the MySQL service.
{code:lang=none}
$ sudo svcadm enable cswmysql5
{code}
Using {{svcs}}, you can verify that the service is enabled:
{code:lang=none}
$ svcs cswmysql5
STATE STIME FMRI
{code}
You use {{disable}} to stop services. For example, this stops the MySQL service:
{code:lang=none}
$ sudo svcadm disable cswmysql5
{code}
You use {{restart}} to refresh a service. For example, after making a configuration change, you can refresh an enabled service like this:
{code:lang=none}
$ sudo svcadm restart cswmysql5
{code}

For example, the following will clear the state of the Apache service and SMF will automatically restart the service once cleared:
{code:lang=none}sudo svcadm clear svc:/network/http:cswapache2{code}

h2. Verifying a Service is in Maintenance Mode
To verify if a service is in maintenance mode:
# Run this command:
{code:lang=none}
svcs -a
{code}
This will show all running and disabled services. If a service is in maintenance mode, you will see something similar to this:
{code:lang=none}
maintenence 18:50:25 svc:/network/webmin:webmin 
{code}
# Review the log to root-cause why the service was in maintenance mode.
# Take the service out of maintenance mode:
{code:lang=none}
svcadm clear service_name
{code}

To verify if a service is disabled:
{code:lang=none}svcs -a{code}
If the service is disabled, you will see something similar to this:
{code:lang=none}
disabled 18:51:10 svc:/network/webmin:webmin
{code}
To enable a service:
# Enable the service:
{code:lang=none}
svcadm enable service_name
{code}
# Verify the service is enabled:
{code:lang=none}
svcs -a | grep service_name
{code}

If successful, you should see something similar to this:
{code:lang=none}
online 18:50:25 svc:/network/webmin:webmin
{code}

SMF maintains a contract with every running service it manages. The contract keeps track of what processes are running for any given service. Using the {{\-p}} option, you can determine all the processes that belong to a service. In the following example, the MySQL daemon is process number 29004.
{code:lang=none}
$ svcs -p network/cswmysql5
STATE STIME FMRI
{code}
The following example demonstrates how SMF restarts a service when it stops unexpectedly:
{code:lang=none}
$ kill -9 29004
$ svcs -p network/cswmysql5

The {{svccfg}} command allows you to import, export, and modify service configurations. You specify entities to manipulate by using the {{\-s}} option with an FMRI. The following example will set an environment variable for the specified FMRI with the value you specify.
{code:lang=none}svccfg -s FMRI setenv ENV_VARIABLE value{code}
You can invoke {{svccfg}} directly with individual subcommands or by specifying a script file.{note}
If you make any changes to a service using this command, you need to restart the service for the changes to take effect.{note}
# Open {{/etc/user_attr}} for edit.
# Add this line replacing "myuser" with the login you want to enable:
{code:lang=none}myuser::::profiles=Service Management{code}

After this change, the specified user is able to manage SMF (import, stop, start) without access to {{sudo}}. This minimizes the need for unnecessarily sharing sudo access among users.
To retrieve a specific setting for a service, we use svcprop in this case to figure out which ipf.conf ipfilter is using:

{noformat} {code:lang=none}
# svcprop -p firewall_config_default/custom_policy_file network/ipfilter:default
/etc/ipf/ipf.conf
{noformat} {code}

h1. Uncovering Information About Services