[comp.unix.microport] SVR3 console message capturing

gregoire@Thalatta.COM (Keith Gregoire) (08/18/88)

I am running Bell Tech System V/386, release 3 on a Bell Tech 386.
 
I am looking for a way of capturing console error messages (notices, 
warnings and panics) to a file (or at least a printer) such as
the way BSD and XENIX do with dmesg.  I have scoured the Bell Tech
System Admin manuals and cannot find a clue as to whether there is 
an existing way to do this.  The dmesg command cannot be found.  
 
I'd rather not reinvent the wheel.  Does anyone have a solution to
this?  I have several ideas:
 
1.	Obtaining a console driver to customize to send output to a file
	as well as the usual places.
 
2.	Obtaining a console driver that can use a hardcopy terminal as
	a console instead of the monitor and keyboard.
 
3.	Write a dmesg that works on SVR3.
 
4.	Can /dev/contty be exploited somehow?  
 
There must be someone else who has had this same problem.  If there is a
way of doing this with the resources I already have with System V/386, 
please let me know what I'm missing via email.
	
-- 

In-Real-Life: Keith Gregoire, Thalatta Corporation, (+1 206 455 9838)
Domain: gregoire@Thalatta.COM   Path: uw-beaver!uw-entropy!thebes!gregoire

bowles@lll-crg.llnl.gov (Jeff Bowles) (08/18/88)

In article <184@thebes.Thalatta.COM> gregoire@Thalatta.COM (Keith Gregoire) writes:
>
>I am running Bell Tech System V/386, release 3 on a Bell Tech 386.
> 
>I am looking for a way of capturing console error messages (notices, 
>warnings and panics) to a file (or at least a printer) such as
>the way BSD and XENIX do with dmesg...

Yes, I know this is going to three groups, but the answer is useful
to people who read all three groups.

Included in the Bell Tech release (and EVERY System V source release since
SVR3.0) is a driver called "osm". In effect, it's a driver that provides
read/write access to the circular buffer (that's by default a couple of
thousand bytes) that captures kernel printf messages. Investigate your
OS directories, you'll find it - add the driver to your kernel, reboot,
make the nodes for it (CHARACTER-SPECIAL devices, mind you!)  and then
you can just cat(1) the device.... Nothing more needed.

	Jeff Bowles

fenk@foobar.hf.intel.com (John Fenk) (08/19/88)

In article <184@thebes.Thalatta.COM>, gregoire@Thalatta.COM (Keith Gregoire) writes:
> 
> I am running Bell Tech System V/386, release 3 on a Bell Tech 386.
>  
> I am looking for a way of capturing console error messages (notices, 
> warnings and panics) to a file (or at least a printer) such as


(This assumes that thew Bell Tech UNIX behaves like Intel's version of UNIX)
The kernel keeps a buffer of PANIC, WARNING, driver printf's, etc.
There are two easy ways to read it.  First go into crash and type "panic".
The messages will be printed.  The second way is to create a character special
file for the "osm" driver (make sure it's configured into your kernel and check
the major number by looking in /etc/conf/systems and
/etc/conf/modules/osm/config. Then you can use cat or tail to look at the
messages (cat /dev/osm).

John Fenk
Intel Corporation
tektronix!ogcvax!littlei!osdtm1!fenk

ewv@zippy.berkeley.edu (Eric Varsanyi) (08/19/88)

In article <11426@lll-winken.llnl.gov> bowles@lll-crg.llnl.gov.UUCP (Jeff Bowles) writes:
>In article <184@thebes.Thalatta.COM> gregoire@Thalatta.COM (Keith Gregoire) writes:
>>I am looking for a way of capturing console error messages (notices, 
>Included in the Bell Tech release (and EVERY System V source release since
>SVR3.0) is a driver called "osm". 

If you have another machine, you can patch 'kernputc' to either 0x2f8 or
0x3f8 and all kernel printf's will go to the serial port (at 9600 baud).
The problem with osm is that it does not catch a panic message, you have to
go look at the dump to find the panic since the 'cat' will never get dispatched
after a panic. If you have another box that can record stuff off the serial
port it is a great way to log disk errors and other stuff that usually scrolls
away.

wu@spot.Colorado.EDU (WU SHI-KUEI) (08/19/88)

In article <13439@agate.BERKELEY.EDU> ewv@zippy.berkeley.edu (Eric Varsanyi) writes:
>In article <11426@lll-winken.llnl.gov> bowles@lll-crg.llnl.gov.UUCP (Jeff Bowles) writes:
>>In article <184@thebes.Thalatta.COM> gregoire@Thalatta.COM (Keith Gregoire) writes:
>>>I am looking for a way of capturing console error messages (notices, 
>>Included in the Bell Tech release (and EVERY System V source release since
>>SVR3.0) is a driver called "osm". 

Our console is a Qume 102 terminal with a printer port.  That port feeds a
PC serial to parallel buffer (Microfazer), which in turn feeds an ancient
and slow Epson printer.  This kludge lets the console run at 9600 while
still capturing everything on paper (YECH).

All this on a 3B2/400 running SV.2.04.

Only a guest here, I really am:

Carl Brandauer
uunet!nbires!bdaemon!carl

haugj@pigs.UUCP (Joe Bob Willie) (08/20/88)

In article <184@thebes.Thalatta.COM> gregoire@Thalatta.COM (Keith Gregoire) writes:
>
>I am running Bell Tech System V/386, release 3 on a Bell Tech 386.
> 
>I am looking for a way of capturing console error messages (notices, 
>warnings and panics) to a file (or at least a printer) such as
>the way BSD and XENIX do with dmesg.  I have scoured the Bell Tech
>System Admin manuals and cannot find a clue as to whether there is 
>an existing way to do this.  The dmesg command cannot be found.  

is /usr/lib/errdemon present on your system?  we have it here.  it
takes reads from /dev/conslog and writes to /usr/adm/console_log.
i believe our system is S5R2 based.  one might assume bell tech didn't
remove features ...

however, the device driver for a console log output driver is very
simple.  read from the system error message ring buffer, write to
the user address space (passc() should be helpful here).  do this until
u.u_count goes to zero or passc() returns an error.
-- 
 jfh@rpp386.uucp	(The Beach Bum at The Big "D" Home for Wayward Hackers)
     "Never attribute to malice what is adequately explained by stupidity"
                -- Hanlon's Razor

larry@hcr.UUCP (Larry Philps) (08/22/88)

In article <184@thebes.Thalatta.COM> gregoire@thebes.UUCP writes:
>
>I am running Bell Tech System V/386, release 3 on a Bell Tech 386.
> 
>I am looking for a way of capturing console error messages (notices, 
>warnings and panics) to a file (or at least a printer) such as
>the way BSD and XENIX do with dmesg.  I have scoured the Bell Tech
>System Admin manuals and cannot find a clue as to whether there is 
>an existing way to do this.  The dmesg command cannot be found.  
>
>In-Real-Life: Keith Gregoire, Thalatta Corporation, (+1 206 455 9838)
>Domain: gregoire@Thalatta.COM   Path: uw-beaver!uw-entropy!thebes!gregoire

On some versions of 386 UNIX, most particularily 386/ix from ISC, there is a
"osm" pseudo device that can be configured into the kernel.  osm stands for
Operating System Messages, and it does just what you want.  Look in your config
directory and see if you have it.  If so, create /dev/osm (usally major 17,
minor 0) then run "cat -u > filename" on it to copy the messages to a file.

If it turns out that you don't have it, write one yourself.  The kernel printf
code saves all messages it prints in a global circular character array called
"putbuf", the variable "putbufsz" gives the number of characters in this array,
and the variable "putbufndx" gives the location at which the next character
will be put into the array.  The printf code also does a wakeup(putbuf)
whenever new characters are put into the array.  Makes for an easy 50 line
driver to access the information you want.

Here is a short user program I wrote ages ago when I was trying to figure out
how putbuf was used.  Actually, you could probably hack this into something
close to what you want instead of writing a driver.
----------
#include <stdio.h>
#include "sys/types.h"

#include "nlist.h"

#define PUTBUF		0
#define PUTBUFSZ	1
#define PUTBUFNDX	2
struct nlist nl[] = {
#ifdef vax
	{ "_putbuf" },
	{ "_putbufsz" },
	{ "_putbufndx" },
#else
	{ "putbuf" },
	{ "putbufsz" },
	{ "putbufndx" },
#endif
	{ 0 },
};

#define BUFFERSIZE	10000
char	buf[BUFFERSIZE];

char	*malloc();

main()
{
	int	i, j;
	int	memfd, putbufndx, putbufsz;
	char	*putbuf;

	if ((memfd = open("/dev/kmem", 0)) < 0) {
		perror("/dev/kmem");
		exit(1);
	}

	nlist("/unix", nl);
	if (nl[0].n_value == 0) {
		fprintf(stderr, "nlist failed\n");
		exit(2);
	}
#ifdef vax
	nl[0].n_value = ((int)nl[0].n_value  & 0x3fffffff);
	nl[1].n_value = ((int)nl[1].n_value  & 0x3fffffff);
	nl[2].n_value = ((int)nl[2].n_value  & 0x3fffffff);
#endif

	Lseek("putbufsz", memfd, (long)nl[PUTBUFSZ].n_value, 0);
	Read("putbufsz", memfd, (char *)&putbufsz, sizeof(putbufsz));
	printf("putbufsz %d\n", putbufsz);

	if (putbufsz >= BUFFERSIZE) {
		fprintf (stderr, "putbufsz(%d) >= BUFFERSIZE(%d)\n",
				putbufsz, BUFFERSIZE);
		exit(4);
	}

	Lseek("putbufndx", memfd, (long)nl[PUTBUFNDX].n_value, 0);
	Read("putbufndx", memfd, (char *)&putbufndx, sizeof(putbufndx));
	printf("putbufndx %d\n", putbufndx);

	if ((putbuf = malloc(putbufsz)) < 0) {
		perror("sbrk");
		exit(5);
	}

	Lseek("putbuf", memfd, (long)nl[PUTBUF].n_value, 0);
	Read("putbuf", memfd, (char *)putbuf, putbufsz);

	putbufndx = (putbufndx + 1) % putbufsz;
	putbuf[putbufndx] = '\0';

	i = (putbufndx + 1) % putbufsz;
	while (i != putbufndx && putbuf[i] == '\0')
		i = (i + 1) % putbufsz;
	j = 0;
	while (i != putbufndx) {
		buf[j] = putbuf[i];
		i = (i + 1) % putbufsz;
		j++;
	}
	buf[j] = '\0';

	printf("putbuf:\n%s\n", buf);
	return(0);
}

Lseek(s, fd, offset, set)
	char	*s;
	int	fd, offset, set;
{
	if (lseek(fd, offset, set) == -1) {
		sprintf(buf, "%s: lseek (%d, 0x%x, %d)", s, fd, offset, set);
		perror (buf);
		exit (1);
	}
}

Read(s, fd, addr, n)
	char	*s;
	int	fd, addr, n;
{
	int	i;

	if ((i = read(fd, addr, n)) == -1) {
		sprintf(buf, "%s: read(%d, 0x%x, %d)", s, fd, addr, n);
		perror (buf);
		exit (2);
	}

	if (i != n) {
		fprintf(stderr, "%s: read(%d, 0x%x, %d) returned %d\n",
				s, fd, addr, n, i);
		exit (3);
	}
}
----------
Larry Philps                             HCR Corporation
130 Bloor St. West, 10th floor           Toronto, Ontario.  M5S 1N5
(416) 922-1937                           {utzoo,utcsri,decvax,ihnp4}!hcr!larry