Script to alert an error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to alert an error
# 1  
Old 09-19-2016
Script to alert an error

Hi

I am writing a shell script which will grep for a particular string e.g. "Process has not started" which i am able to find using a simple grep command on this file and then sending an email alert every 5 mins. Now problem is this email is coming even after this problem is resolved.
once problem is resolved then a new message comes in file e.g. "Process has started successfully" but there are multiple lines in different format between not working and successful.

What command i can use to check "Process has started successfully" is there after "Process has not started" so to ignore the email alert and assume all fine now. else send the email alert. If success message is before failure message then it is an error and should be alerted.

any suggestion would be appreciated. I am trying in shell script.
# 2  
Old 09-19-2016
Any attempts/ideas/thoughts from your side? Please post your work in progress.
# 3  
Old 09-19-2016
You can use egrep to search the file for both strings and pipe the output through tail to just get the last entry and test against that. something like:

Code:
egrep -E "Process has not started|Process has started successfully" | tail -1

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Cybersecurity

**ALERT**ALERT* Whats app requesting users to upgrade to latest version as; its vulnerability found.

Hello All, Want to share here an article for Whats app users that team whats app is requesting users to upgrade to its latest version since they have found a vulnerability; where Hacker could turn on a cell's camera, mic and scan messages and emails. Here is an article from "THE VERGE" for... (1 Reply)
Discussion started by: RavinderSingh13
1 Replies

2. Shell Programming and Scripting

Shell script for alert

Hi Experts, Im new in shell script , please help to achieve the below requirement, We have some replication setup in unix server, in that if there is any exception or error occurs immediately the rep_exception.log will have the exception detail, this log will be updated if any error occurs no... (8 Replies)
Discussion started by: pandiyan
8 Replies

3. Shell Programming and Scripting

Oracle Alert log script

Hi, I'm trying to write a shell script on HP-UX to search through Oracle alert logs for errors which always start with ORA-. If it does find an error I'd like it to print the date line (which precedes the error by a line or two normally) as well as the error line. So in the example below I'd like... (1 Reply)
Discussion started by: capesong
1 Replies

4. Shell Programming and Scripting

need script bash alert email

Hello I have a server it is running more than 5 people Scripts I want to send a warning to the administrator for the main server All is written in the ssh strain For example, when typing the following command "ls" " rm " and other email sends the administrator for the main server About it... (2 Replies)
Discussion started by: x-zer0
2 Replies

5. Shell Programming and Scripting

shell script not getting current error messages with time from alert.log

Hi All, I need to get current error messages with time from alert.log.Below is my shell script but it's not working to meet this objective. could anyone pls share on the above issue for resolution: #################################################################### ## ckalertlog.sh ##... (2 Replies)
Discussion started by: a1_win
2 Replies

6. HP-UX

Error alert keep showing at console

Hi, I would like to ask for your help. I tried to log in through console to my server HP-UX 10.20 but I keep receiving error message as below: Vxfs: mesg 001: vx_nospace -/dev/vg02/lvol6 file system full Vxfs: mesg 001: vx_nospace - /dev/vg02/lvol9 file system full How should I stop this... (4 Replies)
Discussion started by: yeazas
4 Replies

7. Shell Programming and Scripting

Why does my script not work? (Noob Alert)

I am a scripting noob and I have tried to search on google, but cannot find the answer as to why this script doesn't work properly. The idea of this script is that it will list all files starting with f in a certain folder, and delete all but the three newest one. I am trying to achieve this by... (4 Replies)
Discussion started by: bronkeydain
4 Replies

8. Solaris

Sendmail [279] [ID 702911 mail.alert] ERROR!!!

Why do I heep getting this error: I do have another domain name on the network "ciscolab.com" And it is a windows server. (5 Replies)
Discussion started by: louisd11
5 Replies

9. Shell Programming and Scripting

Email alert script

I need to code a script, which will run via cron, every 30 minutes. The script will read a file containing a date&time and number (which represents disk space). The file gets appended to every 30 minutes. Here's a sample of the file: CPU 1:04/25/02 1:00 am:1972554 CPU 1:04/25/02 1:30... (1 Reply)
Discussion started by: moon
1 Replies
Login or Register to Ask a Question