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

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How to get last 15 minutes timestamp and threshold > 60 will sent alert?
# 1  
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

# 2  
You should write you own scripts and post your error messages. 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.
# 3  
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}'

# 4  
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.

# 5  
here the real log ,

2019-10-16 00:00:00,993|32||p1209|testing|testing456|p12091910160000004545714090|638221234567|1|F04| NotEligibleMinAmount|NotEligibleMinAmount;msisdn=62812560454
57;promo_id=1296;delta=0;shortcode=link_miri_cust;req_amount=20000;req_channel=API;req_credit=628125 6045457;req_debit=;req_number=6JF7IBD6IB;mode=v1;req_timestamp=20191015235959;req_fee=;insert=[insert];ReasonType=10003367;rewards_insert=[rewards_insert];rewards_notif=[rewards_notif];additional_rewards=[additional_rewards];additional_rewards_resp=[additional_rewards_resp
2019-10-16 00:00:01,154|22||p1209|testing123|testing456|p12091910160000019377314091|63822123456|1|F0 2|OutsideDateRange|OutsideDateRange;msisdn=6282225493773;promo
_id=1200;delta=0;shortcode=link_bari_cust;req_amount=135000;req_channel=API;req_credit=6282225493773 ;req_debit=;req_number=6JG2IBD6YA;mode=v1;req_timestamp=20191016000000;req_fee=;insert=[insert];ReasonType=10002829;rewards_insert=[rewards_insert];rewards_notif=[rewards_notif];additional_rewards=[additional_rewards];additional_rewards_resp=[additional_rewards_resp];sms_resp=
# 6  
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.

Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #739
Difficulty: Medium
BASIC was based on FORTRAN II.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check file creation Time minutes and if file older then 5 minutes execute some stuff

Hello all, Info: System RedHat 7.5 I need to create a script that based on the creation time, if the file is older then 5 minutes then execute some stuff, if not exit. I thought to get the creation time and minutes like this. CreationTime=$(stat -c %y /tmp/test.log | awk -F" " '{ print... (3 Replies)
Discussion started by: charli1
3 Replies

2. Shell Programming and Scripting

Grep a log file for the last 5 minutes of contents every 5 minutes

Hi all, System Ubuntu 16.04.3 LTS i have the following log INFO 2019-02-07 15:13:31,099] default: "POST /join/8550614e-3e94-4fa5-9ab2-135eefa69c1b HTTP/1.0" 500 2042 INFO 2019-02-07 15:13:31,569] default: "POST /join/6cb9c452-dcb1-45f3-bcca-e33f5d450105... (15 Replies)
Discussion started by: charli1
15 Replies

3. UNIX for Beginners Questions & Answers

How to convert days hours minutes seconds to minutes?

Hi, please help with below time conversion to minutes. one column values: 2 minutes 16 seconds 420 msec 43 seconds 750 msec 0 days 3 hours 29 minutes 58 seconds 480 msec 11 seconds 150 msec I need output in minutes(total elapsed time in minutes) (2 Replies)
Discussion started by: ramu.badugula
2 Replies

4. Shell Programming and Scripting

Grep lines between last hour timestamp and current timestamp

So basically I have a log file and each line in this log file starts with a timestamp: MON DD HH:MM:SS SEP 15 07:30:01 I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings. ... (1 Reply)
Discussion started by: nms
1 Replies

5. Shell Programming and Scripting

AIX : Need to convert UNIX Timestamp to normal timestamp

Hello , I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt Contents of... (6 Replies)
Discussion started by: rahul2662
6 Replies

6. Shell Programming and Scripting

Run a sql script on multiple $Oracle_SID at once and send an alert if reaches the threshold

I am trying to accomplish following tasks in my KSH script: Run a sql script on multiple $ORACLE_SID at once Sends an alert only if the threshold > 2 for any of the $ORACLE_SID Please advice as to how I can approach this!! Thanks in advance! (1 Reply)
Discussion started by: jd_2000
1 Replies

7. Shell Programming and Scripting

To check timestamp in logfile and display lines upto 3 hours before current timestamp

Hi Friends, I have the following logfile. Currently time in india is 07/31/2014 12:33:34 and i have the following content in logfile. I want to display only those entries which contain string 'Exception' within last 3 hours. In this case, it would be the last line only I can get the... (12 Replies)
Discussion started by: srkmish
12 Replies

8. Shell Programming and Scripting

Searching Error Message from a log life between timestamp of every 10 minutes

HI Everyone, My task is to search error messages last 10 minutes everytime from a log file. My script, date1=`date -d '10 minutes ago' "+%H:%M:%S"` date2=`date "+%H:%M:%S"` awk -v d1="${date1}" -v d2="${date2}" '$0~d1{p=1} $0~d2{p=0} p' filename No error getting in... (3 Replies)
Discussion started by: ctscbe
3 Replies

9. UNIX for Dummies Questions & Answers

How to compare a file by its timestamp and store in a different location whenever timestamp changes?

Hi All, I am new to unix programming. I am trying for a requirement and the requirement goes like this..... I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Discussion started by: mailsara
2 Replies

10. Shell Programming and Scripting

Convert minutes to hours, minutes, seconds

How would you convert lets say a 1000 minutes to hours, minutes, seconds (1 Reply)
Discussion started by: Vozx
1 Replies

Featured Tech Videos