After so much theory SMF may look a little bit complex but it isnīt. For the admin itīs really simple. You can control the complete startup of the system with just a few commands.
Whatīs running on the system
At first letīs have a look on all services running on the system:
# svcs
legacy_run 10:04:44 lrc:/etc/rc3_d/S84appserv
disabled 10:04:22 svc:/system/xvm/domains:default
online 10:03:48 svc:/system/svc/restarter:default
offline 10:03:54 svc:/network/smb/server:default
This is only a short snippet of the configuration. The output of this command is 105 lines long on my system. But you services in several service states in it. For example i hadnīt enabled xvm on my system (makes no sense, as this Solaris is already virtualized, and the smb server is still online.
Letīs look after a certain service
# svcs name-service-cache
STATE STIME FMRI
online 10:08:01 svc:/system/name-service-cache:default
The output is seperated into three columns. The first shows the service state, the second the time of the last start of the service. The last one shows the exact name of the service.
Starting and stoping a service
Okay, but how do i start the service, how do i use all this stuff:letīs assume, you want to disable sendmail. At first we check the current state:
# svcs sendmail
STATE STIME FMRI
online 10:23:19 svc:/network/smtp:sendmail
Now we disable the service. Itīs really straight forward:
# svcadm disable sendmail
Letīs check the state again.
# svcs sendmail
STATE STIME FMRI
disabled 10:23:58 svc:/network/smtp:sendmail
Okay, a few days later we realize that we need the sendmail service on the system. No problem we enable it again:
# svcadm enable sendmail
# svcs sendmail
STATE STIME FMRI
online 10:25:30 svc:/network/smtp:sendmail
The service runs again. Okay, we want to restart the service. This is quite simple, too
# svcadm restart sendmail
# svcs sendmail
STATE STIME FMRI
online* 10:25:55 svc:/network/smtp:sendmail
# svcs sendmail
STATE STIME FMRI
online 10:26:04 svc:/network/smtp:sendmail
Did you notice the change in the STIME column. The service has restarted. By the way: STIME doesnīt stand for "start time". Itīs a short form for "State Time". It shows, when the actual state of the services was entered.
Okay, now letīs do some damage to the system. We move the config file for sendmail, the glorious sendmail.cf. The source of many major depressions under sys admins.
# mv /etc/mail/sendmail.cf /etc/mail/sendmail.cf.old
# svcadm restart sendmail
# svcs sendmail
STATE STIME FMRI
offline 10:27:09 svc:/network/smtp:sendmail
Okay, the service went in the offline state. Offline? At first, the maintainance state would look more sensible. But letīs have a look in some diagnostic informations. With
svcs -x
you can print out fault messages regaring services.
# svcs -x
svc:/network/smtp:sendmail (sendmail SMTP mail transfer agent)
State: offline since Sun Feb 24 10:27:09 2008
Reason: Dependency file://localhost/etc/mail/sendmail.cf is absent.
See: http://sun.com/msg/SMF-8000-E2
See: sendmail(1M)
See: /var/svc/log/network-smtp:sendmail.log
Impact: This service is not running.
The SMF didnīt even try to start the service. There is an dependency implicit to the service.
# svcprop sendmail
config/value_authorization astring solaris.smf.value.sendmail
config/local_only boolean true
config-file/entities fmri file://localhost/etc/mail/sendmail.cf
config-file/grouping astring require_all
config-file/restart_on astring refresh
config-file/type astring path
[..]
The service configuration for sendmail defines a dependency to the config-file /etc/mail/sendmail.cf. Do you remember the definition of the service states? A service stays in offline mode until all dependencies are fullfilled. We renamed the file, the dependencies isnīt fullfilled. The restart leads correctly to the "offline state"
Okay, we repair the damage:
# mv /etc/mail/sendmail.cf.old /etc/mail/sendmail.cf
And now we restart the service
# svcadm refresh sendmail
# svcs sendmail
STATE STIME FMRI
online 10:33:54 svc:/network/smtp:sendmail
All is well, the service in online again
Automatic restarting of a service
Okay, letīs test another capability of the SMF. The kill the sendmail daemon.
# svcs sendmail
STATE STIME FMRI
online 10:33:54 svc:/network/smtp:sendmail
# pkill "sendmail"
# svcs sendmail
STATE STIME FMRI
online 10:38:24 svc:/network/smtp:sendmail
The SMF restarted the daemon automatically as you can see from the stime-column
Obtaining the configuration of a service
Okay, as i wrote before every service has some configuration in the SMF Service Configuration Repository. You can dump this configuration with the
svcprop
command. Letīs print out the configuration for the name service cache:
# svcprop svc:/system/name-service-cache:default
general/enabled boolean false
general/action_authorization astring solaris.smf.manage.name-service-cache
[..]
restarter/state astring online
restarter/state_timestamp time 1203844081.231748000
general_ovr/enabled boolean true
Dependencies
But how do i find out the dependencies between services. The
svcadm
commands comes to help:
The
-d
switch shows you all services, on which the service depends. In this example we check this for the ssh daemon.
# svcs -d ssh
STATE STIME FMRI
disabled 8:58:07 svc:/network/physical:nwam
online 8:58:14 svc:/network/loopback:default
online 8:58:25 svc:/network/physical:default
online 8:59:32 svc:/system/cryptosvc:default
online 8:59:55 svc:/system/filesystem/local:default
online 9:00:12 svc:/system/utmp:default
online 9:00:12 svc:/system/filesystem/autofs:default
To check, what services depend on ssh, you can use the
-D
switch:
# svcs -D ssh
STATE STIME FMRI
online 9:00:22 svc:/milestone/multi-user-server:default
There is no further service depending on ssh. But the milestone
multi-user-server
depends on ssh. As long the ssh couldnīt started successfully, the
multi-user-server
milestone canīt be reached.
Okay, i finalized my SMF tutorial. Was a good distraction from other events ... Part 1: Introduction Part 2: The foundations of SMF Part 3: Working with SMF Part 4: Developing for SMF Part 5: Conclusion
Tracked: Feb 28, 13:17