ebpf_thread_function.sh.in 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. netdata_ebpf_test_functions() {
  3. echo "QUERYING: ${1}"
  4. curl -k -o /tmp/ebpf_netdata_test_functions.txt "${1}"
  5. TEST=$?
  6. if [ $TEST -ne 0 ]; then
  7. echo "Cannot request run a for ${1}. See '/tmp/ebpf_netdata_test_functions.txt' for more details."
  8. exit 1
  9. fi
  10. grep "${2}" /tmp/ebpf_netdata_test_functions.txt >/dev/null
  11. TEST=$?
  12. if [ $TEST -ne 0 ]; then
  13. echo "Cannot find ${2} in the output. See '/tmp/ebpf_netdata_test_functions.txt' for more details.."
  14. exit 1
  15. fi
  16. rm /tmp/ebpf_netdata_test_functions.txt
  17. }
  18. MURL="http://127.0.0.1:19999"
  19. INTERVAL=60
  20. if [ -n "$1" ]; then
  21. MURL="$1"
  22. fi
  23. # Check function loaded
  24. netdata_ebpf_test_functions "${MURL}/api/v1/functions" "ebpf_thread"
  25. # Check function help
  26. netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20help" "allows user to control eBPF threads"
  27. #Test default request
  28. netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread" "columns"
  29. #Test thread requests . The mdflush is not enabled, because it is not present in all distributions by default.
  30. #Socket is not in the list, because it will have a complete refactory with next PR
  31. for THREAD in "cachestat" "dc" "disk" "fd" "filesystem" "hardirq" "mount" "oomkill" "process" "shm" "softirq" "sync" "swap" "vfs" ;
  32. do
  33. echo "TESTING ${THREAD}"
  34. netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20enable:${THREAD}:${INTERVAL}%20thread:${THREAD}"
  35. sleep 17
  36. netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20thread:${THREAD}" "running"
  37. sleep 17
  38. netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20disable:${THREAD}"
  39. sleep 6
  40. netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20thread:${THREAD}" "stopped"
  41. sleep 6
  42. done