demasi@paisano.UUCP (Michael C. De Masi) (01/28/88)
Hello Again, First of all, I'd like to thank everybody for their kind responses to my original posting. If you remember, the question involved the possibility of using the regular I/O ports from a standard 3b (or, I suppose, any reasonable Unix* machine) to monitor the console ports of other similar machines in situations where a one console/machine ratio was impossible due to space considerations. Additional requirements were that the monitoring machine should keep a log of any output from the monitored machine's console, and that the solution should not involve any special hardware or radical changes to either machine's software or configuration. The responses I received were many, and about evenly split between ideas for performing the task and requests for any solution that came in. Many of the solutions received were quite feasible, but either involved hardware I did not have or proprietary software I did not intend to buy. Some of the solutions were extremely complex, and others either did not really hit the mark, performance wise. The best solution, of course, was very simple. In the '/etc/inittab' file of the monitoring machine, install the line: XX:2:respawn:sh -c '(/bin/stty 9600 evenp;/bin/cat) </dev/ttyXX >>LOGFILE 2>/dev/null' where 'XX' is replaced by the port number to which you will attach the wire from the monitored machine's console and 'LOGFILE' is replaced by the full path name of a file, writable by 'root' on the monitoring machine, which you choose to hold the output from the monitored console port. The trick here is to open the port simultaneously for both the 'getty' which sets the port for the proper options and the 'cat' which redirects the input from the port to the log file. The generic 'open' issued by shell will wait until it can return a useful file descriptor (Ie, until an operational console port from a running machine gets plugged into the appropriate I/O port on the monitoring machine) before executing the 'getty' and 'cat'. 'cat' will run, redirecting the output from the monitored console to the logfile until it reaches an EOF condition (the connection gets broken, the monitored machine goes down), and the process respawns. The 'sh -c' format of the line is necessary to keep 'init' from going into a rapid respawn error if the connection goes down. Simple, no? In fact, it is this feature which allows the further generation of the 'inittab' entry to be written: 61:2:respawn:sh -c '(/bin/stty 9600 evenp;/bin/echo "\n\nRESUME: \c";/bin/date;/bin/cat;/bin/echo "\n\nBREAK: \c";/bin/date) </dev/tty61 >>/usr4/console/log 2>/dev/null' which in addition to keeping a log of the monitored console's output, also adds a nice trail of informative records and time stamps to the collected data every time the connection gets broken or the monitored machine goes down. This should also give you an idea what the real 'inittab' entry should look like. The only modification on the monitored machine that might be necessary would be to adjust '/etc/gettydefs' to loop around 9600 Baud at the console entry, to keep the two machines from going out of synch. Of course, this setup is only good for readonly monitoring, as attaching to the monitored console in interactive mode through the monitoring machine is presently not possible. Since our consoles are all fed through a patch panel and hard disconnects/reconnects are easy, this is not a big problem. If anybody has any great ideas about how one might get around this, given some variation on the above stated theme, please post. (I tried doing a 'cu' directly to the I/O port, but since the 'cat' is still running, the I/O gets garbled. Kill the 'cat', it immediately respawns.) Special thanks go to Tony Hansen, AT&T-IS Labs and Don Ritchie, AT&T Bell Labs (Gee, those guys at AT&T are smart! :-) who gave me the above ideas. Until we meet again, Michael C. De Masi - AT&T Communications (For whom I work and not speak) 2340 Dulles Corner Blvd. Herndon, Virginia 22071 Phone: 703-834-8123 UUCP: decuac!grebyn!paisano!demasi "All things considered, I'd rather be in Philadelphia" - W C Fields *Unix is a registered trademark of AT&T - Bell Laboratories