1833159 Members
2998 Online
110051 Solutions
New Discussion

Script

 
SOLVED
Go to solution
Nobody's Hero
Valued Contributor

Script

I have a simple script in cron every 1/2 hour that scans syslog and looks for any scsi error. If it finds it it sends to my pager.
Is there a way, that when it finds an error and sends it, to stop sending the message over and over again? like a counter or something. besides, if condition is true, send message, then rename the script so cron cant find it. renaming the script is the only way I can think of ending the loop. dont have syslog-ng on this server and cant.
UNIX IS GOOD
2 REPLIES 2
TTr
Honored Contributor
Solution

Re: Script

You have several options here.
1. Enhance your script to check dates in the syslog and only capture the most recent errors.
2. When the script finds errors and sends a page, have the script touch a file and use it as a flag. In the begining of the script check if the flag file exists and exit the script. You have to manually delete the flag file after you respond to the paging or have the script delete the file every few hours.
3. Use the "dmesg -" command to check for errors if those SCSI errors are sent to the kernel as well. The "-" option in dmesg will only show the new messages since the last time it was invoked.
I am sure other interesting suggestions will come up.
Ivan Krastev
Honored Contributor

Re: Script

You can add the condition in your script:

if [ ! -f /etc/scsi_found ] {
///check for scsi erorrs
if (scsi errors found) { touch file /etc/scsi_found
}
else rm /etc/scsi_found
}



regards,
ivan