Advertisement
Guest User

Untitled

a guest
Feb 14th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.95 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Variables for notify
  4. email_in="root@***"
  5. email_out="notify@***"
  6. subject="Notification for missed call"
  7. smtp="SMTP_SERVER"
  8. email_out_password="PASSWORD"
  9. date=$(date)
  10.  
  11. # Variables for log analyze
  12. log="PATH_TO_QUEUE_LOG"
  13. queue="NAME_OF_QUEUE"
  14. x=0
  15. total=0
  16.  
  17. cmd=$(cat $log | grep $queue )
  18. if [ $? -eq 0 ]; then
  19.     id=$(echo "${cmd}" | grep ABANDON | tail -n1 | sed 's\|\ \g' | awk '{print $2}' | sed 's/\./ /g' | awk '{print $2}' )
  20.     number=$(echo "${cmd}" | grep $id | grep ENTERQUEUE | sed 's\|\ \g' | awk '{print $6}' | tail -n1)
  21.     echo $number
  22. else
  23.     echo ERROR
  24. fi
  25. if [ "$lastnumber" -eq "$number" ]; then
  26.     export lastnumber=$number
  27. else
  28.     export lastnumber=$number
  29.     sendnotify=$(echo "New missed call! \n Client: $number \n Time: $date" | mailx -v -r "$email_out" -s "$subject" -S smtp="$smtp" -S smtp-auth=login -S smtp-auth-user="$email_out" -S smtp-auth-password="$email_out_password" -S ssl-verify=ignore $email_in &> /dev/null)
  30. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement