Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.33 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. echo cpu info: > ~/sysinfo.txt
  11. echo ---------------------------------------------------- >> ~/sysinfo.txt
  12. echo >> ~/sysinfo.txt
  13. uptime >> ~/sysinfo.txt
  14. lscpu  >> ~/sysinfo.txt
  15. echo >> ~/sysinfo.txt
  16. echo Storage: >> ~/sysinfo.txt
  17. echo ---------------------------------------------------- >> ~/sysinfo.txt
  18. df -H --output=source,size,used,avail  >> ~/sysinfo.txt
  19. echo >> ~/sysinfo.txt
  20. echo psql entries: >> ~/sysinfo.txt  
  21. echo ---------------------------------------------------- >> ~/sysinfo.txt
  22. psql -U callrec -c "SELECT schemaname,relname,n_live_tup
  23.  FROM pg_stat_user_tables
  24.  ORDER BY n_live_tup DESC;" >> ~/sysinfo.txt
  25. echo Database Size: >> ~/sysinfo.txt
  26. du -ch /opt/callrec/data/psql | tail -n 1 >> ~/sysinfo.txt
  27. echo   >> ~/sysinfo.txt
  28. echo Memory: >> ~/sysinfo.txt
  29. echo ----------------------------------------------------- >> ~/sysinfo.txt
  30. free -m | awk {'print $2 "   "  $3'} | head -n 2 >> ~/sysinfo.txt
  31. echo       >> ~/sysinfo.txt
  32. echo license info:  >> ~/sysinfo.txt
  33. echo ----------------------------------------------------- >> ~/sysinfo.txt
  34. /opt/callrec/bin/callrec-status -state all -name remoteJTAPI1 -verbosity 5 | grep Licensed | awk {'print $11'} | sed -e 's/(.*//g' >> ~/sysinfo.txt
  35. echo   >> ~/sysinfo.txt
  36. echo Average Day: >> ~/sysinfo.txt
  37. echo ----------------------------------------------------- >> ~/sysinfo.txt
  38. cd /opt/callrec/data/calls
  39. largestday="$(du | sort -n -k1 | tail -n 2 | head -n 1 | awk {'print $2'})"
  40. cd $largestday
  41. echo Calls for day: >> ~/sysinfo.txt
  42. ls -l | wc -l >> ~/sysinfo.txt
  43.  
  44. cd
  45. mkdir ~/techInfo
  46. mv ~/sysinfo.txt ~/techInfo/sysinfo.txt
  47.  
  48. /opt/callrec/bin/scripts/cmdb.sh -d ~/techInfo
  49.  
  50. while getopts "bf:" OPTION
  51. do
  52.     case $OPTION in
  53.         s)
  54.       echo Uploading To SFTP
  55.             read -p "Enter Your Name: "  username
  56.       read -p "Enter Server Url eg. file.zoomint.com"  fileUrl
  57.       sftp $username@$fileUrl
  58.  
  59.             exit
  60.             ;;
  61.         \?)
  62.             echo The only current flag is -s
  63.       echo -s is used to upload outputs to sftp
  64.             exit
  65.             ;;
  66.     esac
  67. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement