nrpe.spec 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. %define isaix %(test "`uname -s`" = "AIX" && echo "1" || echo "0")
  2. %define islinux %(test "`uname -s`" = "Linux" && echo "1" || echo "0")
  3. %if %{isaix}
  4. %define _prefix /opt/nagios
  5. %define _docdir %{_prefix}/doc/nrpe-2.16RC2
  6. %define nshome /opt/nagios
  7. %define _make gmake
  8. %endif
  9. %if %{islinux}
  10. %define _init_dir /etc/init.d
  11. %define _exec_prefix %{_prefix}/sbin
  12. %define _bindir %{_prefix}/sbin
  13. %define _sbindir %{_prefix}/lib/nagios/cgi
  14. %define _libexecdir %{_prefix}/lib/nagios/plugins
  15. %define _datadir %{_prefix}/share/nagios
  16. %define _localstatedir /var/log/nagios
  17. %define nshome /var/log/nagios
  18. %define _make make
  19. %endif
  20. %define _sysconfdir /etc/nagios
  21. %define name nrpe
  22. %define version 2.16RC2
  23. %define release 1
  24. %define nsusr nagios
  25. %define nsgrp nagios
  26. %define nsport 5666
  27. # Reserve option to override port setting with:
  28. # rpm -ba|--rebuild --define 'nsport 5666'
  29. %{?port:%define nsport %{port}}
  30. # Macro that print mesages to syslog at package (un)install time
  31. %define nnmmsg logger -t %{name}/rpm
  32. Summary: Host/service/network monitoring agent for Nagios
  33. URL: http://www.nagios.org
  34. Name: %{name}
  35. Version: %{version}
  36. Release: %{release}
  37. License: GPL
  38. Group: Application/System
  39. Source0: %{name}-%{version}.tar.gz
  40. BuildRoot: %{_tmppath}/%{name}-buildroot
  41. Prefix: %{_prefix}
  42. Prefix: /etc/init.d
  43. Prefix: /etc/nagios
  44. %if %{isaix}
  45. Requires: nagios-plugins
  46. %endif
  47. %if %{islinux}
  48. Requires: bash, grep, nagios-plugins, util-linux, chkconfig, shadow-utils, sed, initscripts, mktemp
  49. %endif
  50. %description
  51. NPRE (Nagios Remote Plugin Executor) is a system daemon that
  52. will execute various Nagios plugins locally on behalf of a
  53. remote (monitoring) host that uses the check_nrpe plugin.
  54. Various plugins that can be executed by the daemon are available
  55. at: http://sourceforge.net/projects/nagiosplug
  56. This package provides the client-side NRPE agent (daemon).
  57. %package plugin
  58. Group: Application/System
  59. Summary: Provides nrpe plugin for Nagios.
  60. Requires: nagios-plugins
  61. %description plugin
  62. NPRE (Nagios Remote Plugin Executor) is a system daemon that
  63. will execute various Nagios plugins locally on behalf of a
  64. remote (monitoring) host that uses the check_nrpe plugin.
  65. Various plugins that can be executed by the daemon are available
  66. at: http://sourceforge.net/projects/nagiosplug
  67. This package provides the server-side NRPE plugin for
  68. Nagios-related applications.
  69. %prep
  70. %setup -q
  71. %pre
  72. # Create `nagios' group on the system if necessary
  73. %if %{isaix}
  74. lsgroup %{nsgrp} > /dev/null 2> /dev/null
  75. if [ $? -eq 2 ] ; then
  76. mkgroup %{nsgrp} || %nnmmsg Unexpected error adding group "%{nsgrp}". Aborting install process.
  77. fi
  78. %endif
  79. %if %{islinux}
  80. getent group %{nsgrp} > /dev/null 2> /dev/null
  81. if [ $? -ne 0 ] ; then
  82. groupadd %{nsgrp} || %nnmmsg Unexpected error adding group "%{nsgrp}". Aborting install process.
  83. fi
  84. %endif
  85. # Create `nagios' user on the system if necessary
  86. %if %{isaix}
  87. lsuser %{nsusr} > /dev/null 2> /dev/null
  88. if [ $? -eq 2 ] ; then
  89. useradd -d %{nshome} -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
  90. %nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
  91. fi
  92. %endif
  93. %if %{islinux}
  94. getent passwd %{nsusr} > /dev/null 2> /dev/null
  95. if [ $? -ne 0 ] ; then
  96. useradd -r -d %{nshome} -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
  97. %nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
  98. fi
  99. %endif
  100. %if %{isaix}
  101. # Check to see if the nrpe service is running and, if so, stop it.
  102. /usr/bin/lssrc -s nrpe > /dev/null 2> /dev/null
  103. if [ $? -eq 0 ] ; then
  104. status=`/usr/bin/lssrc -s nrpe | /usr/bin/gawk '$1=="nrpe" {print $NF}'`
  105. if [ "$status" = "active" ] ; then
  106. /usr/bin/stopsrc -s nrpe
  107. fi
  108. fi
  109. %endif
  110. %if %{islinux}
  111. # if LSB standard /etc/init.d does not exist,
  112. # create it as a symlink to the first match we find
  113. if [ -d /etc/init.d -o -L /etc/init.d ]; then
  114. : # we're done
  115. elif [ -d /etc/rc.d/init.d ]; then
  116. ln -s /etc/rc.d/init.d /etc/init.d
  117. elif [ -d /usr/local/etc/rc.d ]; then
  118. ln -s /usr/local/etc/rc.d /etc/init.d
  119. elif [ -d /sbin/init.d ]; then
  120. ln -s /sbin/init.d /etc/init.d
  121. fi
  122. %endif
  123. %if %{isaix}
  124. %post
  125. /usr/bin/lssrc -s nrpe > /dev/null 2> /dev/null
  126. if [ $? -eq 1 ] ; then
  127. /usr/bin/mkssys -p %{_bindir}/nrpe -s nrpe -u 0 -a "-c %{_sysconfdir}/nrpe.cfg -d -s" -Q -R -S -n 15 -f 9
  128. fi
  129. /usr/bin/startsrc -s nrpe
  130. %endif
  131. %preun
  132. %if %{isaix}
  133. status=`/usr/bin/lssrc -s nrpe | /usr/bin/gawk '$1=="nrpe" {print $NF}'`
  134. if [ "$status" = "active" ] ; then
  135. /usr/bin/stopsrc -s nrpe
  136. fi
  137. /usr/bin/rmssys -s nrpe
  138. %endif
  139. %if %{islinux}
  140. if [ "$1" = 0 ]; then
  141. /sbin/service nrpe stop > /dev/null 2>&1
  142. /sbin/chkconfig --del nrpe
  143. fi
  144. %endif
  145. %if %{islinux}
  146. %postun
  147. if [ "$1" -ge "1" ]; then
  148. /sbin/service nrpe condrestart >/dev/null 2>&1 || :
  149. fi
  150. %endif
  151. %build
  152. export PATH=$PATH:/usr/sbin
  153. CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
  154. MAKE=%{_make} ./configure \
  155. --with-init-dir=/etc/init.d \
  156. --with-nrpe-port=%{nsport} \
  157. --with-nrpe-user=%{nsusr} \
  158. --with-nrpe-group=%{nsgrp} \
  159. --prefix=%{_prefix} \
  160. --exec-prefix=%{_exec_prefix} \
  161. --bindir=%{_bindir} \
  162. --sbindir=%{_sbindir} \
  163. --libexecdir=%{_libexecdir} \
  164. --datadir=%{_datadir} \
  165. --sysconfdir=%{_sysconfdir} \
  166. --localstatedir=%{_localstatedir} \
  167. --enable-command-args
  168. %{_make} all
  169. %install
  170. [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
  171. %if %{islinux}
  172. install -d -m 0755 ${RPM_BUILD_ROOT}%{_init_dir}
  173. %endif
  174. DESTDIR=${RPM_BUILD_ROOT} %{_make} install install-daemon-config
  175. #install -d -m 0755 ${RPM_BUILD_ROOT}%{_sysconfdir}
  176. #install -d -m 0755 ${RPM_BUILD_ROOT}%{_bindir}
  177. #install -d -m 0755 ${RPM_BUILD_ROOT}%{_libexecdir}
  178. # install templated configuration files
  179. #cp sample-config/nrpe.cfg ${RPM_BUILD_ROOT}%{_sysconfdir}/nrpe.cfg
  180. #%if %{isaix}
  181. #cp init-script ${RPM_BUILD_ROOT}%{_init_dir}/nrpe
  182. #%endif
  183. #cp src/nrpe ${RPM_BUILD_ROOT}%{_bindir}
  184. #cp src/check_nrpe ${RPM_BUILD_ROOT}%{_libexecdir}
  185. %clean
  186. rm -rf $RPM_BUILD_ROOT
  187. %files
  188. %if %{islinux}
  189. %defattr(755,root,root)
  190. /etc/init.d/nrpe
  191. %endif
  192. %{_bindir}/nrpe
  193. %dir %{_sysconfdir}
  194. %defattr(600,%{nsusr},%{nsgrp})
  195. %config(noreplace) %{_sysconfdir}/*.cfg
  196. %defattr(755,%{nsusr},%{nsgrp})
  197. %doc Changelog LEGAL README
  198. %files plugin
  199. %defattr(755,%{nsusr},%{nsgrp})
  200. %{_libexecdir}
  201. %defattr(644,%{nsusr},%{nsgrp})
  202. %doc Changelog LEGAL README
  203. %changelog
  204. * Mon Mar 12 2012 Eric Stanley estanley<@>nagios.com
  205. - Created autoconf input file
  206. - Updated to support building on AIX
  207. - Updated install to use make install*
  208. * Mon Jan 23 2006 Andreas Kasenides ank<@>cs.ucy.ac.cy
  209. - fixed nrpe.cfg relocation to sample-config
  210. - replaced Copyright label with License
  211. - added --enable-command-args to enable remote arg passing (if desired can be disabled by commenting out)
  212. * Wed Nov 12 2003 Ingimar Robertsson <iar@skyrr.is>
  213. - Added adding of nagios group if it does not exist.
  214. * Tue Jan 07 2003 James 'Showkilr' Peterson <showkilr@showkilr.com>
  215. - Removed the lines which removed the nagios user and group from the system
  216. - changed the patch release version from 3 to 1
  217. * Mon Jan 06 2003 James 'Showkilr' Peterson <showkilr@showkilr.com>
  218. - Removed patch files required for nrpe 1.5
  219. - Update spec file for version 1.6 (1.6-1)
  220. * Sat Dec 28 2002 James 'Showkilr' Peterson <showkilr@showkilr.com>
  221. - First RPM build (1.5-1)