Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. #!/bin/bash
  2. #######################################
  3. # This script is designed to retrieve #
  4. # total system info for techincal #
  5. # discoveries. will retrieve cores, #
  6. # ram, amount of calls per day, and #
  7. # average load #
  8. # Creator: jamie charlton #
  9. #######################################
  10.  
  11.  
  12. while getopts ":hs" opt; do
  13. case ${opt} in
  14. h )
  15. echo -s
  16. echo used to specify to use sftp after running script
  17. echo if server does not allow outside sftp do not use
  18. echo
  19. echo
  20. exit 0
  21. ;;
  22. s )
  23. sftpstatus='true'
  24.  
  25. ;;
  26. /?)
  27. echo not a valid command,
  28. echo only valid commands are -s and -h
  29. echo which -h just tells you -s is the only command.
  30. echo so you might as well just use -s or nothing at all.
  31. exit 0
  32. ;;
  33. esac
  34. done
  35.  
  36.  
  37. #write cpu info
  38. echo CPU INFO: > ~/sysinfo.txt
  39. echo ---------------------------------------------------- >> ~/sysinfo.txt
  40. uptime >> ~/sysinfo.txt
  41. lscpu >> ~/sysinfo.txt
  42. echo >> ~/sysinfo.txt
  43.  
  44. #write storage info
  45. echo STORAGE: >> ~/sysinfo.txt
  46. echo ---------------------------------------------------- >> ~/sysinfo.txt
  47. df -H --output=source,size,used,avail >> ~/sysinfo.txt
  48. echo >> ~/sysinfo.txt
  49.  
  50. #write psql db info
  51. echo PSQL ENTRIES: >> ~/sysinfo.txt
  52. echo ---------------------------------------------------- >> ~/sysinfo.txt
  53. psql -U callrec -c "SELECT schemaname,relname,n_live_tup
  54. FROM pg_stat_user_tables
  55. ORDER BY n_live_tup DESC;" >> ~/sysinfo.txt
  56. echo Database Size: >> ~/sysinfo.txt
  57. du -ch /opt/callrec/data/psql | tail -n 1 >> ~/sysinfo.txt
  58. echo >> ~/sysinfo.txt
  59.  
  60. #write memory info
  61. echo MEMORY: >> ~/sysinfo.txt
  62. echo ----------------------------------------------------- >> ~/sysinfo.txt
  63. free -m | awk {'print $2 " " $3'} | head -n 2 >> ~/sysinfo.txt
  64. echo >> ~/sysinfo.txt
  65.  
  66. #write info for concurrent calls max
  67. echo LICENSE: >> ~/sysinfo.txt
  68. echo ----------------------------------------------------- >> ~/sysinfo.txt
  69. echo Maximum concurrent calls >> ~/sysinfo.txt
  70. echo
  71. /opt/callrec/bin/callrec-status -state all -name remoteJTAPI1 -verbosity 5 | grep Licensed | awk {'print $11'} | sed -e 's/(.*//g' >> ~/sysinfo.txt
  72. echo >> ~/sysinfo.txt
  73.  
  74. #write info related to call space/usage and amount
  75. echo AVERAGE DAY: >> ~/sysinfo.txt
  76. echo ----------------------------------------------------- >> ~/sysinfo.txt
  77. cd /opt/callrec/data/calls
  78. largestday="$(du | sort -n -k1 | tail -n 2 | head -n 1 | awk {'print $2'})"
  79. cd $largestday
  80. echo "Calls Per Day (estimate): " >> ~/sysinfo.txt
  81. ls -l | wc -l >> ~/sysinfo.txt
  82.  
  83. #create directory to store the files in for easy sftp or off transfer
  84. cd
  85. mkdir ~/techInfo
  86. mv ~/sysinfo.txt ~/techInfo/sysinfo.txt
  87.  
  88. #run cmdb and write it to that folder
  89. /opt/callrec/bin/scripts/cmdb.sh -d ~/techInfo
  90.  
  91. cd ~/
  92.  
  93. #handles the sftp declared by flag
  94. if [ $sftpstatus == 'true' ]; then
  95. read -p "Enter Your Name: " username
  96. read -p "Enter Server Url eg. file.zoomint.com: " fileUrl
  97. sftp "$username"@"$fileUrl"
  98. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement