Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using a Script that would automatically do a dump of the attack as soon as it exceeds a threshold. The scripts looks like the following:

interface=eth0
dumpdir=/tmp/

while /bin/true; do
  pkt_old=`grep $interface: /proc/net/dev | cut -d :  -f2 | awk '{ print $2 }'`
  sleep 1
  pkt_new=`grep $interface: /proc/net/dev | cut -d :  -f2 | awk '{ print $2 }'`



  pkt=$(( $pkt_new - $pkt_old ))

  echo -ne "\r$pkt packets/s\033[0K"


  if [ $pkt -gt 10000  ]; then
    echo -e "\n`date` Under attack, dumping packets."
    tcpdump -nn -s0 -c 2000 -w $dumpdir/dump.`date +"%Y%m%d-%H%M%S"`.cap
    echo "`date` Packets dumped, sleeping now."
    sleep 300
  fi
done

I want the same Script to send an Email to a specified address to notify the Admin if the server was attacked. How should we achieve this?

share|improve this question
1  
man mail: mail -s "Subejct" <Text> <User> –  l1zard Aug 16 '13 at 18:23
    
I tried "echo Hey | mail -s Test Test@mail.com" but nothing was received. –  Asad Moeen Aug 16 '13 at 18:33
    
In /var/mail/mail I got this " Mailing to remote domains not supported" –  Asad Moeen Aug 16 '13 at 18:35
    
Fixed it by installing sendmail, thanks. –  Asad Moeen Aug 16 '13 at 18:44
    
@AsadMoeen Then please delete this question or provide your own answer and mark it as accepted, if you do not it will keep popping to the front page as a open question with no accepted answer. –  Scott Chamberlain Aug 16 '13 at 22:09
add comment

1 Answer 1

up vote 0 down vote accepted

So I did it with the following command.

echo Hey | mail -s Test Test@mail.com

The above command didn't work so I fixed it by installing sendmail which wasn't installed by default.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.