$VER: Sysmon.doc 0.4 (9.5.96) © 1995-1996 by Etienne Vogt (Etienne.Vogt@obspm.fr) INTRODUCTION Sysmon is a system monitoring package based on a shared library and Shell based support commands. It requires AmigaOS 2.04 or higher. Main features are : - Precise CPU usage timing for all tasks with very low overhead. - System message logging daemon like UNIX syslogd (useful for debugging). - Safe System shutdown script (useful for BBS's and networked machines). This is a public *** BETA *** release, so it's not a finished product. Sysmon now works on the 68060 (Thanks to Terrance Richard Boyes for testing) at least with the 68060.library from Phase 5. If you find any bug, please report it back to me. My E-Mail address is listed in this file. Sysmon has been successfully tested on the following configurations : - A500 68000 ECS, 1 Mb Chip 1.5 Mb Slow 2 Mb Fast , OS 3.1 20 Mb IDE-XT + 170 Mb SCSI HDs - A3000 68030 ECS, 2 Mb Chip 8 Mb Fast , OS 3.1 100 Mb + 1 Gb SCSI HDs - A500 68040(PP&S) ECS , 1 Mb Chip 2 Mb Fast16 8 Mb Fast32 , OS 2.04 50 Mb SCSI HD - A4000 68040 AGA, 2 Mb Chip 8 Mb Fast , OS 3.0 250 Mb IDE + 1 Gb SCSI-2 HDs - A1200 68EC020 AGA, 2 Mb Chip 5 Mb Fast , OS 3.0 60 Mb IDE + 100 Mb SCSI HDs This software is intended for experienced users. In particular, there are no GUI tools available yet; so if you are a mouse-maniac user that don't like typing Shell commands or editing ASCII configuration files, I'm afraid that this software is not for you. DISTRIBUTION Sysmon is Freely Distributable Copyrighted Software (FreeWare). It may be freely copied as long as it is kept intact. However, the support commands that do not require sysmon.library may be distributed separately. (see the OTHER COMMANDS section below). It may not be sold under any guise. I don't want others to make money out of my work. Distribution MUST BE FREE, except for media costs plus a token amount covering only shipping and handling. Authors of FreeWare may freely use the sysmon.library in their software. Authors of ShareWare may use the library at the cost of giving me a free registration (this includes upgrades as long as the software continues to use the library). Authors of commercial packages MUST obtain a written license agreement from me before selling software using the library. Fred Fish is explicitely allowed to include this package in his AmigaLibDisk collection (either on floppy disk or on CD-ROM), as is the aminet group for their Aminet CD-ROM. Usage and Distribution of Sysmon and sysmon.library is STRICTLY FORBIDDEN to: - Anyone affiliated with the french society FRANCE-FESTIVAL-DISTRIBUTION (especially Serge Hammouche). - Anyone affiliated with MICROSOFT CORPORATION or its subsidiaries. DISCLAIMER This software is provided "as is" without any warranty, either expressed or implied. By using this software, you accept the entire risk as to its quality and performance. Especially, as this software patches some private system functions, it can not be guaranteed that it will continue to work with future operating system versions, and it will certainly not work as is on a PowerPC based Amiga. CONTACTING THE AUTHOR I can be reached by E-Mail at the following address : Etienne.Vogt@obspm.fr Bug reports must include the complete hardware and software configuration, including any third party software that was running in the background. The Output from 'ShowConfig' and 'ShowSys' may be useful. If you have any question or suggestion about this software, feel free to send me E-Mail. INSTALLATION - Copy the file 'libs/sysmon.library' to your LIBS: directory. - Copy the support commands in the 'c/' sub-directory to C: . - Copy the files in the 's/' sub-directory to S: . - You may also copy the files in the 'docs/' and 'include/' subdirectories wherever you like. - Load S:Startup-Sequence in your favorite editor. Locate the line with 'SetPatch' in it. Add a line just after it saying 'C:StartSM'. Save the modified Startup-Sequence. If you have an accelerator board that is configured via a command in your Startup-Sequence, make sure to put the 'StartSM' command after any command used to configure your CPU or memory. - Wait for disk activity to finish, then reboot your Amiga. Sysmon will then be started with the default configuration. - After bootup, open a shell and type 'showsys'. You should then get a listing of all tasks in the system, like this : AmigaOS 40.63 05-Nov-95 19:34:37 UpTime : 0 04:45:06 Address Name State Pri CPU [68000] Type 0020F700 DH0 WAIT 10 0 00:00:20.761 Process 0029E200 Workbench (Workbench) WAIT 1 0 00:01:38.599 Cli 4 0021B918 DH2 WAIT 10 0 00:00:37.442 Process 002A7628 Active WAIT 21 0 00:00:31.385 Process 00267930 « ConClip » WAIT 0 0 00:00:00.002 Process 00217138 SH0 WAIT 10 0 00:00:02.803 Process 00223A3C trackdisk.device WAIT 5 0 00:00:25.848 Task 0020703A input.device WAIT 20 0 00:22:01.744 Task 002B9C40 Clock WAIT 0 0 00:04:03.565 Process 00254248 « IPrefs » WAIT 0 0 00:00:03.761 Process 002AFE50 Spliner WAIT 0 0 00:00:03.037 Process 0022C758 ramlib WAIT 0 0 00:00:00.762 Process 00228458 DH3 WAIT 10 0 00:00:02.828 Process 0020B858 scsi.device WAIT 11 0 00:00:15.128 Task 00214C70 DF0 WAIT 10 0 00:00:04.401 Process 00221570 DF1 WAIT 10 0 00:00:03.449 Process 00246570 ErrorLog.daemon (ErrorLogD) WAIT 6 0 00:00:23.148 Cli 0 0026A978 RexxMaster WAIT 4 0 00:00:00.399 Cli 0 00297E78 CON WAIT 5 0 00:02:08.857 Process 002B1D78 ClickToFront WAIT 21 0 00:00:00.194 Process 0020DA8C trackdisk.device WAIT 5 0 00:00:35.705 Task 00241A88 VD0 WAIT 10 0 00:00:35.972 Process 0020C490 A590 SCSI handler WAIT 12 0 00:00:24.504 Task 002B5890 AppMenuCx WAIT 0 0 00:00:00.198 Process 00285C98 Background CLI (Snap) WAIT 1 0 00:00:13.573 Cli 2 0023A4A0 RAM WAIT 10 0 00:00:02.588 Process 002A49A0 AmigaEyes READY -1 0 00:10:44.476 Process 00223CB0 DH1 WAIT 10 0 00:00:07.265 Process 00296AD0 AmigaShell_3 (showsys) RUN 0 0 00:06:02.147 Cli 3 002339D8 Sysmon.server WAIT 3 0 00:00:00.106 Process 0020B2F8 console.device WAIT 5 0 00:00:00.400 Task CONFIGURATION The configuration file is used to set up various parameters of operations. It is usually located in the S: directory. If you want to put it somewhere else, you have to add the complete path to the file as argument to the StartSM command in the Startup-Sequence. The configuration parameters currently available are : - LOGFILE : This parameters sets up the name of the file used for the system message logging facility. Currently all messages go into a single file. You should place this file on a hard disk partition with sufficent free space available. The default file name is S:Sysmon.log - LOGWINDOW : This sets up the window specifications for syslog messages that are serious enough to be displayed in a window. You can also redirect them somewhere else like an AUX: serial terminal or even a file, but you must be aware that this 'file' is not closed after each message like the log file is. The default window specification is CON:20/50/600/80/SysLog/AUTO/CLOSE/WAIT - FILEPRI : Sets up the higher priority level of messages that will be logged in the log file; low values mean high severity like in UNIX (See the sysmon.h include file for the definitions). The default value is 7 (LOG_DEBUG) which means that all messages will be logged. - WINPRI : This is the same as the previous parameter but for the window logging. The default value is 4 (LOG_WARN), meaning that messages of class warning or more severe will be logged. - CONPRI : Sets up the higher priority level for logging to a serial port terminal (console). The logging is done via the smKPrintf() function which is not system friendly (accesses the serial port hardware directly). If you have something else than a terminal attached to your serial port (ex. a modem), you should leave this parameter to its default value of 0 (LOG_EMERG). This means that only system panic messages will be logged; these can not be disabled but are not currently used by the sysmon package (and should never be used by application or user programs). - LOGBUFFERS : This sets up the number of preallocated buffers to store syslog messages before they can be logged to disk and/or window by the Sysmon.server process. If you have a program that generates lots of messages and you think you are losing some of them, you should increase the number of buffers. The default value is 5. - STAMPPERIOD : Sets the time period in minutes between time stamping messages written to the logfile at priority level 6 (LOG_INFO). You can disable these messages by specifying a stamp period or 0. Default value is 60 minutes (one message every hour). - IDLELED : This enables you to monitor the CPU activity using the power LED. If IDLELED is set to YES, the system will dim the power LED when the CPU is idle and brighten it when a task is running. This can however cause interferences with audio output as the power LED also controls the low pass audio filter. Default value is NO. SUPPORT COMMANDS These support commands should be installed in your C: directory. They can only be used from the Shell. - StartSM: This command loads and initializes the sysmon.library and starts the Sysmon.server syslog process. It should be called from your Startup-Sequence right after the SetPatch command. Usage : StartSM CONF=CONFIGFILE CONFIGFILE : Specifies the path to the configuration file described before. It defaults to S:Sysmon.config - ShowSys: This command will give a list of all the tasks in the system with their address, name, state, priority, cumulated CPU usage and type. An example of the display generated by this command was given in the INSTALLATION section. Usage : ShowSys FULL/S FULL: This switch causes the command to also display the allocated stack size, signals usage, task flags and total dispatch count for each task. - Timer: This command runs another command as a subprocess and times the command execution. It then reports the elapsed time and the CPU time used by the command. It is similar to the UNIX 'time' command. Usage : Timer COMMAND/F/A COMMAND : The command that will be executed and timed. - Freeze: This command will suspend a given task by putting it in the FROZEN state. It uses the sysmon.library function smFreeze(). (see sysmon_lib.doc for further details). This can be useful to stop a looping task that is eating away all the CPU time available. Be careful though to not freeze system tasks or the whole machine may hang. The frozen task can be resurrected by the UnFreeze command. Usage : Freeze TASK,ADDR=ADDRESS/K TASK: The name of the task to be frozen. If it is not unique, the first task found in the system lists will be frozen. ADDRESS: You can alternatively to the name, specify the hexadecimal address of the task as displayed by ShowSys. - UnFreeze: This command will bring a previously frozen task back to life. Is uses the sysmon.library function smUnFreeze(). (see sysmon_lib.doc for further details). Usage : UnFreeze TASK,ADDR=ADDRESS/K TASK: The name of the task to be unfrozen. If it is not unique, the first task found in the frozen list will be unfrozen. ADDRESS: You can alternatively to the name, specify the hexadecimal address of the task as displayed by ShowSys. - Halt: This command will halt the system by displaying a guru-like deadend alert. It uses the sysmon.library function smHalt(). (see sysmon_lib.doc for further details). It is used by the shutdown script and is not intended to be called directly. Usage : Halt REBOOT/S,REKICK/S REBOOT : This switch bypasses the alert display and causes the system to reboot immediately. REKICK : This switch forces MMU-softkicked machines like the early A3000s to reload the kickstart file when rebooting. - SysLog: This command can be used to generate syslog messages from the Shell. Usage : MESSAGE/A,LEVEL/K/N,NOHEAD/S,NOWIN/S,NOFILE/S MESSAGE : The message text body which must be inserted between double quotes if it contains spaces. The message length is limited to SM_MAXLOGCHARS bytes (currently 256). LEVEL : The priority level of the message in numeric form (see sysmon.h) Do not use the LOG_EMERG (0) and LOG_ALERT (1) values without good reasons. NOHEAD : This switch suppresses the header that is normally prepended to each message. This allows you to split a single long message in smaller parts. NOWIN : Do not log this message to the log window regardless of priority settings. NOFILE : Do not log this message to the log file regardless of priority settings. OTHER COMMANDS These commands do not depend on sysmon.library and thus are not to be considered part of the sysmon package, so they can be distributed separately. I wrote them for my own usage and decided to distribute them with sysmon because they may be useful to the Amiga community. The UnMount command is also used by the shutdown script. - RunBackground: This command starts a command as a detached process. Unlike the standard 'run' command, it automatically redirects the standard input and output to NIL: so the shell can be closed and it also allows you to specify options such as the new process priority and stack size. Usage : STACK=STACKSIZE/K/N,PRI=PRIORITY/K/N,DELAY/K/N,NOREQ/S,COMMAND/F/A STACKSIZE : The size of the stack to allocate for the new process. Defaults to the current shell stack size. PRIORITY : The priority to give to the new process. Defaults to the current process priority. DELAY : Optional delay after the new process startup and before the command returns. This can be used to avoid concurrent accesses to a disk. NOREQ : This switch will disable DOS requesters for the newly created process. Unfortunately, software error requesters are also disabled, so a CPU trap will cause an immediate guru reboot. COMMAND : The command to be executed. - UnMount: This command will try to unmount a DOS device by sending it an ACTION_DIE packet and optionally an ACTION_INHIBIT packet if the ACTION_DIE fails. It is used by the shutdown script to stop filesystem accesses before halting the system. Note that very few filesystems or handlers currently implement the ACTION_DIE packet (An exception is the CrossDosFileSystem). Usage : DEVICE,INHIBIT/S,RETRY/K/N,ALL/S,FREENODE/S DEVICE : The name of the DOS device to unmount. INHIBIT : This switch causes the command to send an ACTION_INHIBIT packet if the ACTION_DIE fails. ACTION_INHIBIT causes the filesystem to appear as 'BUSY' on the workbench screen, like during a format or diskcopy. RETRY : The number of retries for the ACTION_INHIBIT if the first one is rejected because the filesystem is busy. The retry period is 1 second and the default number of retries is 10. ALL : Finds all mounted filesystems and tries to unmount them (except the RAM-handler). Used by shutdown script. FREENODE: This switch causes the command to remove and free the device node after the handler has been stopped. Things attached to the device node like a file system startup message are not freed. It is similar to an 'Assign device: DISMOUNT' command. - Request: This command enables/disables system requesters in the current shell. This can be useful for remote shells or in the User-Startup if you make assigns to external disks that may not be always connected. Usage : OFF/S,ON/S,WB/S OFF : Disables system requesters in the current shell. Unfortunately, software failure requesters are also disabled causing an immediate guru reboot in the event of a CPU trap. ON : Enables system requesters on the current screen. For a remote shell, enables system requesters on the default public screen. WB : Enables system requesters on the default public screen, usually the Workbench screen. This is the default setting at startup. - ValidateWait: This command waits until the specified volume is validated. If it does not become validated within a specified period, it will time out and return an error condition to the Shell. It may be a good idea to put a 'ValidateWait SYS:' command at the beginning of your Startup-Sequence. Usage : DRIVE/A,TIMEOUT/K/N DEVICE : The device (or assign) to check for validation. TIMEOUT: The amount of time in seconds before timing-out. Defaults to 300 seconds (5 minutes). THE SHUTDOWN SCRIPT The shutdown script should be placed in your S: directory. It enables you to perform a safe power down of your system. This is particularly useful if your machine is connected to a network or runs a BBS. You should not edit this script as it may change in a future version of the Sysmon package. Instead, you should create a User-Shutdown script in S: where you can put commands to customize the shutdown sequence. The sequence of events performed by this script is as follows : - First ask the user for confirmation, unless the NOCONF switch was specified on the command line. If you enter 'y', the shutdown continues, else it is aborted. - Set the shell priority to 2, and send a syslog message at level 4 (LOG_WARN). - Execute the S:User-Shutdown script if it exists. You can put commands in this script to stop commodities or network protocol stacks for example. You can also create a Final-Shutdown script in RAM: (via echo or copy commands) that will be executed later. All commands used in Final-Shutdown must be copied to RAM: - Copy all further needed commands to RAM:, reset the search path to RAM: - Find and unmount all filesystems except RAM:, using UnMount ALL INHIBIT. - Execute the RAM:Final-Shutdown script if created by User-Shutdown. - Halt the system via the Halt command. If the REBOOT and/or REKICK options were given on the command line, they are passed to the Halt command. The REBOOT option will cause the system to reboot immediately. If it is not specified, the Halt command will stop all running tasks and display a guru like deadend alert saying 'System Shutdown Complete'. You can then safely turn the power off or reboot by pressing the left mouse button. Usage : Shutdown REBOOT/S,REKICK/S,NOCONF/S REBOOT : This switch is passed to the 'Halt' command at the end of the script. It bypasses the alert display and causes the system to reboot. REKICK : This will force MMU-Softkicked machines like early A3000s to reload the kickstart file when rebooting. NOCONF : Skip the confirmation question. THE SYSMON MONITOR The sysmon monitor is an interactive shell based program that allows you to display the system lists and variables and interact with them (not implemented yet). This program is still under development and more commands will be implemented in future releases. When you type 'sysmon' on the command line, you will get the 'SYSMON>' prompt back that tells you that the monitor is waiting for commands. You can then type sysmon commands (not to be confused with the shell-based sysmon support commands) or exit with the 'EXIT' or 'QUIT' commands. You can also specify a command directly on the command line. In this case, Sysmon will execute the command and exit immediately thereafter. All sysmon commands can be abreviated to the minimum number of characters required to uniquely identify the command. The required characters are shown in capital letters in the description below. Currently implemented commands are : - EXit: - QUIT: These commands will exit the sysmon monitor. An end of file (CTRL-\) at the 'SYSMON>' prompt will do the same. - SHow: This command is used to display system lists and variables. The item to display is given as first argument to the SHOW command. · SHow TAsks will display all the tasks in the system, in a manner similar to the 'ShowSys' support command. · SHow LIBraries will display all shared libraries loaded in the system with version number, open count, negative and positive sizes of the library node and node priority. · SHow DEVices displays all loaded exec devices · SHow RESOurces displays the exec Resource list. · SHow RESIdents displays the resident module array. · SHow POrts displays the public Message Port list. · SHow SEMaphores displays the public Signal Semaphore list. · SHow MEMory displays the Memory Header list. · SHow INTerrupts displays the Interrupt Nodes installed. · SHow FOnts displays the Text Fonts loaded in memory. · SHow MEMHandlers displays the Low Memory Handler list on Amiga OS 3.0+. · SHow INPuthandlers displays the Input Handler list from input.device. · SHow BOards displays the expansion boards installed. If expname.library is installed, it will be used to identify the boards. expname.library is written by Richard Körber and is available on aminet. · SHow LOad periodically displays the top CPU eating processes and total CPU load. It takes the following options (in standard ReadArgs() format) : UP=UPDATE/K/N,MAX=MAXDISP/K/N,THR=THRESHOLD/K/N The list is updated every seconds and includes upto processes. A process which takes less than 1 millisecond in an update cycle is not displayed; processes with an priority lower than are not taken into account; also processes which start and exit within a single cycle can not be taken into account. Type CTRL-C to exit from this command. An example display from a 'quiet' 68000 system is shown below : UpTime : 0 01:03:31 Update : 00:00:05.010 CPU Load : 20.0 % DispCnt : 165143 IdleCnt : 170715 DispUpd : 120 IdleUpd : 256 Address Name Load CPUTime Dispatch 0029B3D0 AmigaShell_3 (sysmon) 7.7 % 00:00:00.385 15 0020703A input.device 4.6 % 00:00:00.232 42 0029C778 CON 3.7 % 00:00:00.184 15 002B8E90 AmigaEyes 1.7 % 00:00:00.085 17 002BCFC8 Clock 1.3 % 00:00:00.064 4 002A2B58 Workbench (Workbench) 0.6 % 00:00:00.028 10 00218834 trackdisk.device 0.2 % 00:00:00.010 9 002253AC trackdisk.device 0.0 % 00:00:00.003 2 - SET: This command is used to change attributes of objects in the system lists. The type of object is given as first argument to the SHOW command, the object name/address and new attributes are given as options in standard ReadArgs() format. · SET TAsk NAME,ADDR=ADDRESS/K,PRI=PRIORITY/K/N This command is used to change the priority of a task. You specify the task name as or the hex address as
, and the new priority as . Use ADDRESS=0 to affect the current task. If the task name has embedded blanks, enclose it with double quotes "". ex: SET TASK "Clock" PRI=-1 will set the "Clock" pri to -1 SET TASK ADDR=0 PRI=1 will set the current shell to pri 1 WRITING PROGRAMS FOR SYSMON You can use the sysmon.library in your own programs. See the DISTRIBUTION section for legal details. The library contains public functions that can be used to monitor cpu usage, send syslog messages to the Sysmon.server process, etc... Read the sysmon_lib.doc autodoc file and the sysmon.h include file for further information. Sources for the support commands are provided as examples. CHANGES - V0.13 · Task switching code was broken on the 68060. Fixed according to Phase 5 documentation for stack frame formats. · Halt REKICK crashed on the 68040 and higher. Fixed. · More commands implemented in the Sysmon monitor.