Log Monitoring Tools for Unix: Linux, Ubuntu, Red Hat and Solaris Servers




By Jacob Bowman
How to Easily Monitor and Alert on Unix Log Files…STRESS FREE!
Log Monitoring Tools for Linux and Solaris: Do you wish to monitor UNIX log file on a Linux or Sun Solaris System based on a time-frame (i.e. search for the occurrence of “pattern” in the log file within the last x amount of minutes)? If so, this article will save you hours and days of laborious work.
If you work in a UNIX environment, a time will come when you will wish to have caught a problem on one or more of your servers earlier than you did. When that time comes, you’ll scroll through your system or application logs and you’ll find a number of errors in there that speaks to an oncoming/developing problem.
You’ll wonder how you can monitor these logs in the future and alert yourself in the event of a problem. You’ll search the web for solutions and you’ll discover, to your dismay, that nothing out there is simple and straightforward enough to implement in your particular UNIX environment.
Then, you’ll want to write your own script. But alas, it is at this point that your mind will go blank. Because as you start to write your own log monitoring script, you will sadly discover that it really isn’t an easy thing to do. So you’ll begin to wonder in desperation, what do I do?
Well, I’ll tell you what you ought to do: Download or Write Your own ‘Smart Log Script’ and Keep it Simple!
What do I mean by that? Well, if you want to monitor a log file for errors/strings, and you’re concerned with efficiency, whatever script you write or download MUST follow the outline below. Emphasis on MUST!
For example, say you want to monitor the last x amount of minutes or hours of data in a particular log file for certain strings and alert if the strings are found, you MUST model your log monitoring script after the following tool:
Unix Log Tool: /bin/LogRobot (logfile-absolute-path) (time-in-minutes) ‘(string1)’ ‘(string2)’ (-found) (warn) (critical)
Example: ## /bin/LogRobot /var/log/messages 60 ‘luance’ ‘Err1310′ -found 5 10
So in this example,
/bin/LogRobot is the tool name.
/var/log/messages is the log file.
60 is the amount of previous minutes you want to search the log file for.
“luance” is one of the strings that is on the line of logs that you’re interested in.
“Err1310″ is another string on the same line that you expect to find the “luance” string on. Specifying these two strings (luance and Err1310) isolates and processes the lines you want a lot quicker, particularly if you’re dealing with a huge log file.
-found specifies what type of response you’ll get. By specifying -found, you’re saying if anything is found that matches the specified strings within the 60 minute time frame, then that should be regarded as a problem and outputted out.
5 specifies Warning. By specifying 5, you’re telling the program to alert as WARNING if there are at least 5 occurrences of the search strings you specified, in the log file within the last 60 minutes.
10 specifies Critical. By specifying 10, you’re telling the program to alert as CRITICAL if there are at least 10 occurrences of the search strings you specified, in the log file within the last 60 minutes.
Summarized Explanation:
As you can see, the LogRobot tool is monitoring a log file. The arguments that are passed to this log monitoring tool instructs it to do the following:
Within the last 60 minutes, if the tool finds less than 5 occurrences of the specified search strings in the log file, it WILL NOT alert. If the script finds at least 5 to 9 occurrences of the specified strings in the log, it’ll alert with a WARNING. If the script finds at least 10 or more occurrences of the strings in the log within the last 60 minutes, it’ll alert with a CRITICAL.
How easy is that? EXTREMELY!
For more information on how this tool works and to DOWNLOAD it for your own use, visit the following page:
http://www.jacobhtbowman.com/unix-monitoring-tools/unix-log-monitor-linux-sunos.htm