[PowerShell] Linux下全方位监控主机系统状况脚本 →→→→→进入此内容的聊天室

来自 , 2020-04-30, 写在 PowerShell, 查看 123 次.
URL http://www.code666.cn/view/b91f5a1e
  1. #!/bin/bash
  2.  
  3. # check_xu.sh
  4.  
  5. # 0 * * * * /home/check_xu.sh
  6.  
  7. DAT=”`date +%Y%m%d`”
  8.  
  9. HOUR=”`date +%H`”
  10.  
  11. DIR=/home/oslog/host_${DAT}/${HOUR}
  12.  
  13. DELAY=60
  14.  
  15. COUNT=60
  16.  
  17. # whether the responsible directory exist
  18.  
  19. if ! test -d ${DIR}
  20.  
  21. then
  22.  
  23. /bin/mkdir -p ${DIR}
  24.  
  25. fi
  26.  
  27. # general check
  28.  
  29. export TERM=linux
  30.  
  31. /usr/bin/top -b -d ${DELAY} -n ${COUNT} > ${DIR}/top_${DAT}.log 2>&1 &
  32.  
  33. # cpu check
  34.  
  35. /usr/bin/sar -u ${DELAY} ${COUNT} > ${DIR}/cpu_${DAT}.log 2>&1 &
  36.  
  37. #/usr/bin/mpstat -P 0 ${DELAY} ${COUNT} > ${DIR}/cpu_0_${DAT}.log 2>&1 &
  38.  
  39. #/usr/bin/mpstat -P 1 ${DELAY} ${COUNT} > ${DIR}/cpu_1_${DAT}.log 2>&1 &
  40.  
  41. # memory check
  42.  
  43. /usr/bin/vmstat ${DELAY} ${COUNT} > ${DIR}/vmstat_${DAT}.log 2>&1 &
  44.  
  45. # I/O check
  46.  
  47. /usr/bin/iostat ${DELAY} ${COUNT} > ${DIR}/iostat_${DAT}.log 2>&1 &
  48.  
  49. # network check
  50.  
  51. /usr/bin/sar -n DEV ${DELAY} ${COUNT} > ${DIR}/net_${DAT}.log 2>&1 &
  52.  
  53. #/usr/bin/sar -n EDEV ${DELAY} ${COUNT} > ${DIR}/net_edev_${DAT}.log 2>&1 &
  54.  
  55.  
  56. //shell/5374

回复 "Linux下全方位监控主机系统状况脚本"

这儿你可以回复上面这条便签

captcha