Managing System Services


Most of the basic software services available on UNIX systems, such as the print service, networking services, or user/group management, require some form of administration. Two important areas of administrative system services described here are the Service Access Facility and accounting utilities. The Service Access Facility came about to help standardize how services available to terminals, networks, and other remote devices are managed on each system and across different packages of software services. Accounting utilities are used to track system usage and, optionally charge users for that usage.

Service Access Facility

The Service Access Facility (SAF) was designed to provide a unified method for monitoring ports on a UNIX system and providing services that are requested from those ports.

A port is the physical point at which a peripheral device, such as a terminal or a network, is connected to the computer. The job of a port monitor is to accept requests that come into the computer from the peripherals and see that the requests are handled.

The port monitor that is used most frequently is called ttymon. To see if this or other port monitors are installed on your system, you can use the sacadm command. Type the following command to see results like these:

 # sacadm −1 PMTAG    PMTYPE   FLGS RCNT STATUS       COMMAND ttymon1  ttymon   -    2    ENABLED  /usr/lib/saf/ttymon #ttymon1 ttymon3  ttymon   -    2    ENABLED  /usr/lib/saf/ttymon #ttymon3

This example shows that there are two instances of ttymon on the system.

Terminal Port Monitor

The ttymon port monitor listens for requests from terminals to log in to the system. In the previous example, each instance of a ttymon port monitor command (/usr/lib/saf/ttymon) has a separate tag identifying it (ttymon1 and ttymon3) and is started separately by the Service Access Controller (sacadm daemon) when the system enters a multiuser state.

Each port monitor instance will run continuously, listening for requests from the ports it is monitoring and starting up processes to provide a service when requested. To see what services are provided and what ports are being monitored by a particular port monitor instance, type

 # pmadm −1 -p ttymon1 PMTAG   PMTYPE SVCTAG FLGS ID <PMSPECIFIC> ttymon1 ttymon 11     u    root /dev/term/11- - /usr/bin/login - 9600 - login:-tvi925 ttymon1 ttymon 12     u    root /dev/term/12 - - /usr/bin/login - 9600 - login:  -tvi925 ttymon1 ttymon 13     u    root /dev/term/13 - - /usr/bin/login - 9600 - login:  -tvi925 ttymon1 ttymon 14     u    root /dev/term/14 - - /usr/bin/login - 9600 - login:  -tvi925

The ttymon1 port monitor monitors all four ports on the ports board in slot 1 on the computer (/dev/term/11 through /dev/term/14). The service registered with ttymon1 is the login service (/bin/login). When a user turns on the terminal connected to port 11, the user receives the “login:” prompt and terminal line settings are defined by the 9600 entry in the /etc/ttydefs file.

The ttymon port monitor replaces the previous getty and uugetty commands from earlier versions of UNIX. Unlike the getty and uugetty commands, a single ttymon monitors several ports, so you do not need a separate process running for each port. Also, ttymon lets you configure the types of services you can run on each terminal line, using pmadm -a. These can include, for example, adding STREAMS modules to STREAMS drivers and configuring line disciplines for each port.

Service Access Controller

The process that starts SAF rolling is called the Service Access Controller. By default, it is started in each system from this line in the /etc/inittab file:

 sc:234:respawn:/usr/lib/saf/sac -t 300

The sac process starts when you enter the multiuser state; it reads the SAF administrative file to see which listener processes to start (see the sacadm 1 command shown previously for an example of the contents of this file) and starts those processes.

Configuring Port Monitors and Services

The SAF provides a robust set of commands and files for adding, modifying, removing, and tracking port monitors and services. These SAF features enable you to create your own port monitors and add services to suit your needs. Since creating port monitors and device drivers can be quite complex, you should read the network administration sections in your administration manual to help create your own SAF facilities.

Configuration Scripts   Typically three types of configuration scripts can be created to customize the environment for your system, a particular port monitor, or a particular service, respectively:

  • One per system   The /etc/saf/_sysconfig configuration script is delivered empty It is interpreted when the sac process is started and is used for all port monitors on the system.

  • One per port monitor   A separate /etc/saf/pmtag/_config file can be created for each port monitor (replace pmtag with the name of the port monitor) to define its environment.

  • One per service   A separate doconfig file can be created for each service to override the defaults set by other configuration scripts. For example, you could push different STREAMS modules onto a STREAM.

Administrative File   There is one administrative file per port monitor. You can view the contents of the files using the pmadm 1 command, as shown earlier.

Services   You can manipulate services by

  • Adding a service to a port monitor (pmadm -a)

  • Enabling a service for a port monitor (pmadm -e)

  • Disabling a service for a port monitor (pmadm -d)

  • Removing a service from a port monitor (pmadm -r)

Port Monitors   You can manipulate port monitors by

  • Adding a port monitor (sacadm -a)

  • Enabling a port monitor (sacadm -e)

  • Disabling a port monitor (sacadm -d)

  • Starting a port monitor (sacadm -s)

  • Stopping a port monitor (sacadm -k)

  • Requesting port monitor information (sacadm 1)

  • Removing a port monitor (sacadm -r)

Other options enable you to perform additional administration on the port monitor. See your system administration and network administration manuals for these on your system.

Accounting

Accounting is a set of add-on utilities available on many computers running UNIX. Its primary value is that it provides a means for tracking usage of your system and charging customers for that usage.

The basic steps that the process accounting subsystem goes through are

  • Collecting raw data   You can select how often the data are collected.

  • Once-a-day reports   You can produce cumulative summary and daily reports every day using the runacct command.

  • Once-a-month reports   You can produce cumulative summary and monthly reports once a month (or more often) using the monacct command.

The kind of data you can collect includes

  • How long was a user logged in?

  • How much were terminal lines used?

  • How often did the system reboot?

  • How often is process accounting started/stopped?

  • How many files does each user have on disk (including the number of blocks used by the user’s files)?

For each process on the system, you can see

  • Who ran it (UID/GID)?

  • How long did it run (the time it started and the real time that elapsed until it completed)?

  • How much CPU time did it use (both user and system CPU time)?

  • How much memory was used?

  • What commands were run?

  • What was the controlling terminal?

Based on the data collected, you set charges and bill for these services. You can also define extra charges for special services you provide (such as restoring deleted files).

Setting Up Accounting

Since process accounting is very complex and powerful, it is not appropriate to describe all ways of gathering data and producing reports. Instead, an example of the process will be given.

To collect process accounting data automatically, you should have a file named /var/spool/ cron/crontabs/adm. The following are recommended entries for the adm file:

 0   *  *   *   *   /usr/lib/acct/ckpacct 30  2  *   *   *   /usr/lib/acct/runacct 2> /var/adm/acct/log 30  9  *   5   *   /usr/lib/acct/monacct

The preceding entries in the adm file will run ckpacct every hour to check that process accounting files do not exceed 1,000 blocks. It will run runacct every morning at 2:30 A.M. to collect daily process accounting information. It will run monacct at 9:30 A.M. on the fifth day of every month to collect monthly accounting information. You should also have the following entry in the /var/spool/cron/crontabs/root file:

 30    22    *         *       4     /usr/Lib/acct/dodisk

This will run the disk accounting functions at 10:30 P.M. on the fourth day of every month.

Samples of the output from process accounting are shown in the following. The Daily Report shows terminal activity over the duration of the reporting period:

 Jul 16 02:30 2006  DAILY REPORT FOR trigger Page 1 from Fri Jul 14 02:31:22 2006 to   Sat Jul 15 02:30:25 2006 1       runacct 1       acctcon TOTAL DURATION IS 1440 MINUTES LINE            MINUTES PERCENT # SESS  # ON    # OFF term/11         25      3       7       4       4 term/12         157     16      6       3       3 TOTALS          183     --     13       7       7      .      .      .

The preceding report shows the duration of the reporting period, the total duration of time in which the system was in multiuser mode, and the time each terminal was active. It then goes on to show other records that were written to the /var/adm/wtmp accounting file. The Daily Usage Report here (Figure 14–1) shows system usage on a per-user basis.

image from book

 Mar 16 02:30 1999  DAILY USAGE REPORT FOR trigger Page 1        LOGIN  CPU (MINS)   KCORE-MINS   CONNEC (MINS)  DISK    # OF  # OF  # DISK   FEE UID  NAME  PRIME NPRIME PRIME NPRIME  PRIME  NPRIME  BLOCKS  PROCS  SESS  SAMPLES 0    TOTAL  9      7     2      16     131      51      0     1114    13     0     0 0    root   7      6     1      11       0       0      0      519     0     0     0 3    sys    0      0     0       0       0       0      0       00     0     0     0 4    adm    0      0     0       1       0       0      0       00     0     0     0 5    uucp   0      0     0       0       0       0      0       00     0     0     0 999  mcn    2      1     1       2     111      37      0      269     1     0     0 7987 gwn    0      0     0       0       0       0      0       00     0     0     0

image from book

Figure 14–1: The Daily Usage Report

The report shows, for each user, the user ID and login name, the minutes of CPU time consumed (prime and nonprime time), the amount of core memory consumed (prime and nonprime time), the time connected to the system (prime and nonprime time), the disk blocks consumed, the number of processes invoked, the number of times the user logged in, how many times the disk sample was run, and the fee charged against the user (if any).

Process Scheduling

Chapter 11 gives you an overview of process scheduling and describes how users can change processor priorities temporarily on a running system. This section describes how an administrator can change processor priorities on a permanent basis.

Note 

Most administrators will have no need to change the default process scheduling on the average time-sharing configuration. Process scheduling tools were intended to be used primarily to tune computers running specific applications that needed real-time types of processing, such as robotics or life-support systems. Changing processor priorities can result in severe performance problems if not done carefully.

Process Scheduling Parameters

Several operating system tunable parameters affect the process scheduling on your system. The following list describes the location of each tunable parameter and the default value, and it gives a short description of how the value is used.

The examples given are specific to the configuration files for a particular computer running some UNIX variants. You can change tunable parameter values by editing the file (using any text editor) and rebuilding the system. Other variants do not use the three files that follow but use a form of them with the same intent of managing tunable parameters.

The /etc/master.d/kernel File

This file contains all of the kernel configuration parameters. The following are those parameters specific to process scheduling.

  • MAXCLSYSPRI (default=99) This parameter sets the maximum global priority of processes in the system class. The priority cannot be set below 39, to ensure that system processes get higher priority than user processes.

  • INITCLASS (default=TS) This parameter sets the class at which system initialization processes will run (i.e., those started by the init process). Setting this to TS (time sharing) ensures that all login shells will be run in time-sharing mode.

  • SYS_NAME (default=SYS) This parameter identifies the name of the system scheduler class.

The /etc/master.d/ts File

This file contains parameters relating to the process scheduling time-sharing class.

  • TSMAXUPRI (default=20) This parameter sets the range of priority in which user processes can run. With a default of 20, users can change their priorities from –20 to +20. (See the description of the priocntl command in Chapter 11.)

  • ts_dptbl parameter table This table contains the values that are used to manage timesharing processes. It is built into the kernel automatically There are six columns in the ts_dptbl file: The glbpri column contains the priorities that determine when a process runs; the qntm column contains the amount of time given to a process with the given priority The other columns handle processes that sleep (i.e., are inactive while waiting for something to occur) and change priorities.

  • ts_kmdpris parameter table This table contains the values that are used to manage sleeping time-sharing processes. It is built into the kernel automatically The table assigns priorities to processes that are sleeping. Priorities are based on why the processes are sleeping (e.g., a process waiting for system resources would get higher priority than one waiting for input from another process).

The /etc/master.d/rt File

This file controls process scheduling relating to the real-time class. Note that some UNIX variants (e.g., Solaris 10) do not support the real-time class.

  • NAMERT (default=RT) This parameter identifies the name of the real-time scheduler class.

  • rt_dptbl parameter table This table contains the values that are used to manage realtime processes. It is only built into the kernel if the /etc/system file contains the line “INCLUDE:RT.” Two columns are in the rt_dptbl file: the rt_glbpri column contains the priorities that determine when a process runs and the rt_qntm column contains the amount of time given to a process with the given priority

Display Scheduler Parameters

You can display the current scheduler table parameters on Solaris using the dispadmin command. To display the classes that are configured on your system, type the following command to see the typical output shown:

 dispadmin −1 CONFIGURED CLASSES ================== SYS     (System Class) TS       (Time Sharing)   FX     (Fixed Priority) IA      (Interactive)

To display the current scheduler parameters for the time-sharing class, type the following command to see a report like the one shown:

 dispadmin -c TS -g # Time Sharing Dispatcher Configuration RES=1000 # ts_quantum ts_tqexp ts_slpret ts_maxwaitts_lwait PRIORITY LEVEL     1000        0       10          5       10       #     0     1000        0       11          5       11       #     1     1000        1       12          5       12       #     2     1000        1       13          5       13       #     3     1000        2       14          5       14       #     4     1000        2       15          5       15       #     5     1000        3       16          5       16       #     6     1000        3       17          5       17       #     7     1000        4       18          5       18       #     8     1000        4       19          5       19       #     9      800        5       20          5       20       #    10      800        5       21          5       21       #    11      800        6       22          5       22       #    12      .      .      .

Under Solaris 10, you could replace TS with FX to see fixed-priority parameters, IA to see interactive parameters, or SYS to see system parameters.




UNIX. The Complete Reference
UNIX: The Complete Reference, Second Edition (Complete Reference Series)
ISBN: 0072263369
EAN: 2147483647
Year: 2006
Pages: 316

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net