Novell is now a part of Micro Focus

Have Your Workstation Notify You of Problems

Novell Cool Solutions: Tip
By Randall R. Saeks

Digg This - Slashdot This

Posted: 7 Dec 2005

PROBLEM: Having workstations notify someone when they have problems.

SOLUTION: Run a script on a periodic basis to check the system log for problems and if a condition is met, send an email. This could be in an hourly cronjob, for example.

EXAMPLE: Here is the script:

#-= Varibles for auto-notify =-
# Name of the machine
hostname=`hostname -s`
#Search for things in the last hour.
hr_lookup=`date +%h" "%d" "%H:`

# -= Data for auto-notify =-
# Give the IP and network info of the client
network_info=`ifconfig -L en0 | grep broadcast`
# Display the last 5 users.  (Optional)
# change PATH to location of user logins, if #desired
last_usr=`tail -n5 PATH`
#Location of system log, and pull last 1000 lines.
#Search for things in the last hour with the " | #grep $hr_lookup" command.  Remove to look in the 
#last 1000 lines, regardless of time.
#Also, change CONDITION to text that appears in 
#log for the event you want to be notified of, 
#quoted if a longer item.
#EX: crashdump will show all lines with crashdump #in them.  Likewise, "Search Connection Failure" 
#will show all lines with that string.
sys_log=`tail -n1000 /var/log/system.log | grep "$hr_lookup" | grep CONDITION`

# -= Begin Script =-
# If something was found in the log, then prepare #to send an email.  Varibles behave as above.
if tail -n1000 /var/log/system.log | grep "$hr_lookup" | grep CONDITION
# change EMAIL to email address
/usr/sbin/sendmail EMAIL <<EOF
# Change LOCALID to what you want the sender to #be.  can be helpful for email filtering.
#Change TOEMAIL to who is the email to
# SUBJECT = Subject of the email
Subject: SUBJECT
#This is the body of the email.  Change with what you want to display.
|Machine name:|

|Last 5 Users:|

|Network info:|

|System Log:|
#Make sure to remove comments (lines beginning with '#') between the two EOF's, otherwise, those will be in the body of the email.

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Copyright Micro Focus or one of its affiliates