How-To: Setup and manage CA Workload Automation System Agent via Service Management Facility (SMF) on Oracle Solaris OS 10 and higher.

Document ID : KB000028437
Last Modified Date : 14/02/2018
Show Technical Document Details

Introduction:

The Oracle Solaris Service Management Facility (SMF) is responsible for managing system and application services, replacing the legacy init scripting start-up mechanism common to other UNIX operating systems.  Starting with Oracle Solaris 10 the Service Management Facility (SMF) can be used to manage the CA Workload Automation System Agent service.

Instructions:

1. Add the project for the CA WA System Agent service.

    my_server# projadd -p 555 -c "Project for CA WA System Agent" cybAgent-WA_AGENT
    my_server# projects -l cybagent-WA_AGENT
    cybagent-WA_AGENT
        projid : 555
        comment: "Project for CA WA System Agent"
        users  : (none)
        groups : (none)
        attribs:

2. Check if the /var/svc/manifest/application/local directory exists. If it does not exist, create it.

    my_server# cd /var/svc/manifest/application
    my_server# mkdir local

3. Creating the SMF Manifest File:

    The SMF manifest file is an XML file that describes our service to SMF, listing information such as the executable to run and any dependencies.
    Add new XML manifest file under /var/svc/manifest/application/local called cybagent-WA_AGENT.xml:

    my_server# ls -l /var/svc/manifest/application/local/
    total 4
    -rw-r--r--   1 root     root        1485 May 16 16:41 cybagent-WA_AGENT.xml

    Example file:

        <?xml version='1.0'?>
        <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>

        <service_bundle type='manifest' name='cybagent-WA_AGENT'>
        <service name='application/local/cybagent-WA_AGENT' type='service' version='0'>

        <!-- Wait for network interfaces to be initialized    -->

        <dependency
                name='network'
                grouping='require_all'
                restart_on='none'
                type='service'>
                <service_fmri value='svc:/milestone/network:default'/>
        </dependency>

        <!-- Wait for all local filesystems to be mounted    -->

        <dependency
                name='filesystem-local'
                grouping='require_all'
                restart_on='none'
                type='service'>
                <service_fmri value='svc:/system/filesystem/local:default'/>
        </dependency>

        <instance name='cybagent-WA_AGENT' enabled='false'>

        <exec_method
                name='start'
                type='method'
                exec='/opt/CA/WorkloadAutomationAE/SystemAgent/WA_AGENT/cybAgent -a'
                timeout_seconds='300'>
        <method_context
                project='cybagent-WA_AGENT'
                resource_pool=':default'
                working_directory=':default'>
        <method_credential
                supp_groups=':default'
                privileges=':default'
                limit_privileges=':default'
                user='root'/>
                <method_environment>
                    <envvar name='HODOR' value='Hodor'/>
                    <envvar name='LD_LIBRARY_PATH' value='/usr/local/lib'/>
                </method_environment>
        </method_context>
        </exec_method>

        <exec_method
                name='stop'
                type='method'
                exec='/opt/CA/WorkloadAutomationAE/SystemAgent/WA_AGENT/cybAgent -s'
                timeout_seconds='300'>
        </exec_method>
        <property_group name='startd' type='framework'>
                <!-- sub-process core dumps shouldn't restart session -->
                <propval name='ignore_error' type='astring' value='core,signal'/>
        </property_group>
        </instance>

        <stability value='Evolving'/>

        </service>
        </service_bundle>

Notes:

  • The method_context and method_credential properties are required in the start method or the service may not load properly.
  • The method_environment elements in the example is optional. It is solely used here to differentiate CA WA System Agent behavior when started as a SMF service
  • The property_group element used in the example is optional. It prevents the CA WA System Agent from restarting when its child process is killed or dumps core.
      

4.  Run the svccfg validate command to check your manifest file for syntax errors. No output indicates that no errors were found:

    my_server# cd /var/svc/manifest/application/local/
    my_server# svccfg validate cybagent-WA_AGENT.xml
    my_server#

5.    Import the manifest as a new service:

    my_server# svccfg import /var/svc/manifest/application/local/cybagent-WA_AGENT.xml
    svccfg: Restarting svc:/system/manifest-import
    The manifest being imported is from a standard location and should be imported with the  command : svcadm restart svc:/system/manifest-import
    svccfg: Successful import.

6.    View current status:

    my_server# svcs -a | grep [c]yb
    disabled       21:12:14 svc:/application/local/cybagent-WA_AGENT:cybagent-WA_AGENT
   
    my_server# svcs -l cybagent-WA_AGENT
    fmri         svc:/application/local/cybagent-WA_AGENT:cybagent-WA_AGENT
    enabled      false
    state        disabled
    next_state   none
    state_time   May 21, 2016 09:12:14 PM EDT
    logfile      /var/svc/log/application-local-cybagent-WA_AGENT:cybagent-WA_AGENT.log
    restarter    svc:/system/svc/restarter:default
    contract_id
    manifest     /var/svc/manifest/application/local/cybagent-WA_AGENT.xml
    dependency   require_all/none svc:/milestone/network:default (online)
    dependency   require_all/none svc:/system/filesystem/local:default (online)

7.    Start the new service:

    my_server# svcadm enable cybAgent-WA_AGENT
    my_server# svcs | grep [c]yb
    online         21:16:29 svc:/application/local/cybagent-WA_AGENT:cybagent-WA_AGENT
    my_server# svcs -l cybagent-WA_AGENT
    fmri         svc:/application/local/cybagent-WA_AGENT:cybagent-WA_AGENT
    enabled      true
    state        online
    next_state   none
    state_time   May 21, 2016 09:16:29 PM EDT
    logfile      /var/svc/log/application-local-cybagent-WA_AGENT:cybagent-WA_AGENT.log
    restarter    svc:/system/svc/restarter:default
    contract_id  2336
    manifest     /var/svc/manifest/application/local/cybagent-WA_AGENT.xml
    dependency   require_all/none svc:/milestone/network:default (online)
    dependency   require_all/none svc:/system/filesystem/local:default (online)

8.    Verify that the service is running within new cybagent-WA_AGENT project:

    my_server# ps -o pid,project,ctid,args -ef | grep [c]ybAgent
    27696 cybagent-WA_AGENT  2336 ./cybAgent.bin -a

The CA WA Sysyem Agent has been setup under SMF. Now let run tests to ensure the System Agent started via SMF project functions well.

Create a job to print the environment:

     Stop the new service:


    my_server# svcadm disable cybAgent-WA_AGENT
    my_server# ps -ef | grep cyb
        root    24  1278   0 17:46:00 pts/3       0:00 grep cyb

    /* ----------------- sun11-env ----------------- */
    insert_job: sun11-env   job_type: CMD
    command: env
    machine: localhost
    owner: autosys@localhost
    permission:
    date_conditions: 0
    std_out_file: "/tmp/$AUTO_JOB_NAME.out"
    alarm_if_fail: 1

Start the agent using legacy /etc/init.d startup script:

    my_server# /etc/init.d/waae_agent-WA_AGENT start

Verify that the agent is NOT running within the cybagent-WA_AGENT project:

    my_server# ps -o pid,project,args -ef | grep cybAgent
    29004 system ./cybAgent.bin -a

Run the test job and check the output (grep -ci will return 1 if found, 0 if not found):

    $ sendevent -E STARTJOB -J sun11-env      
    $ grep -ci 'usr/local/lib' /tmp/sun11-env.out
    0
    $ grep -ci HODOR /tmp/sun11-env.out
    0

Stop the agent using legacy /etc/init.d startup script:

    my_server# /etc/init.d/waae_agent-WA_AGENT stop

Start the agent via SMF:

      my_server# svcadm enable cybAgent

Run the test job and check the output:

    $ sendevent -E STARTJOB -J sun11-env      
    $ grep HODOR /tmp/sun11-env.out
    HODOR=Hodor
    $ grep 'usr/local/lib' /tmp/sun11-env.out
    LD_LIBRARY_PATH=/opt/CA/WorkloadAutomationAE/SystemAgent/WA_AGENT:/opt/CA/SharedComponents/ETPKI/lib:/opt/CA/
    SharedComponents/Csam/SockAdapter/lib:/opt/CA/WorkloadAutomationAE/autosys/lib:/opt/CA/WorkloadAutomationAE/JRE_WA/1.6.0_33/lib:/opt/
    CA/WorkloadAutomationAE/autosys/lib:/opt/CA/SharedComponents/Csam/SockAdapter/lib:/opt/CA/CAlib:/app/oracle/ora11/lib32:/opt/CA/
    WorkloadAutomationAE/SystemAgent/WA_AGENT:/opt/CA/SharedComponents/ETPKI/lib:/opt/CA/SharedComponents/Csam/SockAdapter/
    lib:/opt/CA/WorkloadAutomationAE/autosys/lib:/opt/CA/WorkloadAutomationAE/SystemAgent/WA_AGENT:/opt/CA/WorkloadAutomationAE/
    SystemAgent/WA_AGENT/jre/lib/sparc/client:/opt/CA/WorkloadAutomationAE/SystemAgent/WA_AGENT/jre/lib/sparc:/opt/CA/SharedComponents/
    ETPKI/lib:/opt/CA/SharedComponents/Csam/SockAdapter/lib:/opt/CA/WorkloadAutomationAE/autosys/lib: /usr/local/lib:

Adjusting kernel resource control values for the cybagent-WA_AGENT project.


This section describes adjusting the process.max-sem-nsems (Maximum number of semaphores allowed per semaphore set) for the cybagent-WA_AGENT project.
The following command can be used to increase the process.max-sem-nsems value to 1024 for processes started within the cybagent-WA_AGENT project context:

my_server# projmod -s -K "process.max-sem-nsems=(privileged,1024,deny)" cybagent-WA_AGENT
my_server# projects -l cybagent-WA_AGENT
cybagent-WA_AGENT
        projid : 555
        comment: "Project for CA WA System Agent"
        users  : (none)
        groups : (none)
        attribs: process.max-sem-nsems=(privileged,1024,deny)

Restart the agent:

    my_server# svcadm -v restart cybagent-STANDARD
    Action restart set for svc:/application/local/cybagent-STANDARD:cybagent-STANDARD.
    my_server# tail -f "/var/svc/log/application-local-cybagent-STANDARD:cybagent-STANDARD.log"
    [ May 21 22:04:36 Stopping because service restarting. ]
    [ May 21 22:04:36 Executing stop method ("/opt/CA/WorkloadAutomationAE/SystemAgent/WA_AGENT/cybAgent -s"). ]
    [ May 21 22:04:39 Method "stop" exited with status 0. ]
    [ May 21 22:04:40 Executing start method ("/opt/CA/WorkloadAutomationAE/SystemAgent/WA_AGENT/cybAgent -a"). ]
    [ May 21 22:04:40 Method "start" exited with status 0. ]

The change can be verified by running a test job:

    /* ----------------- sun11-max-sem ----------------- */
     
    insert_job: sun11-max-sem   job_type: CMD
    command: prctl -n process.max-sem-nsems -t privileged $$
    machine: localhost
    owner: autosys@localhost
    permission:
    date_conditions: 0
    std_out_file: "/tmp/$AUTO_JOB_NAME.out"
    alarm_if_fail: 1

Run the job:

    $ sendevent -E STARTJOB -J sun11-max-sem


Checking the output file will show the updated value:

$ cat /tmp/sun11-max-sem.out
process: 6044: /bin/sh /opt/CA/WorkloadAutomationAE/SystemAgent/WA_AGENT/spool/ACE_SC
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
process.max-sem-nsems
        privileged      1.02K       -   deny  

Additional Information:

Introducing the Basics of Service Management Facility (SMF) on Oracle Solaris 11