I am looking to create a script that will run daily via a cron job that:
- output 15 lines or more of logs to a file if they occur in a 15 minute time frame and contain the keyword 'disconnects'
- email the output of the file after script is done running
Here is a sample log:
May 13 12:23:06 10.0.0.1 syslog: eventd_to_syslog():User[00:00:00:00:00:00] disconnects from WLAN[SSID-Name] at AP[AP-Name@00:00:00:00:00:00]
I have created the script below to parse and sort the logfile.log by AP and date/time. I just need to output the frequent logs of any disconnects that occur within a 15 minute time frame to a file and email that file to our network team.
#!/bin/bash filename='aplist' filelines=`cat $filename` for line in $filelines; do grep -v Guest logfile.log | grep disconnects | sort -k 11 > 1-test-output done