v_update_sys_rrd 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. # info: update system rrd charts
  3. # options: period
  4. #
  5. # The script is wrapper for all rrd functions. It updates all
  6. # v_update_sys_rrd_* at once.
  7. #----------------------------------------------------------#
  8. # Variable&Function #
  9. #----------------------------------------------------------#
  10. # Importing system enviroment as we run this script
  11. # mostly by cron wich do not read it by itself
  12. source /etc/profile.d/vesta.sh
  13. # Importing variables
  14. source $VESTA/conf/vars.conf
  15. source $V_CONF/vesta.conf
  16. source $V_FUNC/shared.func
  17. # Another workaround for cron enviroment
  18. PATH="$PATH:$V_BIN"
  19. export PATH
  20. # Argument defenition
  21. period=$1
  22. # Checking rrddir
  23. if [ ! -d "$V_RRD" ]; then
  24. mkdir -p $V_RRD
  25. fi
  26. #----------------------------------------------------------#
  27. # Action #
  28. #----------------------------------------------------------#
  29. # Updateing system stats
  30. $V_BIN/v_update_sys_rrd_la $period
  31. $V_BIN/v_update_sys_rrd_net $period
  32. $V_BIN/v_update_sys_rrd_mem $period
  33. $V_BIN/v_update_sys_rrd_ssh $period
  34. # Updating web stats
  35. if [ "$WEB_SYSTEM" = 'apache' ]; then
  36. $V_BIN/v_update_sys_rrd_httpd $period
  37. fi
  38. if [ "$PROXY_SYSTEM" = 'nginx' ]; then
  39. $V_BIN/v_update_sys_rrd_nginx $period
  40. fi
  41. # Updating ftp stats
  42. if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then
  43. $V_BIN/v_update_sys_rrd_ftp $period
  44. fi
  45. # Updating db stats
  46. if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
  47. for type in ${DB_SYSTEM//,/ }; do
  48. # Switching on db type
  49. case $type in
  50. mysql) $V_BIN/v_update_sys_rrd_mysql $period ;;
  51. pgsql) $V_BIN/v_update_sys_rrd_pgsql $period ;;
  52. esac
  53. done
  54. fi
  55. #----------------------------------------------------------#
  56. # Vesta #
  57. #----------------------------------------------------------#
  58. # Logging
  59. log_event 'system' "$V_EVENT"
  60. exit