Implementing an IBM.Application resource

The following example shows how to prepare the lpd printer spooler on a SUSE based Linux® system to be managed by System Automation for Multiplatforms.
  1. Remove the lpd from the default run level of the system. If you want to run this resource as a floating resource on more than one node, you have to check the runlevel on each node.
  2. For the start and stop command of the IBM.Application use the default init scripts shipped with your lp daemon:
    StartCommand: /etc/init.d/lp start
    StopCommand: /etc/init.d/lp stop
  3. For the monitor command we use a simple shell script which checks for the lpd process in the process table:
    File: /root/lpmon
    #!/bin/bash
    
    OPSTATE_ONLINE=1
    OPSTATE_OFFLINE=2
    
    ps -ax | grep -v "grep" | grep "/usr/sbin/lpd" > /dev/null
    if [ $? == 0 ]
    then
      exit $OPSTATE_ONLINE
    else
      exit $OPSTATE_OFFLINE
    fi
    Alternatively you can use the pidmon command shipped with System Automation for Multiplatforms. It basically searches the process table for a given command string. If the command string was found, The RMC OpState is returned. For more information about the pidmon command, see pidmon for a detailed description of this command.
    MonitorCommand: /root/lpmon
    or
    MonitorCommand: /usr/sbin/rsct/bin/pidmon '/usr/sbin/lpd'
  4. In case of a floating resource make sure that all nodes can access the start/stop and monitor command under the same path. Since the lpd is a small and simple application, the default Start- or Stop- and MonitorCommandTimout values (default is 5 seconds) can be used. In order to start lpd via the init scripts provide root as the user name for the IBM.Application.
Now the IBM.Application resource can be defined using the mkrsrc command:
# mkrsrc IBM.Application  \
        Name                  = "line_printer_daemon"  \
        ResourceType          = 1  \
        StartCommand          = "/etc/init.d/lpd start"  \
        StopCommand           = "/etc/init.d/lpd stop"  \
        MonitorCommand        = "/usr/sbin/rsct/bin/pidmon '/usr/sbin/lpd' "  \
        MonitorCommandPeriod  = 15  \
        MonitorCommandTimeout = 5  \
        StartCommandTimeout   = 5  \
        StopCommandTimeout    = 5  \
        UserName              = "root"  \
        RunCommandsSync       = 1  \
        ProtectionMode        = 0  \
        NodeNameList          = "{'node01','node02'}"

This command results in three resources being created: An aggregate resource named line_printer_daemon which can potentially be brought online on nodes node01 and node02 and two constituent resources also named line_printer_daemon, one on node node01 and the other on node node02. If a start request is issued against the aggregate resource, then the Global Resource RM chooses one of the constituents and starts it with the script (or command) specified with the StartCommand attribute.