Akamit Blog

Enterprise sysadmin's blog

  • You are here: 
  • Home
  • Simple template-like smf configuration

Simple template-like smf configuration

Posted on February 10th, 2010

Creation of new services in Solaris 10 is simple. The following example covers configuring and starting snmptrapd daemon. Example may be used as a template for simple services, quick and dirty way.

First, we create xml configuration file, in our case snmptrapd.xml

 
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type="manifest" name="nagios">
 
<service name="site/snmptrapd" type="service" version="1">
 
<create_default_instance enabled="true"/>
<single_instance/>
 
<dependency name="milestone" grouping="require_all" restart_on="none" type="service">
        <service_fmri value="svc:/milestone/multi-user"/>
</dependency>
 
<exec_method type="method" name="start"
exec="/usr/local/sbin/snmptrapd -On -Lsd -p /var/run/snmptrapd.pid -c /usr/local/share/snmp/snmptrapd.conf" timeout_seconds="60"/>
<exec_method type="method" name="stop" exec=":kill"
timeout_seconds="60"/>
 
<stability value="Unstable"/>
 
<template>
        <common_name>
                <loctext xml:lang="C">Net-SNMP Trap Dispatcher</loctext>
        </common_name>
</template>
</service>
</service_bundle>

Next, just do it :)

bash-3.00# svccfg validate snmptrapd.xml
bash-3.00# svccfg import snmptrapd.xml 
bash-3.00# svcs snmptrapd
STATE          STIME    FMRI
online         10:59:13 svc:/site/snmptrapd:default
bash-3.00# ps -ef|grep snmptrapd
    root 19757 25265   0 10:59:14 ?           0:00 /usr/local/sbin/snmptrapd -On -Lsd -p /var/run/snmptrapd.pid -c /usr/local/shar
    root 20417 11157   0 10:59:38 pts/2       0:00 grep snmptrapd

We got it.

Note: If you made a mistake manually editing xml manifest file and got the error

svccfg: couldn't parse document

you can easily find xml file errors with xmllint

xmllint --valid your_manifest.xml

Filed under Solaris |

One Response to “Simple template-like smf configuration”

  1. boofie Says:
    June 28th, 2010 at 12:48 pm

    This helped me to integrate snmptrapd into the SMF/SVC world. Thanks!

Leave a Reply