Step:1
Make a file & named "disk-alert" & copy below contents in it.
######################################################################
# set admin email so that you can get email
ADMIN="abc@xyz.com" (Mention Your Mail Id Here)
# set alert level 90% is default (Set Usage Level as per the need)
ALERT=90
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
#echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge $ALERT ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
mail -s "Alert: Almost out of disk space $usep" $ADMIN
fi
done
######################################################################
Step:2
Edit "crontab" & make below setting.
crontab -e
59 23 * * * /root/script/diskalert
Save & Exit (:wq)
Step:3
service crond start
service sendmail start
chkconfig crond on
chkconfig sendmail on
Simple Script for extract compressed file
Simple Script for extract compressed file
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
Shell Script To Get User Input
#!/bin/bash
echo "Shell Script To Get User Input";
while read inputline
do
what="$inputline"
echo $what;
if [ -z "${what}" ];
then
exit
fi
done
Question: What is the broadcast address of the network 172.31.94.0/23?
No comments:
Post a Comment