Send email if logs has value threshold
by dr.x from LinuxQuestions.org on (#4T3TV)
Hello Folks ,
i have a tail -f log pointing to a log file .
i have smtp setup on why server and i can send emails using sendmail command .
#################
i just want to make a rule such as the tail -f keep looking on the file :
tail -f /var/log/ipfw/*.log | grep --line-buffered google.com | grep --line-buffered -v -E "45.147.|66.12.239.118" | awk -F" " '{print $1,$6,$12,$17,"-->" length($17)}'
The result is as below :
24/Oct/2019:11:55:06 12.4.15.66 jan 461324 -->6
24/Oct/2019:11:55:06 12.4.15.66 jan 1110431 -->7
24/Oct/2019:11:55:06 66.10.130.75 kevin 274722 -->6
24/Oct/2019:11:55:06 104.6.15.126 jan 489653 -->6
24/Oct/2019:11:55:06 12.34.130.75 kevin 191924 -->6
24/Oct/2019:11:55:11 1.12.15.71 kevin 210375 -->6
24/Oct/2019:11:55:11 104.5.239.119 kevin 276696 -->6
###########################################
as you see above , last column its 6 , 7 values .
lets take an example , 24/Oct/2019:11:55:06 12.4.15.66 jan 461324 -->6 .
i want to send an email to dr.x@gmail.com if value is less than 4 in the last column , and email should contain subject as "Jan" and in email contents it should have :
24/Oct/2019:11:55:06 12.4.15.66 jan 461324 --> value that less than 4
#####################
Can you help me what do i need to add with tail -f command to achieve the email sending function ?
Thanks a lot !


i have a tail -f log pointing to a log file .
i have smtp setup on why server and i can send emails using sendmail command .
#################
i just want to make a rule such as the tail -f keep looking on the file :
tail -f /var/log/ipfw/*.log | grep --line-buffered google.com | grep --line-buffered -v -E "45.147.|66.12.239.118" | awk -F" " '{print $1,$6,$12,$17,"-->" length($17)}'
The result is as below :
24/Oct/2019:11:55:06 12.4.15.66 jan 461324 -->6
24/Oct/2019:11:55:06 12.4.15.66 jan 1110431 -->7
24/Oct/2019:11:55:06 66.10.130.75 kevin 274722 -->6
24/Oct/2019:11:55:06 104.6.15.126 jan 489653 -->6
24/Oct/2019:11:55:06 12.34.130.75 kevin 191924 -->6
24/Oct/2019:11:55:11 1.12.15.71 kevin 210375 -->6
24/Oct/2019:11:55:11 104.5.239.119 kevin 276696 -->6
###########################################
as you see above , last column its 6 , 7 values .
lets take an example , 24/Oct/2019:11:55:06 12.4.15.66 jan 461324 -->6 .
i want to send an email to dr.x@gmail.com if value is less than 4 in the last column , and email should contain subject as "Jan" and in email contents it should have :
24/Oct/2019:11:55:06 12.4.15.66 jan 461324 --> value that less than 4
#####################
Can you help me what do i need to add with tail -f command to achieve the email sending function ?
Thanks a lot !