|I have mentioned a detailed requirement to be very clear. The points with '*' are the tasks that the script is|
expected to do. All other information provided is for clear understanding of the script functionality.
The basic form of the script will simply send a copy of all lines that contain either "error" or "warning"
to the user specified in the script as RECIPIENT. Note that RECIPIENT is a shell variable that will contain
an e-mail address.
The basic script will be able to look at a log file periodically and report on any new lines that contain
either "error" or "warning". The search for this text is to be "case insensitive". This means that the script
needs to accept a line containing either "error", "Error", "ERROR" or the word error spelt in any other
combination of upper and lower case letters as being functionally equivalent.
The basic script, named "logmon" (for log monitor) will need to do the following:
* be able to run in an environment that does not include a path. (i.e. the environment provided by
* accept the name of a log file as the sole command line argument
* search the specified log file for lines that have been added since the previous search.
* construct an e-mail reporting any lines that contain either "error" or "warning" in any combination
of upper and lower case letters
* send the e-mail to the address specified in the RECIPIENT shell variable which is defined within the
Optional requirements for now
Include only putting a single copy of a message in an e-mail, but reporting
how many times the message is repeated. Also modifying the script so that the same script will either
report via e-mail, or directly to a terminal, depending on how it is called. The final option will
be a system that reports errors directly to the root console.
(Note that this will need to be implemented in a way that sends the message to your account and does not actually send a message to root for testing purpose.)
Please add a comment or comments in your script that state which, if any, of the optional requirements have been implemented.
* modify the script so that, instead of listing multiple lines with the same message, it lists one instance
of each duplicated line (Note that for the purposes of this requirement, two lines that share everything
except the timestamp are considered to be identical lines.)
* follows the single instance of a duplicated line with a line that reports how many times the previous
* add code that will report the above to the command line when it is called with the name "logcheck"
(How could you have one script that has two different names?)
Note that any data that needs to be passed from one time when the script runs to the next time cannot be passed in a temporary file. It will
need to be stored in a secure location.
Certain commands that I thought might be helpful are diff, wc, tail, grep, awk, and sort. Can anyone think of a way to do the above. Any suggestions
are most welcome.
Thanks in Advance for all the help.