netdata.spec.in 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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: netdata
  78. Version: @PACKAGE_VERSION@
  79. Release: 1%{?dist}
  80. License: GPLv3+
  81. Group: Applications/System
  82. Source0: https://github.com/netdata/%{name}/releases/download/%{version}/%{name}-%{version}.tar.gz
  83. URL: http://my-netdata.io
  84. BuildRequires: pkgconfig
  85. BuildRequires: xz
  86. BuildRequires: zlib-devel
  87. BuildRequires: libuuid-devel
  88. BuildRequires: autoconf
  89. BuildRequires: automake
  90. Requires: zlib
  91. Requires: libuuid
  92. # Packages can be found in the EPEL repo
  93. %if %{with nfacct}
  94. BuildRequires: libmnl-devel
  95. BuildRequires: libnetfilter_acct-devel
  96. Requires: libmnl
  97. Requires: libnetfilter_acct
  98. %endif
  99. %if %{with freeipmi}
  100. BuildRequires: freeipmi-devel
  101. Requires: freeipmi
  102. %endif
  103. Requires(pre): /usr/sbin/groupadd
  104. Requires(pre): /usr/sbin/useradd
  105. Requires(post): libcap
  106. %{netdata_initd_buildrequires}
  107. %{netdata_recommends}
  108. %{netdata_initd_requires}
  109. %description
  110. netdata is the fastest way to visualize metrics. It is a resource
  111. efficient, highly optimized system for collecting and visualizing any
  112. type of realtime timeseries data, from CPU usage, disk activity, SQL
  113. queries, API calls, web site visitors, etc.
  114. netdata tries to visualize the truth of now, in its greatest detail,
  115. so that you can get insights of what is happening now and what just
  116. happened, on your systems and applications.
  117. %prep
  118. %setup -q -n %{name}-%{version}
  119. %build
  120. autoreconf -i
  121. %configure \
  122. --with-zlib \
  123. --with-math \
  124. %{?with_nfacct:--enable-plugin-nfacct} \
  125. %{?with_freeipmi:--enable-plugin-freeipmi} \
  126. --with-user=netdata
  127. %{__make} %{?_smp_mflags}
  128. %install
  129. rm -rf "${RPM_BUILD_ROOT}"
  130. %{__make} %{?_smp_mflags} DESTDIR="${RPM_BUILD_ROOT}" install
  131. find "${RPM_BUILD_ROOT}" -name .keep -delete
  132. install -m 644 -p system/netdata.conf "${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}"
  133. install -m 755 -d "${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d"
  134. install -m 644 -p system/netdata.logrotate "${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name}"
  135. %if %{with systemd}
  136. install -m 755 -d "${RPM_BUILD_ROOT}%{_unitdir}"
  137. install -m 644 -p system/netdata.service "${RPM_BUILD_ROOT}%{_unitdir}/netdata.service"
  138. %else
  139. # install SYSV init stuff
  140. install -d "${RPM_BUILD_ROOT}/etc/rc.d/init.d"
  141. install -m 755 system/netdata-init-d \
  142. "${RPM_BUILD_ROOT}/etc/rc.d/init.d/netdata"
  143. %endif
  144. %pre
  145. getent group netdata >/dev/null || groupadd -r netdata
  146. getent group docker >/dev/null || groupadd -r docker
  147. getent passwd netdata >/dev/null || \
  148. useradd -r -g netdata -G docker -s /sbin/nologin \
  149. -d %{contentdir} -c "netdata" netdata
  150. %post
  151. %{netdata_init_post}
  152. %preun
  153. %{netdata_init_preun}
  154. %postun
  155. %{netdata_init_postun}
  156. %clean
  157. rm -rf "${RPM_BUILD_ROOT}"
  158. %files
  159. %doc README.md
  160. %defattr(-,root,root)
  161. %dir %{_sysconfdir}/%{name}
  162. %dir %{_libdir}/%{name}
  163. %config %{_sysconfdir}/%{name}/*.conf
  164. #%config %{_sysconfdir}/%{name}/charts.d/*.conf
  165. #%config %{_sysconfdir}/%{name}/health.d/*.conf
  166. #%config %{_sysconfdir}/%{name}/node.d/*.conf
  167. #%config %{_sysconfdir}/%{name}/python.d/*.conf
  168. #%config %{_sysconfdir}/%{name}/statsd.d/*.conf
  169. %config %{_sysconfdir}/logrotate.d/%{name}
  170. %{_libdir}/%{name}
  171. %{_libexecdir}/%{name}
  172. %{_sbindir}/%{name}
  173. %{_sysconfdir}/%{name}/edit-config
  174. %caps(cap_dac_read_search,cap_sys_ptrace=ep) %attr(0550,root,netdata) %{_libexecdir}/%{name}/plugins.d/apps.plugin
  175. %if %{with netns}
  176. # cgroup-network detects the network interfaces of CGROUPs
  177. # it must be able to use setns() and run cgroup-network-helper.sh as root
  178. # the helper script reads /proc/PID/fdinfo/* files, runs virsh, etc.
  179. %caps(cap_setuid=ep) %attr(4550,root,netdata) %{_libexecdir}/%{name}/plugins.d/cgroup-network
  180. %attr(0550,root,root) %{_libexecdir}/%{name}/plugins.d/cgroup-network-helper.sh
  181. %endif
  182. %if %{with freeipmi}
  183. %caps(cap_setuid=ep) %attr(4550,root,netdata) %{_libexecdir}/%{name}/plugins.d/freeipmi.plugin
  184. %endif
  185. %attr(0770,netdata,netdata) %dir %{_localstatedir}/cache/%{name}
  186. %attr(0755,netdata,root) %dir %{_localstatedir}/log/%{name}
  187. %attr(0770,netdata,netdata) %dir %{_localstatedir}/lib/%{name}
  188. %dir %{_datadir}/%{name}
  189. %dir %{_sysconfdir}/%{name}/health.d
  190. %dir %{_sysconfdir}/%{name}/python.d
  191. %dir %{_sysconfdir}/%{name}/charts.d
  192. %dir %{_sysconfdir}/%{name}/node.d
  193. %dir %{_sysconfdir}/%{name}/statsd.d
  194. %dir %{_libdir}/%{name}/conf.d/health.d
  195. %dir %{_libdir}/%{name}/conf.d/python.d
  196. %dir %{_libdir}/%{name}/conf.d/charts.d
  197. #%dir %{_libdir}/%{name}/conf.d/node.d
  198. %dir %{_libdir}/%{name}/conf.d/statsd.d
  199. %if %{with systemd}
  200. %{_unitdir}/netdata.service
  201. %else
  202. %{_sysconfdir}/rc.d/init.d/netdata
  203. %endif
  204. # Enforce 0644 for files and 0755 for directories
  205. # for the netdata web directory
  206. %defattr(0644,root,netdata,0755)
  207. %{_datadir}/%{name}/web
  208. %changelog
  209. * Wed Jan 02 2019 Pawel Krupa <pkrupa@redhat.com> - 0.0.0-3
  210. - Temporary set version statically
  211. - Fix changelog ordering
  212. - Comment-out node.d configuration directory
  213. * Wed Jan 02 2019 Pawel Krupa <pkrupa@redhat.com> - 0.0.0-2
  214. - Fix permissions for log files
  215. * Sun Nov 15 2015 Alon Bar-Lev <alonbl@redhat.com> - 0.0.0-1
  216. - Initial add.