runtime-check.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/sh
  2. wait_for() {
  3. host="${1}"
  4. port="${2}"
  5. name="${3}"
  6. timeout="30"
  7. if command -v nc > /dev/null ; then
  8. netcat="nc"
  9. elif command -v netcat > /dev/null ; then
  10. netcat="netcat"
  11. else
  12. printf "Unable to find a usable netcat command.\n"
  13. return 1
  14. fi
  15. printf "Waiting for %s on %s:%s ... " "${name}" "${host}" "${port}"
  16. sleep 30
  17. i=0
  18. while ! ${netcat} -z "${host}" "${port}"; do
  19. sleep 1
  20. if [ "$i" -gt "$timeout" ]; then
  21. printf "Timed out!\n"
  22. return 2
  23. fi
  24. i="$((i + 1))"
  25. done
  26. printf "OK\n"
  27. }
  28. wait_for localhost 19999 netdata
  29. case $? in
  30. 1) exit 2 ;;
  31. 2) exit 3 ;;
  32. esac
  33. curl -sfS http://127.0.0.1:19999/api/v1/info > ./response || exit 1
  34. cat ./response
  35. jq '.version' ./response || exit 1
  36. curl -sfS http://127.0.0.1:19999/index.html || exit 1
  37. curl -sfS http://127.0.0.1:19999/v0/index.html || exit 1
  38. curl -sfS http://127.0.0.1:19999/v1/index.html || exit 1
  39. curl -sfS http://127.0.0.1:19999/v2/index.html || exit 1
  40. NETDATA_LIBEXEC_PARTS="
  41. plugins.d/apps.plugin
  42. plugins.d/cgroup-network
  43. plugins.d/charts.d.plugin
  44. plugins.d/cups.plugin
  45. plugins.d/debugfs.plugin
  46. plugins.d/ebpf.plugin
  47. plugins.d/freeipmi.plugin
  48. plugins.d/go.d.plugin
  49. plugins.d/ioping.plugin
  50. plugins.d/local-listeners
  51. plugins.d/ndsudo
  52. plugins.d/network-viewer.plugin
  53. plugins.d/nfacct.plugin
  54. plugins.d/perf.plugin
  55. plugins.d/python.d.plugin
  56. plugins.d/slabinfo.plugin
  57. plugins.d/xenstat.plugin
  58. "
  59. if [ -d "${NETDATA_LIBEXEC_PREFIX}" ]; then
  60. success=1
  61. for part in ${NETDATA_LIBEXEC_PARTS}; do
  62. # shellcheck disable=SC2254
  63. if echo "${part}" | grep -qE "${NETDATA_SKIP_LIBEXEC_PARTS}"; then
  64. continue
  65. fi
  66. if [ ! -x "${NETDATA_LIBEXEC_PREFIX}/${part}" ]; then
  67. success=0
  68. echo "!!! ${NETDATA_LIBEXEC_PREFIX}/${part} is missing"
  69. fi
  70. done
  71. if [ "${success}" -eq 0 ]; then
  72. exit 1
  73. fi
  74. fi