From:	CSBVAX::MRGATE!@KL.SRI.Com:zar@Hamlet.Caltech.Edu@SMTP 30-JUN-1987 10:22
To:	EVERHART
Subj:	Nanny Source V1.0 2/14

Received: from Hamlet.Caltech.Edu by KL.SRI.COM with TCP; Mon 29 Jun 87 17:31:01-PDT
Date:     Mon, 29 Jun 87 17:29:44 PDT
From:     zar@Hamlet.Caltech.Edu (Dan Zirin)
Message-Id: <870629172944.0m2@Hamlet.Caltech.Edu>
Subject:  Nanny Source V1.0 2/14
To:       info-vax@kl.sri.com

$!------------------------------Cut Here-------------------------
$ chk = "1316534522"
$ required = "nt1.tex"
$ if "''f$search(required)'".eqs."" then write sys$output -
  "File NT1.TEX must exist prior to running this procedure."
$ if "''f$search(required)'".eqs."" then exit %x2c
$ create nt2.tex
$ deck/dollars="ThEgReAtZaR"
\subrub WAKE

The WAKE command will queue a message to be sent to a user or terminal
at a specified date and time. This command is limitted to 25
outstanding messages throughout the system and is anonymous in nature.
The message has a maximum length of 40 bytes. The wake-up call
function accepts three arguments: a terminal name or username, an
absolute time (format: "dd-mmm-yyyy hh:mm:ss.ss"\; fields within the
absolute time may be omitted, but punctuation may not), and a message
preceded by a double quote. Only one space may delimit each argument.
An example would be:

\nobreak
{\tt\qquad WAKE ZAR: 12-MAY-1982 12:00:00.00 "Time to eat lunch.}

or

\nobreak
{\tt\qquad WAKE TTB2: -- ::. "This tests the wake-up call.}

If a username is specified for the first argument, a colon must follow
the name. If the wake-up call expires and the user is not logged on
the system, the message will not be sent. If the user specified is
logged on to more than one terminal, the user with the lowest process
I.D. will receive the wake-up call.

\subrub WCLR

The WCLR command will remove a wake-up call from Nanny's memory. It
requires one argument: the wake-up call identification number (between
10 and 35). Only users with system UICs can cancel a wake-up call
issued by another user.

\subrub WSHOW

The WSHOW command will return wake-up queue information to the
caller's return mailbox (before the actual return status sent). The
command takes no arguments and returns information in the following
format:

\nobreak
{\tt\qquad id own-uic destination date/time}

where `id' is the wake-up call identification number multiplied by
$-1$ (2 bytes), `own-uic' is the UIC of the issuing process (4 bytes),
`destination' is the name of a terminal or user to send the message
(12 bytes), and `date/time' is the system binary time when the call
will be sent (8 bytes). Nanny will send one packet of information (26
bytes) for each wake-up call in its memory after which a dumy packet
with an `id' equal to $-1$ will be sent signifying the end of the
queue. The next message sent will be the Nanny return status code.

\chapter Parameter File

The parameter file is a standard ASCII text file containing input
constants for Nanny. Nanny reads one constant per line from the
parameter file. These constants will set guildelines for Nanny to
follow when determining new priorities, logging off idle terminals,
and performing other functions. The parameter file is read once when
Nanny is started, and each night at midnight. The following
sub-paragraphs will define each constant of the parameter file in
detail. To format a constant for a FORTRAN list-directed I/O
statement, enter the value into the parameter file with no leading
blanks or zeros (leading blanks or zeros are optional when reading
variables with a list-directed I/O statement) and follow the constant
with at least one space (ASCII character 32).

\subrub Process name

This 15 byte character value is Nanny's process name. It should be
different from any other process name on the system.

\subrub System Group UIC Number

This value is the group number portion of the system's UIC (User
Identification Code). This value MUST be represented as an octal 3
digit number and may and may take a value between 1 and 255. While
Nanny is searching for processes to pick on, she will ignore processes
with a UIC group portion less than or equal to this value (for example
if SYSGRP (the value under discussion) is 3 and Nanny comes across a
process with a UIC of [2,1], the process will be ignored. If SYSGRP is
5 and the process's UIC was [7,1], the process will be entered into
Nanny's tables).

\subrub System Account

The system account is the account name (or number) all system
processes are charged to. To find out your system account, log-in as
the user SYSTEM and issue the command ";SHOW PROCESS/QUOTA;". In the
upper-left of the display will be ";Account name: xxxxxxxx;". Any
process that Nanny finds with this account name string will be
disregarded. The value is read from the parameter file with an (A8)
FORTRAN format statement (the first eight bytes are used to determine
the value).

\subrub Cycle Time

The cycle time is the time Nanny waits between process checks. The
value is represented in hundreths of seconds (i.e. 1000 is equal to
10.00 seconds). A good value should be between 30 and 60 seconds
(although values between 10 seconds and 2 minutes are allowed). This
value is read from the parameter file with a list-directed I/O
statement.

\subrub Maximum Idle Time And Maximum Elapsed Time

The maximum idle time is the total elapsed time before a interactive
user is removed from the system. Idle terminals are a waste of
resources and process slots. This value is expressed in Nanny cycle
time (specified by the previous line in the parameter file). The
maximum elapsed time is the maximum allowed elapsed time since login
that a process may exist. If a process exceeds this value, Nanny
forces the process to exit its image. This is good for programs like
KERMIT (in server mode) that trick Nanny into thinking the process
is never idle. This value is also expressed in Nanny cycle time.
These values are read with a list-directed I/O statement.

\subrub Non-idle Time And Non-idle I/O

Non-idle time is the amount of CPU needed to consider a interactive
process not idle. The value is expressed in hundreths of seconds
(i.e. 5 is 0.05 seconds of CPU). A good value would be between 2 and
20 (allowed values are between 0 and 299). Non-idle I/O is the amount
of combined buffered and direct I/O required to be non-idle. These
two values are read with a FORTRAN list-directed I/O statement.

\subrub Maximum memory usage

If the total physical memory usage of all processes monitored by Nanny
exceeds this value, Nanny will start suspending low priority batch
jobs (after which the SWAPPER will swap out the batch job rather than
interactive processes). Typically, this value should be 85% of your
system's total memory capacity. A value of 0 (zero) indicates you
don't want Nanny to suspend processes when memory usage peaks. Values
may be between 2048 pages and 65536 pages (1--32 megabytes). This
value is read from the parameter file with a list-directed I/O statement.

\subrub Low memory usage

If the total physical memory usage of all processes monitored by Nanny
is less than this value and the Nanny has previously suspended
processes, Nanny will resume the highest priority batch job suspended.
This value should be the `Maximum memory usage' minus the average
maximum working set extent of a typical batch job on your system. A
value of 0 (zero) is redundant with the previous parameter. Valid
values are 2048--65536 pages. This value is read from the parameter
file with a list-directed I/O statement.

\subrub Working set purge

This line should read ";YES;" if you want Nanny to purge her working
set after each cycle and ";NO;" if you want her to just purge it each
night at midnight. Purging Nanny's working set for every cycle may
save your system 100 to 150 pages of memory, but pagefaulting will be
high. Nanny will also start automatically purging memory if you have
a maximum memory usage specified (2 lines earlier in the parameter
file) and memory is considered low.

\subrub Free Disk Space

This line contains a single integer used in determining if disk space
is low in the disk check algorithm. A disk is full if the maximum
blocks divided by this number is greater than the free disk blocks.
A good number is 50. This value is read from the parameter file with
a list-directed I/O statement.

\subrub Disk checking

The next line are the device names of disks Nanny will check for low
space and errors. The disk names must be seperated by commas and the
list of names followed by a space (ascii character 32). A maximum of
16 disks can be specified. Nanny checks every 15 minutes if each disk
has less than 1/50 of the total available disk space left. A check for
an increase of 10 error counts on the disk since the last check is
also made. If either of the checks is true, messages are sent to Nanny
specified operator terminals.

\subrub Nanny operators

The next line are the device names of terminals to be designated as
Nanny operator terminals. Some Nanny errors and many Nanny status
messages are sent to these terminals. Included in this list of
terminals is ;OPA0:; (the console). The terminal names must be seperated
by commas and the list of names followed by a space (ascii character
32). A maximum of eight terminals may be specified.

\subrub Command Disable Mask

This value is a bit mask to disable one or more of Nanny's commands.
The value must be expressed in hexidecimal form and have exactly 8
digits. To disable a command, set the bit corresponding to the command
to be disabled. To enable a command, clear the bit. The following
define each bit of the mask and the command the bit represents:

{\obeylines\parindent=2em
Bit 1 -- This bit, if set, will disable the command ADDACC
Bit 2 -- This bit, if set, will disable the command DIE
Bit 3 -- This bit, if set, will disable the command ENTER
Bit 4 -- This bit, if set, will disable the command FORGET
Bit 5 -- This bit, if set, will disable the command FREE
Bit 6 -- This bit, if set, will disable the command GRAB
Bit 7 -- This bit, if set, will disable the command IGNORE
Bit 8 -- This bit, if set, will disable the command KILL
Bit 9 -- This bit, if set, will disable the command LISTEN
Bit 10 -- This bit, if set, will disable the command NEW
Bit 11 -- This bit, if set, will disable the command ODIS
Bit 12 -- This bit, if set, will disable the command OEN
Bit 13 -- This bit, if set, will disable the command QSTART
Bit 14 -- This bit, if set, will disable the command QSTOP
Bit 15 -- This bit, if set, will disable the command REQUEUE
Bit 16 -- This bit, if set, will disable the command RESUME
Bit 17 -- This bit, if set, will disable the command STOP
Bit 18 -- This bit, if set, will disable the command SUSPEND
Bit 19 -- This bit, if set, will disable the command WAKE
Bit 20 -- This bit, if set, will disable the command WCLR
Bit 21 -- This bit, if set, will disable the command WSHOW
Bits 22 through 32 -- unused.\par}

If the disable mask was equal to 00008009 (hex), the commands ADDACC,
FORGET, and RESUME would be disabled. The value FFFFFFFF disables all
commands and 00000000 enables all commands.

\subrub Function Enable Mask

This value is a bit mask to enable one or more of Nanny's functions.
The value must be expressed in hexidecimal form and have 8 digits. To
enable a function, set the bit corresponding to the function to be
enabled. To disable the function, clear the bit. The following defines
each bit of the mask and the function the bit represents:

{\parindent=4em

\item{Bit 1 --}This bit, if set, will allow Nanny to modify batch
process priorities if CPU usage is unfairly distributed.

\item{Bit 2 --}This bit, if set, will allow Nanny to modify detached
process priorities if CPU usage is unfairly distributed.

\item{Bit 3 --}This bit, if set, will allow Nanny to modify
interactive process priorities if CPU usage is unfairly distributed.

\item{Bit 4 --}This bit, if set, will allow Nanny to modify network
process priorities if CPU usage is unfairly distributed.

\item{Bit 5 --}This bit, if set, will allow Nanny to modify subprocess
priorities if CPU usage is unfairly distributed.

\item{Bit 6 --}This bit, if set, will cause duplicate users CPU totals
to be combined when determining CPU distribution. If disabled,
duplicate users will not exist.

\item{Bit 7 --}This bit, if set, will allow Nanny to suspend low
priority processes when memory usage peaks.

\item{Bit 8 --}This bit, if set, will allow Nanny to suspend batch
processes if memory is low.

\item{Bit 9 --}This bit, if set, will allow Nanny to suspend detach
processes if memory is low.

\item{Bit 10 --}This bit, if set, will allow Nanny to suspend interactive
processes if memory is low.

\item{Bit 11 --}This bit, if set, will allow Nanny to suspend network
processes if memory is low.

\item{Bit 12 --}This bit, if set, will allow Nanny to suspend subprocesses
if memory is low.

\item{Bit 13 --}This bit, if set, will allow Nanny to logoff idle
interactive system processes.

\item{Bit 14 --}This bit, if set, will send a logoff warning to idle
processes at 1/2 the total maximum idle time.

\item{Bit 15 --}This bit, if set, will send a logoff warning to idle
processes at approximately 60 seconds before logoff (depending on the
cycle time).

\item{Bit 16 --}This bit, if set, will send a warning to interactive
users with a CPU quota prior to exceeding the CPU quota.

\item{Bit 17 --}Reserved.

\item{Bit 18 --}27 -- Unused.

\item{Bit 28 --}Reserved.

\item{Bit 29 --}Update the system time at daylight savings time (every
six months). It is suggested you leave this off unless you check the
source code for your time zone corrections.

\item{Bit 30 --}Reserved.

\item{Bit 31 --}Causes debugging messages to be sent to the logfile
and NO functions are performed.

\item{Bit 32 --}Causes debugging messages to be sent to the logfile
and execute all desired functions.\par}

The value 3FFFFFFF enables all functions and 00000000 disables all
functions.

\subrub Ignoring users

The next line are the usernames of people the Nanny will entirly
ignore. The usernames must be seperated by commas and the list of
names followed by a space (ascii character 32). A maximum of 32 names
can be specified.

\subrub Ignoring terminals

The next line are the device names of terminals Nanny will ignore
(OPA0: for example). The device names must be specified as ";ddun:;"
or ";_ddun:;" (never use concealed devices!), seperated by commas, and
the list of names followed by a space (ascii character 32). A maximum
of 16 names can be specified.

\chapter Installation

To install Nanny, log-in as the user SYSTEM. Then, create a directory
to store Nanny's files. Ideally, this directory should be protected to
prohibit access to the world (non-system users). A sugested command
would be:

\nobreak
\qquad;$ CREATE/DIR/PROT=(S:RW,O:RW,G,W) SYS$SYSDEVICE:[SYSMGR.NANNY];

Edit the files STARTNAN.COM and NANNY.INP (parameter file). Use BUILD.COM
to create all executables. Add ";@STARTNAN;" to SYS\$MANAGER:SYSTARTUP.COM
and run the program NANNYACP to talk to Nanny while she's running (except
for wake-up calls). Use WAKEACP for sending, deleting, and showing wake-up
calls.

\bye
ThEgReAtZaR
$ checksum nt2.tex
$ if chk.nes.checksum$checksum then write sys$output -
  "NT2.TEX didn't pass checksum. File may be corrupted."
$ if chk.nes.checksum$checksum then exit %x2c
$ copy/log nt1.tex+nt2.tex nanny.tex
$ if $status then delete/log nt1.tex;,nt2.tex;
$ exit
