All pastes #910926 Raw Edit

Someone

public text v1 · immutable
·published 2008-02-20 09:54 UTC
rendered paste body
#!/bin/bash

WM_TO='TO MAIL'
WM_FROM='FROM'

MAX_BW=50

ETH=`bwm-ng -c 1 -o plain |grep eth0`
BW=`echo $ETH |grep eth0 |awk {'print $6'}`
BW2=${BW/.*}
DAT=`date`

echo ----------------------
echo Current check date: $DAT
echo Status:
echo $ETH
echo ----------------------

if [ $BW2 -ge $MAX_BW ]; then
  echo Bandwidth is over $MAX_BW - Currently: $BW
  echo Prepearing a warning e-mail to $WM_TO

  echo From: $WM_FROM > .tmp_warnmail
  echo To: $WM_TO >> .tmp_warnmail
  echo Subject: Bandwidth Warning >> .tmp_warnmail
  echo >> .tmp_warnmail
  echo This is a automatic message sendt by Bandwidth Warning Script >> .tmp_$
  echo >> .tmp_warnmail
  echo This is sendt because the bandwidth was greater than $MAX_BW >> .tmp_w$
  echo Current stats $ETH >> .tmp_warnmail
  echo Current date: $DAT >> .tmp_warnmail
  sendmail -s 'Bandwidth Warning' $WM_TO < .tmp_warnmail
  rm -fR .tmp_warnmail
else
  echo Bandwidth is under $MBW - Curently: $BW
fi