Login

Statistici

Membri: 150
Stiri: 729
Linkuri: 20
Vizitatori: 1265829

We support LinTube

Arata-ti suportul

Citesti stirile pe MYLRo.org? Ai un site? Pune un link catre noi.

 
Anunta-ma daca un proces incarca sistemul E-mail
  • Currently 3.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Rating: 3.0/5 (2 votes cast)

Scris de Cypress   
Saturday, 15 December 2007
#!/bin/bash
#
# Script to notify admin user if Linux,FreeBSD load crossed certain limit
# It will send an email notification to admin.
# This is free script under GNU GPL version 2.0 or above.
# Support/FeedBack/comment : http://cyberciti.biz/fb/
# Tested os:
# * RedHat Linux
# * Debain Linux
# * FreeBSD


# Set up limit below
NOTIFY="6.0"

# admin user email id
EMAIL="root"

# Subject for email
SUBJECT="Alert $(hostname) load average"

# -----------------------------------------------------------------

# Os Specifc tweaks do not change anything below ;)
OS="$(uname)"
TRUE="1"
if [ "$OS" == "FreeBSD" ]; then
TEMPFILE="$(mktemp /tmp/$(basename $0).tmp.XXX)"
FTEXT='load averages:'
elif [ "$OS" == "Linux" ]; then
TEMPFILE="$(mktemp)"
FTEXT='load average:'
fi


# get first 5 min load
F5M="$(uptime | awk -F "$FTEXT" '{ print $2 }' | cut -d, -f1)"
# 10 min
F10M="$(uptime | awk -F "$FTEXT" '{ print $2 }' | cut -d, -f2)"
# 15 min
F15M="$(uptime | awk -F "$FTEXT" '{ print $2 }' | cut -d, -f3)"

# mail message
# keep it short coz we may send it to page or as an short message (SMS)
echo "Load average Crossed allowed limit $NOTIFY." >> $TEMPFILE
echo "Hostname: $(hostname)" >> $TEMPFILE
echo "Local Date & Time : $(date)" >> $TEMPFILE

# Look if it crossed limit
# compare it with last 15 min load average
RESULT=$(echo "$F15M > $NOTIFY" | bc)

# if so send an email
if [ "$RESULT" == "$TRUE" ]; then
mail -s "$SUBJECT" "$EMAIL" < $TEMPFILE
fi

# remove file
rm -f $TEMPFILE
Comments
Add NewSearchRSS
Only registered users can write comments!

Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved.


 

Ultimele comentarii

Softul saptamanii

WINE 1.0 RC1

Tips & Tricks

O arhivare mai buna cu gzip
Daca preferi ca arhivele tale gzip sa fie cat mai bine comprimate, foloseste comanda export GZIP=--best. Data viitoare cand vei arhiva cu gzip, comprimarea va fi facuta la cel mai inalt nivel.
 

Vizitatori Online

Avem 1 vizitator online