Create your own SMF goal service

Yesterday I demonstrated goal services to you with the build-in goal services. But can you do if two important applications are running under control of a single SMF and you want to monitor them independently. Well, the answer is simple: Create your own goal service.

At first you have to create a plain standard SMF service. Easiest way is to use svcbundle

root@batou:~# svcbundle -i -s service-name=milestone/yetanothergoalservice -s start-method=":true“

A goal service should never start things. Thus in order to create such a service just use :true as a start method. Right after the command has executed (you may see an error message), you will see a running SMF service.

root@batou:~# svcs svc:/milestone/yetanothergoalservice:default
STATE          STIME      FMRI
online         21:06:13   svc:/milestone/yetanothergoalservice:default

But this service isn’t an goal service already. You have to set the general/goal-service to true as well.

root@batou:~# svcadm disable svc:/milestone/yetanothergoalservice:default
root@batou:~# svccfg -s svc:/milestone/yetanothergoalservice:default setprop general/goal-service=true
root@batou:~# svcadm enable svc:/milestone/yetanothergoalservice:default

Okay, now we can use this new goal service. Like with the default goal service you can use the goals subcommand, however you have to specify the goal service you want to configure. Without the -g it would modify the default service.

I’m a little bit lazy, I will just use sendmail and apache24 in my goal service. Thus the goal service will monitor both. Obviously this makes not much sense, as the other goal service monitors it as well, however

root@batou:~# svcadm goals -g svc:/milestone/yetanothergoalservice:default apache24 sendmail

Now we check the the goal service functionality by disabling one of the monitored services.

root@batou:~# svcadm disable apache24
root@batou:~# svcs yetanothergoalservice
STATE          STIME      FMRI
maintenance    21:12:47   svc:/milestone/yetanothergoalservice:default

Let’s see if this information is propagated as well into the Fault Management Architecture

March 26 21:12:47.8549 925ceff4-354f-4217-871c-95e1fbcb5c1f FMD-8000-9L Isolated
  100%  defect.sunos.smf.svc.maintenance

        Problem in: svc:///milestone/yetanothergoalservice:default
           Affects: svc:///milestone/yetanothergoalservice:default
               FRU: -
      FRU Location: -

Your first goal service up and running.