Operating System - HP-UX
1752796 Members
6284 Online
108789 Solutions
New Discussion юеВ

Re: hp unix shell (urgent help guys)

 
ibrahim_zubi
New Member

hp unix shell (urgent help guys)

hi:
i had a log file like this:

01/28/2010 06:09:06.599 GMT+02:00 main (08.003.11) INFORMATIVE: Setting next file to: //b03185545.dat
01/28/2010 06:09:06.652 GMT+02:00 main (00.000.00) INFORMATIVE: File /oracle/uibstest/b03185545.dat was successfully archived to /oracle/uibstest.b03185545.dat.20100128060906
01/28/2010 06:09:06.693 GMT+02:00 main (00.000.00) INFORMATIVE: File /oracle/uibstestb03185545.dat was archived into: /oracle/uibstest.b03185545.dat.20100128060906 - and delivered
to: /oracle/uibstestb03185545.dat/oracle/uibstest/b03185545.dat)
01/28/2010 08:31:45.904 GMT+02:00 RequestProcessor-3 (03.002.01) ACCOUNTING: Stop Collector
01/28/2010 08:31:45.911 GMT+02:00 RequestProcessor-3 (02.015.01) ACCOUNTING: Received Stop Request.
01/28/2010 08:31:45.934 GMT+02:00 main (07.003.11) INFORMATIVE: Aggregated 30,382 NMEs at a rate of 3 NMEs/sec
01/28/2010 08:31:46.108 GMT+02:00 main (06.016.04) INFORMATIVE: Wrote NME file: /oracle/uibstest 01/28/2010 08:31:46.226 GMT+02:00 main (06.016.04) INFORMATIVE: Wrote NME file: /oracle/uibstest for scheme S04_unbil.

i want a shell to cmpare the date and time of the processing (ex. 01/28/2010 08:31:46) with the system date and time,then to sent email or an SMS to me when delay of time about 30 minutes.

and i want also to send a notification if a word "error" appears in the log file.

Please advice
8 REPLIES 8
Robert Salter
Respected Contributor

Re: hp unix shell (urgent help guys)

You could have a script that will "grep" the expression you're looking for and place it in a file (file1). Have that file emailed or SMSed to you every hour via cron.

Then at every half hour have sanother script grep your expression, place it in another file(file2), use "comm -13 file1 file2" and have the output emailed/SMS to you.

You can do the same with "error" notifications.

Beers,

robert
Time to smoke and joke
ibrahim_zubi
New Member

Re: hp unix shell (urgent help guys)

thanks for your replay, but am a beginner in scripting , in fact am in learning phase and time is not in my side, as this will allow me to improve my new carrier so much.as my previuos experience is in hardware issue.
i appritiate if you send me a detailed solution.

many thanks
OldSchool
Honored Contributor

Re: hp unix shell (urgent help guys)

You're going to have to better define the requirements.


For example:

" want a shell to cmpare the date and time of the processing (ex. 01/28/2010 08:31:46) with the system date and time,then to sent email or an SMS to me when delay of time about 30 minutes."

What else is there to identify the line so that the time can be extracted (as you can see in the example, every line has a date / time stamp, so which should be compared to the system time)???


" want a shell to cmpare the date and time of the processing (ex. 01/28/2010 08:31:46) with the system date and time,then to sent email or an SMS to me when delay of time about 30 minutes."

you need to probably need rethink this request. Is that any occurance of the word "error"? occurring only with specific other words?

Once its found, should you only look for "error" occuring after the time of the first page/message?


".... want a shell to cmpare the date and time of the processing (ex. 01/28/2010 08:31:46) with the system date and time,then to sent email or an SMS to me when delay of time about 30 minutes."


You might want to visit http://www.shelldorado.com/ for tutorials as well.....

Shell scripting is lie any other language, you learn by actually writing code and testing it.
ibrahim_zubi
New Member

Re: hp unix shell (urgent help guys)

the file apears like this way (attached):

please any one can give me a script works every 1 hour , compares the time of the log with system time, if the gap is 30 min send email to my yahoo email or SMS to my number.
note that am a biggener in scripting.

Steven Schweda
Honored Contributor

Re: hp unix shell (urgent help guys)

> note that am a biggener in scripting.

And if you never try to write any scripts
yourself, then you may stay that way for a
very long time.


Some people will be willing to help you when
you run into a specific problem.

Some people will be willing to do your whole
job for you.

Some people will be willing to do your whole
job for you for no pay.


I suspect that there are many more people in
the first group than there are in the second
group or the third group.
Robert Salter
Respected Contributor

Re: hp unix shell (urgent help guys)

I agree with Oldschool and Steven, you will never reach your destination until you take the first step. It's unfortunate that time is not on your side, but we've all worked under the same conditions more than once. What you're looking ot do is not that complicated, simple logic, simple commands. You just need to try and figure it out. Use "ls -l", "date","awk or cut" and some logic.

Like Steven said job for you for no pay.> Not me, I'm expensive.
Time to smoke and joke
ibrahim_zubi
New Member

Re: hp unix shell (urgent help guys)

guys i know you are right
okay donot worry, i will try it my self.
i just needed some help regarding the comarision between the date of the log and the sysdate.
Dennis Handly
Acclaimed Contributor

Re: hp unix shell (urgent help guys)

>I just needed some help regarding the comparison between the date of the log and the sysdate.

You can compare for a match but to do date arithmetic, you need to work very hard, or use a language like perl.

Here is the current time, assuming you are in the same timezone:
date "+%m/%d/%Y %H:%M:%S"