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. - Remove the
lpdfrom 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. - For the start and stop command of the
IBM.Applicationuse the default init scripts shipped with your lp daemon:StartCommand: /etc/init.d/lp start StopCommand: /etc/init.d/lp stop - For the monitor command we use a simple shell script which checks for the
lpdprocess in the process table:
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 RMCFile: /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 fiOpStateis 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' - 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
MonitorCommandTimoutvalues (default is 5 seconds) can be used. In order to start lpd via the init scripts provide root as the user name for theIBM.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.