As always, I suggest that you read through the entire lab before you get started!
Look at the output of vmstat and iostat. What information do they provide that is not available using top? Notice that both commands accept an argument of the number of seconds before reporting the next round of statistics. Try vmstat 5 while you start and run other applications like netscape.
If you are unfamiliar with Perl, start by skimming through a Perl tutorial. (Yes, we will be doing more with Perl this semester.) If you are uncertain of your programming skills, I suggest: Picking Up Perl. If you are more confident, try Perl in 20 pages.
There is lots of Perl documentation online and there are three books on Perl (such as Learning Perl and Programming Perl) in the Lehigh Safari e-book library, including a relatively advanced book on Perl for System Administration. (Chapter 9, Log Files is also available separately.)
Now write a very simple Perl script that prints out the parameter given to it, like the echo(1) command. It should work like this:
% ./echo.pl hello
hello
The following script will write the words 'hello world' to syslog, along with the PID of the logger.pl process. Modify it to write the contents of the first parameter of the script instead (just like the echo script above).
Verify that it works by running it and checking /var/log/messages.#!/usr/bin/perl use strict; # compile-time checks use warnings; # enable run-time warnings use Sys::Syslog qw(:DEFAULT setlogsock); # library for syslog functions setlogsock('unix'); # use a unix domain socket openlog("logger.pl", 'pid', 'user'); # register ourselves syslog('info', 'hello world'); # the syslog call closelog(); # close the socket