Advertisement
Guest User

Untitled

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