Advertisement
Guest User

Untitled

a guest
Nov 4th, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. #!/bin/bash
  2. ## This is an open Source script written for Optimize Linux Box.
  3. ## Author Mansur ul hasan
  4.  
  5. clear
  6.  
  7. #<!------------- Notification Setting function
  8.  
  9. notification_func(){
  10. echo > /usr/local/cron/emailtemplates
  11.  
  12. if [ ! -f "/usr/local/cron/smart-disk-scanner/emaillist" ]; then
  13. read -p "Enter the Email Address for notification : " email
  14. echo $email > /usr/local/cron/smart-disk-scanner/emaillist
  15. fi;
  16. }
  17.  
  18. #<!----- Information gathering menu for Disks
  19.  
  20. info_grab_func(){
  21.  
  22. ipinfo=`ifconfig eth0 | awk '{print $2}' |grep addr | cut -d':' -f2`
  23.  
  24. df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
  25. do
  26. echo $output
  27. usep=$(echo $output | awk '{print $1}' | cut -d'%' -f1 )
  28. partition=$(echo $output | awk '{print $2}' )
  29. if [ "$usep" -ge "97" ]; then
  30.  
  31. hostname=$(hostname)
  32. useemail=$(cat /usr/local/cron/smart-disk-scanner/emaillist)
  33. ipinfo=`ifconfig eth0 | awk '{print $2}' |grep addr | cut -d':' -f2`
  34. echo $ipinfo
  35. echo "
  36.  
  37. %% SYSTEM DISK INFORMATION %%
  38. |------------------------------------------------------------------------------|
  39. | DATE : $(date)
  40. |
  41. | SERVER NAME : $(hostname)
  42. |
  43. | Partiotion : $partition
  44. |
  45. | Used Space : ($usep%)
  46. |------------------------------------------------------------------------------|
  47.  
  48. Hey System Admins Please check the Servers Disk....!!!
  49.  
  50. ----------------------------------------------------------------------
  51. Note : To unsubscribe this mailing list please contact NASA Department
  52. ----------------------------------------------------------------------
  53. This monitoring system is the part of Linux Genius v1.1
  54. For suuport please do contact at [email protected]
  55. " >/usr/local/cron/smart-disk-scanner/emailtemplates
  56.  
  57. for em in `cat /usr/local/cron/smart-disk-scanner/emaillist`
  58. do
  59. mailx -r [email protected] -s "Linux Genius Alert Host $hostname : Disk space reached to $usep%" $em < /usr/local/cron/smart-disk-scanner/emailtemplates
  60. mailx -r [email protected] -s "Linux Genius Alert Host $hostname : Disk space reached to $usep%" [email protected] < /usr/local/cron/smart-disk-scanner/emailtemplates
  61. done
  62. fi
  63. done
  64. }
  65.  
  66. #<!--------- Cron Insertion Function
  67. cron_insert_func(){
  68. sh ~/linux-genious-1.1/disk/./cron.sh
  69.  
  70. }
  71. #notification_func
  72. #main_init
  73.  
  74. #<!----- Argument Passing Menu
  75.  
  76. case $1 in
  77. --config)
  78. # echo "Config Function "
  79. notification_func
  80. ;;
  81. --task)
  82. info_grab_func
  83. ;;
  84. --cron)
  85. cronchk=$(crontab -l)
  86. case $cronchk in
  87. *"--task"*)
  88. echo "Cron is already added "
  89. ;;
  90. *)
  91. cron_insert_func
  92. ;;
  93. esac
  94. ;;
  95. *)
  96. echo "Not a Valid Argument"
  97. ;;
  98. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement