netdata.service.in 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # SPDX-License-Identifier: GPL-3.0-or-later
  2. [Unit]
  3. Description=Real time performance monitoring
  4. # append here other services you want netdata to wait for them to start
  5. After=network.target network-online.target nss-lookup.target
  6. Wants=network-online.target nss-lookup.target
  7. [Service]
  8. LogNamespace=netdata
  9. Type=simple
  10. User=root
  11. RuntimeDirectory=netdata
  12. RuntimeDirectoryMode=0775
  13. PIDFile=/run/netdata/netdata.pid
  14. ExecStart=@sbindir_POST@/netdata -P /run/netdata/netdata.pid -D
  15. ExecStartPre=/bin/mkdir -p @localstatedir_POST@/cache/netdata
  16. ExecStartPre=/bin/chown -R @netdata_user_POST@ @localstatedir_POST@/cache/netdata
  17. ExecStartPre=/bin/mkdir -p /run/netdata
  18. ExecStartPre=/bin/chown -R @netdata_user_POST@ /run/netdata
  19. PermissionsStartOnly=true
  20. # saving a big db on slow disks may need some time
  21. TimeoutStopSec=150
  22. # restart netdata if it crashes
  23. Restart=on-failure
  24. RestartSec=30
  25. # Valid policies: other (the system default) | batch | idle | fifo | rr
  26. # To give netdata the max priority, set CPUSchedulingPolicy=rr and CPUSchedulingPriority=99
  27. CPUSchedulingPolicy=batch
  28. # This sets the scheduling priority (for policies: rr and fifo).
  29. # Priority gets values 1 (lowest) to 99 (highest).
  30. #CPUSchedulingPriority=1
  31. # For scheduling policy 'other' and 'batch', this sets the lowest niceness of netdata (-20 highest to 19 lowest).
  32. Nice=0
  33. # Capabilities
  34. # is required for freeipmi and slabinfo plugins
  35. CapabilityBoundingSet=CAP_DAC_OVERRIDE
  36. # is required for apps plugin
  37. CapabilityBoundingSet=CAP_DAC_READ_SEARCH
  38. # is required for freeipmi plugin
  39. CapabilityBoundingSet=CAP_FOWNER CAP_SYS_RAWIO
  40. # is required for apps, perf and slabinfo plugins
  41. CapabilityBoundingSet=CAP_SETPCAP
  42. # is required for perf plugin
  43. CapabilityBoundingSet=CAP_SYS_ADMIN CAP_PERFMON
  44. # is required for apps plugin
  45. CapabilityBoundingSet=CAP_SYS_PTRACE
  46. # is required for ebpf plugin
  47. CapabilityBoundingSet=CAP_SYS_RESOURCE
  48. # is required for go.d/ping app
  49. CapabilityBoundingSet=CAP_NET_RAW
  50. # is required for cgroups plugin
  51. CapabilityBoundingSet=CAP_SYS_CHROOT
  52. # is required for nfacct plugin (bandwidth accounting)
  53. CapabilityBoundingSet=CAP_NET_ADMIN
  54. # is required for plugins that use sudo
  55. CapabilityBoundingSet=CAP_SETGID CAP_SETUID
  56. # is required to change file ownership
  57. CapabilityBoundingSet=CAP_CHOWN
  58. # Sandboxing
  59. ProtectSystem=full
  60. ProtectHome=read-only
  61. # PrivateTmp break netdatacli functionality. See - https://github.com/netdata/netdata/issues/7587
  62. #PrivateTmp=true
  63. ProtectControlGroups=on
  64. # We whitelist this because it's the standard location to listen on a UNIX socket.
  65. ReadWriteDirectories=/run/netdata
  66. # This is needed to make email-based alert deliver work if Postfix is the email provider on the system.
  67. ReadWriteDirectories=-/var/spool/postfix/maildrop
  68. # LXCFS directories (https://github.com/lxc/lxcfs#lxcfs)
  69. # If we don't set them explicitly, systemd mounts procfs from the host. See https://github.com/netdata/netdata/issues/14238.
  70. BindReadOnlyPaths=-/proc/cpuinfo -/proc/diskstats -/proc/loadavg -/proc/meminfo
  71. BindReadOnlyPaths=-/proc/stat -/proc/swaps -/proc/uptime -/proc/slabinfo
  72. [Install]
  73. WantedBy=multi-user.target