netdata.spec.in 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. # SPDX-License-Identifier: GPL-3.0-or-later
  2. %global contentdir %{_datadir}/netdata
  3. # This is temporary and should eventually be resolved. This bypasses
  4. # the default rhel __os_install_post which throws a python compile
  5. # error.
  6. %global __os_install_post %{nil}
  7. #
  8. # Conditional build:
  9. %bcond_without systemd # systemd
  10. %bcond_with nfacct # build with nfacct plugin
  11. %bcond_with freeipmi # build with freeipmi plugin
  12. %bcond_with netns # build with netns support (cgroup-network)
  13. %if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version} >= 1140
  14. %else
  15. %undefine with_systemd
  16. %undefine with_netns
  17. %endif
  18. %if %{with systemd}
  19. %if 0%{?suse_version}
  20. %global netdata_initd_buildrequires \
  21. BuildRequires: systemd-rpm-macros \
  22. %{nil}
  23. %global netdata_initd_requires \
  24. %{?systemd_requires} \
  25. %{nil}
  26. %global netdata_init_post %service_add_post netdata.service
  27. %global netdata_init_preun %service_del_preun netdata.service
  28. %global netdata_init_postun %service_del_postun netdata.service
  29. %else
  30. %global netdata_initd_buildrequires \
  31. BuildRequires: systemd
  32. %global netdata_initd_requires \
  33. Requires(preun): systemd-units \
  34. Requires(postun): systemd-units \
  35. Requires(post): systemd-units \
  36. %{nil}
  37. %global netdata_init_post %systemd_post netdata.service
  38. %global netdata_init_preun %systemd_preun netdata.service
  39. %global netdata_init_postun %systemd_postun_with_restart netdata.service
  40. %endif
  41. %else
  42. %global netdata_initd_buildrequires %{nil}
  43. %global netdata_initd_requires \
  44. Requires(post): chkconfig \
  45. %{nil}
  46. %global netdata_init_post \
  47. /sbin/chkconfig --add netdata \
  48. %{nil}
  49. %global netdata_init_preun %{nil} \
  50. if [ $1 = 0 ]; then \
  51. /sbin/service netdata stop > /dev/null 2>&1 \
  52. /sbin/chkconfig --del netdata \
  53. fi \
  54. %{nil}
  55. %global netdata_init_postun %{nil} \
  56. if [ $1 != 0 ]; then \
  57. /sbin/service netdata condrestart 2>&1 > /dev/null \
  58. fi \
  59. %{nil}
  60. %endif
  61. %if 0%{?_fedora}
  62. %global netdata_recommends \
  63. Recommends: curl \
  64. Recommends: iproute-tc \
  65. Recommends: lm_sensors \
  66. Recommends: nmap-ncat \
  67. Recommends: nodejs \
  68. Recommends: python \
  69. Recommends: PyYAML \
  70. Recommends: python2-PyMySQL \
  71. Recommends: python2-psycopg2 \
  72. %{nil}
  73. %else
  74. %global netdata_recommends %{nil}
  75. %endif
  76. Summary: Real-time performance monitoring, done right
  77. Name: @PACKAGE_NAME@
  78. Version: @PACKAGE_RPM_VERSION@
  79. Release: 1%{?dist}
  80. License: GPLv3+
  81. Group: Applications/System
  82. Source0: https://github.com/netdata/%{name}/releases/download/v@PACKAGE_VERSION@/%{name}-@PACKAGE_VERSION@.tar.gz
  83. URL: http://my-netdata.io
  84. BuildRequires: pkgconfig
  85. BuildRequires: xz
  86. BuildRequires: zlib-devel
  87. BuildRequires: libuuid-devel
  88. Requires: zlib
  89. Requires: libuuid
  90. # Packages can be found in the EPEL repo
  91. %if %{with nfacct}
  92. BuildRequires: libmnl-devel
  93. BuildRequires: libnetfilter_acct-devel
  94. Requires: libmnl
  95. Requires: libnetfilter_acct
  96. %endif
  97. %if %{with freeipmi}
  98. BuildRequires: freeipmi-devel
  99. Requires: freeipmi
  100. %endif
  101. Requires(pre): /usr/sbin/groupadd
  102. Requires(pre): /usr/sbin/useradd
  103. Requires(post): libcap
  104. %{netdata_initd_buildrequires}
  105. %{netdata_recommends}
  106. %{netdata_initd_requires}
  107. %description
  108. netdata is the fastest way to visualize metrics. It is a resource
  109. efficient, highly optimized system for collecting and visualizing any
  110. type of realtime timeseries data, from CPU usage, disk activity, SQL
  111. queries, API calls, web site visitors, etc.
  112. netdata tries to visualize the truth of now, in its greatest detail,
  113. so that you can get insights of what is happening now and what just
  114. happened, on your systems and applications.
  115. %prep
  116. %setup -q -n @PACKAGE_NAME@-@PACKAGE_VERSION@
  117. %build
  118. %configure \
  119. --with-zlib \
  120. --with-math \
  121. %{?with_nfacct:--enable-plugin-nfacct} \
  122. %{?with_freeipmi:--enable-plugin-freeipmi} \
  123. --with-user=netdata
  124. %{__make} %{?_smp_mflags}
  125. %install
  126. rm -rf "${RPM_BUILD_ROOT}"
  127. %{__make} %{?_smp_mflags} DESTDIR="${RPM_BUILD_ROOT}" install
  128. find "${RPM_BUILD_ROOT}" -name .keep -delete
  129. install -m 644 -p system/netdata.conf "${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}"
  130. install -m 755 -d "${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d"
  131. install -m 644 -p system/netdata.logrotate "${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name}"
  132. %if %{with systemd}
  133. install -m 755 -d "${RPM_BUILD_ROOT}%{_unitdir}"
  134. install -m 644 -p system/netdata.service "${RPM_BUILD_ROOT}%{_unitdir}/netdata.service"
  135. %else
  136. # install SYSV init stuff
  137. install -d "${RPM_BUILD_ROOT}/etc/rc.d/init.d"
  138. install -m 755 system/netdata-init-d \
  139. "${RPM_BUILD_ROOT}/etc/rc.d/init.d/netdata"
  140. %endif
  141. %pre
  142. getent group netdata >/dev/null || groupadd -r netdata
  143. getent group docker >/dev/null || groupadd -r docker
  144. getent passwd netdata >/dev/null || \
  145. useradd -r -g netdata -G docker -s /sbin/nologin \
  146. -d %{contentdir} -c "netdata" netdata
  147. %post
  148. %{netdata_init_post}
  149. %preun
  150. %{netdata_init_preun}
  151. %postun
  152. %{netdata_init_postun}
  153. %clean
  154. rm -rf "${RPM_BUILD_ROOT}"
  155. %files
  156. %doc README.md
  157. %defattr(-,root,root)
  158. %dir %{_sysconfdir}/%{name}
  159. %dir %{_libdir}/%{name}
  160. %config %{_sysconfdir}/%{name}/*.conf
  161. #%config %{_sysconfdir}/%{name}/charts.d/*.conf
  162. #%config %{_sysconfdir}/%{name}/health.d/*.conf
  163. #%config %{_sysconfdir}/%{name}/node.d/*.conf
  164. #%config %{_sysconfdir}/%{name}/python.d/*.conf
  165. #%config %{_sysconfdir}/%{name}/statsd.d/*.conf
  166. %config %{_sysconfdir}/logrotate.d/%{name}
  167. %{_libdir}/%{name}
  168. %{_libexecdir}/%{name}
  169. %{_sbindir}/%{name}
  170. %{_sysconfdir}/%{name}/edit-config
  171. %caps(cap_dac_read_search,cap_sys_ptrace=ep) %attr(0550,root,netdata) %{_libexecdir}/%{name}/plugins.d/apps.plugin
  172. %if %{with netns}
  173. # cgroup-network detects the network interfaces of CGROUPs
  174. # it must be able to use setns() and run cgroup-network-helper.sh as root
  175. # the helper script reads /proc/PID/fdinfo/* files, runs virsh, etc.
  176. %caps(cap_setuid=ep) %attr(4550,root,netdata) %{_libexecdir}/%{name}/plugins.d/cgroup-network
  177. %attr(0550,root,root) %{_libexecdir}/%{name}/plugins.d/cgroup-network-helper.sh
  178. %endif
  179. %if %{with freeipmi}
  180. %caps(cap_setuid=ep) %attr(4550,root,netdata) %{_libexecdir}/%{name}/plugins.d/freeipmi.plugin
  181. %endif
  182. %attr(0770,netdata,netdata) %dir %{_localstatedir}/cache/%{name}
  183. %attr(0770,netdata,netdata) %dir %{_localstatedir}/log/%{name}
  184. %attr(0770,netdata,netdata) %dir %{_localstatedir}/lib/%{name}
  185. %dir %{_datadir}/%{name}
  186. %dir %{_sysconfdir}/%{name}/health.d
  187. %dir %{_sysconfdir}/%{name}/python.d
  188. %dir %{_sysconfdir}/%{name}/charts.d
  189. %dir %{_sysconfdir}/%{name}/node.d
  190. %dir %{_sysconfdir}/%{name}/statsd.d
  191. %dir %{_libdir}/%{name}/conf.d/health.d
  192. %dir %{_libdir}/%{name}/conf.d/python.d
  193. %dir %{_libdir}/%{name}/conf.d/charts.d
  194. %dir %{_libdir}/%{name}/conf.d/node.d
  195. %dir %{_libdir}/%{name}/conf.d/statsd.d
  196. %if %{with systemd}
  197. %{_unitdir}/netdata.service
  198. %else
  199. %{_sysconfdir}/rc.d/init.d/netdata
  200. %endif
  201. # Enforce 0644 for files and 0755 for directories
  202. # for the netdata web directory
  203. %defattr(0644,root,netdata,0755)
  204. %{_datadir}/%{name}/web
  205. %changelog
  206. * Sun Nov 15 2015 Alon Bar-Lev <alonbl@redhat.com> - 0.0.0-1
  207. - Initial add.