Sunday, 20 August 2017

AIX System Resource Controller (SRC) Overview

The System Resource Controller (SRC) provides a set of commands and subroutines to make it easier for the system admins/users to create and control subsystems.

What is Subsystem?
A subsystem is any program or process or set of programs or processes that is usually capable of operating independently or with a controlling system.A subsystem is designed as a unit to provide a designated function.

Features of  System Resource Controller (SRC):
  • Subsystem is a set of related programs designed to perform one particular function.
  • The subsystems can be sub divided into subservers(daemons).
  • SRC helps you to manage the whole subsystems and their respective subservers by creating subsystem groups.
  • SRC allows us to stop, start, trace, list and refresh subsystems and subservers (daemons).
  • SRC is started during the system initialization with a record for /usr/bin/srcmstr daemon in the /etc/inittab file.
Basic Components of SRC:

There are three basic components of SRC
Subgroup –> SubSystem –> SubServer (daemons)

A subserver is a program or process that belongs to a subsystem called as deamons as well. 
Eg: sshd,ftpd 

A subsystem can have multiple subservers and is responsible for starting, stopping, and providing status of subservers.
Eg: gated,inetd,named etc.,

Subsystem Group
A subsystem group is a group of any specified subsystems. Grouping subsystems together allows the control of several subsystems at one time. 
Eg: TCP/IP,  Network Information System (NIS), and Network File Systems (NFS).

In the above example 
Subsystem group "tcp/ip" under which there is subsystem "inetd" under which there is a subserver called "ftp" here.

Subsystem Operational  Commands: 

srcmstr Deamon starts the System Resource Controller
startsrc Starts a subsystem, subsystem group, or subserver
stopsrc Stops a subsystem, subsystem group, or subserver
refresh Refreshes a subsystem
traceson  Turns on tracing of a subsystem, a group of subsystems, or a subserver
tracesoff Turns off tracing of a subsystem, a group of subsystems, or a subserver
lssrc  Gets status on a subsystem.

Command Description
lssrc -a  To list the status of all subsystems
lssrc -h node1-a To list the status of all subsystems  on foreign host node1
lssrc -s inetd   To list the status of the subsystem inetd
lssrc -g tcpip   To get the status of the subsystem group tcpip 
startsrc -s inetd  To start the subsystem inetd
startsrc -g tcpip  To start the subsystem group tcpip
stopsrc -s inetd  To stop the subsystem inetd (If process is under srcmstr. ie PPID of process=PID of srcmstr)
stopsrc -g tcpip   To stop the subsystem group tcpip
refresh -s nfsd    To refresh nfsd subsystem
refresh -g tcpip   To refresh tcpip subsystem group
lssrc -p [PID of process]To get  status of the subsystem by process ID 
kill  [PID of process] To kill a process that not started by srcmstr 
Subsystem Config Commands:

mkssy ==> Create Subsystem
chssys  ==> Chnage or modify Subsystem Parameters
rmssys  ==> Remove Subsystem
# mkssys -p /usr/sbin/sshd \   /* Absolute path to the subsystem executable
                                  program. */
         -s sshd_adm \         /* Name that uniquely identifies the subsys. */
         -u 0 \                /* User id for the subsystem. */
         -a "-D -f /etc/ssh/sshd_config_adm" \   /* Arguments that must be
                                                    passed to the command. */
         -e /dev/console \     /* Where the subsystem standard error data is
                                  placed. */
         -i /dev/console \     /* Where the subsys. standard input is routed. */
         -o /dev/console \     /* Where the subsys. standard output is placed. */
         -R \                  /* Subsystem is restarted if the subsystem stops
                                  abnormally. */
         -Q \                  /* Multiple instances of the subsystem are not
                                  allowed to run at the same time. */
         -S \                  /* Subsystem uses the signals communication
                                  method. */
         -f 9 \                /* Signal sent to the subsystem when a forced
                                  stop of the subsystem is requested. */
         -n 15 \               /* Signal sent to the subsystem when a normal
                                  stop of the subsystem is requested. */
         -E 20 \               /* Execution priority of the subsystem. */
         -G ssh \              /* Subsystem belongs to the group specified. */
         -d \                  /* Inactive subsystems are displayed when the
                                  lssrc -a command request is made. */
         -w 20                 /* Time, in seconds, allowed to elapse between a
                                  stop cancel (SIGTERM) signal and a subsequent
                                  SIGKILL signal. */
Check the service's configuration:

# lssrc -S -s sshd_adm                
sshd_adm::-D -f /etc/ssh/sshd_config_adm:/usr/sbin/sshd:0:0:/dev/console:/dev/console:/dev/console:-R:-Q:-S:0:0:\

# odmget -q subsysname=sshd_adm SRCsubsys

        subsysname = "sshd_adm"
        synonym = ""
        cmdargs = "-D -f /etc/ssh/sshd_config_adm"
        path = "/usr/sbin/sshd"
        uid = 0
        auditid = 0
        standin = "/dev/console"
        standout = "/dev/console"
        standerr = "/dev/console"
        action = 1
        multi = 0
        contact = 2
        svrkey = 0
        svrmtype = 0
        priority = 20
        signorm = 15
        sigforce = 9
        display = 1
        waittime = 20
        grpname = "ssh"