How to get last 15 minutes timestamp and threshold > 60 will sent alert?

Hi All,

need your help , i have some files and got some below condition

cat tdr12009.log | grep -i success | grep promo | awk -F'[|;]' '{print substr($1,1,16),$15}' | more
 

2019-10-16 00:03 delta=1
2019-10-16 00:03 delta=2
2019-10-16 00:04 delta=20
2019-10-16 00:09 delta=10
2019-10-16 00:10 delta=1
2019-10-16 00:13 delta=0
2019-10-16 00:16 delta=2
2019-10-16 00:17 delta=30
2019-10-16 00:18 delta=2
2019-10-16 00:19 delta=21
2019-10-16 00:20 delta=21
2019-10-16 00:22 delta=31
2019-10-16 00:22 delta=12
2019-10-16 00:23 delta=11
 2019-10-16 00:23 delta=11

from above condition i need create cronjob and get last 15 minutes and condition if delta > 60 will sent alert

could you help to this case

Regards

You should write you own scripts and post your error messages.

UNIX.com is not a "script writing service".

We are here to help you write your own scripts, learn to use IT to solve your own problems, and to think for yourself how to solve problems using software.

A cronjob is generally a script. So, try to write a script (programming logic) to do what you want and post the results and any error messages you get when you attempt to run your scripts.

Okay noted bro...

I already find my question

cat tdr12009.log | grep -i success | grep promo_cashback | awk -F'[|;]' '{print substr($1,1,16),$15}' | awk -F"|" -v d1="$(date --date="15 min ago" +"%Y-%m-%d %H:%M")" -v d2="$(date +"%Y-%m-%d %H:%M")" 'substr($0,1,15) > d1 && substr($0,1,15) < d2 || substr($0,1,15) ~ d2'|awk -F \= '{if($2>60)print}'

Thanks

If we could see the content of tdr12009.log , your job could probably be done with a single awk invocation against the log file.
Show the input please, operating system and shell you are using.

Regards
Peasant.

here the real log ,

Thanks

This is not a representative input.

First, lines are not proper but broken. Little vi yank magic helps but ...
Second, the grep success or grep promo_cashback return nothing from your input.

Is this your request perhaps ?

  • Parsing the log file, match a line which has contains success string.
  • If string success is matched, look for promo_cashback in the same line.
  • When both conditions are meet on the line, look for string delta=N in the same line, where N is an integer.
  • When N is > 60, send an alert.

Correct me if i'm wrong and please show representative input, with your operating system and shell details.

Regards
Peasant.