Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ## This is an open Source script written for Optimize Linux Box.
- ## Author Mansur ul hasan
- ## Email mansurali901@gmail.com
- clear
- #<!------------- Notification Setting function
- notification_func(){
- echo > /usr/local/cron/emailtemplates
- if [ ! -f "/usr/local/cron/smart-disk-scanner/emaillist" ]; then
- read -p "Enter the Email Address for notification : " email
- echo $email > /usr/local/cron/smart-disk-scanner/emaillist
- fi;
- }
- #<!----- Information gathering menu for Disks
- info_grab_func(){
- ipinfo=`ifconfig eth0 | awk '{print $2}' |grep addr | cut -d':' -f2`
- 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 "97" ]; then
- hostname=$(hostname)
- useemail=$(cat /usr/local/cron/smart-disk-scanner/emaillist)
- ipinfo=`ifconfig eth0 | awk '{print $2}' |grep addr | cut -d':' -f2`
- echo $ipinfo
- echo "
- %% SYSTEM DISK INFORMATION %%
- |------------------------------------------------------------------------------|
- | DATE : $(date)
- |
- | SERVER NAME : $(hostname)
- |
- | Partiotion : $partition
- |
- | Used Space : ($usep%)
- |------------------------------------------------------------------------------|
- Hey System Admins Please check the Servers Disk....!!!
- ----------------------------------------------------------------------
- Note : To unsubscribe this mailing list please contact NASA Department
- ----------------------------------------------------------------------
- This monitoring system is the part of Linux Genius v1.1
- For suuport please do contact at itmarkazsupport@hotmail.com
- " >/usr/local/cron/smart-disk-scanner/emailtemplates
- for em in `cat /usr/local/cron/smart-disk-scanner/emaillist`
- do
- mailx -r alert@yourdomain.com -s "Linux Genius Alert Host $hostname : Disk space reached to $usep%" $em < /usr/local/cron/smart-disk-scanner/emailtemplates
- mailx -r alert@etilizepak.com -s "Linux Genius Alert Host $hostname : Disk space reached to $usep%" mansurali901@gmail.com < /usr/local/cron/smart-disk-scanner/emailtemplates
- done
- fi
- done
- }
- #<!--------- Cron Insertion Function
- cron_insert_func(){
- sh ~/linux-genious-1.1/disk/./cron.sh
- }
- #notification_func
- #main_init
- #<!----- Argument Passing Menu
- case $1 in
- --config)
- # echo "Config Function "
- notification_func
- ;;
- --task)
- info_grab_func
- ;;
- --cron)
- cronchk=$(crontab -l)
- case $cronchk in
- *"--task"*)
- echo "Cron is already added "
- ;;
- *)
- cron_insert_func
- ;;
- esac
- ;;
- *)
- echo "Not a Valid Argument"
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement