nrpe.spec 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. %define name nrpe
  2. %define version 1.5
  3. %define release 3
  4. %define nsusr nagios
  5. %define nsgrp nagios
  6. %define nsport 5666
  7. # Reserve option to override port setting with:
  8. # rpm -ba|--rebuild --define 'nsport 5666'
  9. %{?port:%define nsport %{port}}
  10. # Macro that print mesages to syslog at package (un)install time
  11. %define nnmmsg logger -t %{name}/rpm
  12. Summary: Host/service/network monitoring agent for nagios
  13. URL: http://www.nagios.org
  14. Name: %{name}
  15. Version: %{version}
  16. Release: %{release}
  17. Copyright: GPL
  18. Group: Application/System
  19. Source0: %{name}-%{version}.tar.gz
  20. Patch0: %{name}.patch
  21. BuildRoot: %{_tmppath}/%{name}-buildroot
  22. Prefix: %{_prefix}
  23. Prefix: /etc/init.d
  24. Prefix: /etc/nagios
  25. Requires: bash, grep, nagios-plugins
  26. PreReq: /usr/bin/logger, chkconfig, sh-utils, shadow-utils, sed, initscripts, fileutils, mktemp
  27. %description
  28. Nrpe is a agent application that will monitor services on your
  29. system. Nrpe is written in C and is designed to run under Linux
  30. (and some other *NIX variants) as a background process,
  31. intermittently running checks on various services that you specify.
  32. The actual service checks are performed by separate "plugin" programs
  33. which return the status of the checks to Nagios. The plugins are
  34. available at http://sourceforge.net/projects/nagiosplug
  35. This package provide core agent.
  36. %package plugin
  37. Group: Application/System
  38. Summary: Provides nrpe plugin for Nagios.
  39. Requires: nagios-plugins
  40. %description plugin
  41. Nagios is a program that will monitor hosts and services on your
  42. network. It has the ability to email or page you when a problem arises
  43. and when a problem is resolved. Nagios is written in C and is
  44. designed to run under Linux (and some other *NIX variants) as a
  45. background process, intermittently running checks on various services
  46. that you specify.
  47. This package provides the nrpe plugin for Nagios-related applications.
  48. %prep
  49. %setup -q
  50. %patch0 -p1
  51. %pre
  52. # Create `nagios' user on the system if necessary
  53. if id %{nsusr} ; then
  54. : # user already exists
  55. else
  56. /usr/sbin/useradd -r -d /var/log/nagios -s /bin/sh -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
  57. %nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
  58. fi
  59. # if LSB standard /etc/init.d does not exist,
  60. # create it as a symlink to the first match we find
  61. if [ -d /etc/init.d -o -L /etc/init.d ]; then
  62. : # we're done
  63. elif [ -d /etc/rc.d/init.d ]; then
  64. ln -s /etc/rc.d/init.d /etc/init.d
  65. elif [ -d /usr/local/etc/rc.d ]; then
  66. ln -s /usr/local/etc/rc.d /etc/init.d
  67. elif [ -d /sbin/init.d ]; then
  68. ln -s /sbin/init.d /etc/init.d
  69. fi
  70. %preun
  71. if [ "$1" = 0 ]; then
  72. /sbin/service nrpe stop > /dev/null 2>&1
  73. /sbin/chkconfig --del nrpe
  74. fi
  75. %postun
  76. if [ "$1" -ge "1" ]; then
  77. /sbin/service nrpe condrestart >/dev/null 2>&1 || :
  78. fi
  79. # Delete nagios user and group
  80. if [ $1 = 0 ]; then
  81. /usr/sbin/userdel %{nsusr} || %nnmmsg "User %{nsusr} could not be deleted."
  82. /usr/sbin/groupdel %{nsgrp} || %nnmmsg "Group %{nsgrp} could not be deleted."
  83. fi
  84. %build
  85. export PATH=$PATH:/usr/sbin
  86. CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
  87. ./configure \
  88. --with-init-dir=/etc/init.d \
  89. --with-nrpe-port=%{nsport} \
  90. --with-nrpe-user=%{nsusr} \
  91. --with-nrpe-grp=%{nsgrp} \
  92. --prefix=%{_prefix} \
  93. --exec-prefix=%{_prefix}/sbin \
  94. --bindir=%{_prefix}/sbin \
  95. --sbindir=%{_prefix}/lib/nagios/cgi \
  96. --libexecdir=%{_prefix}/lib/nagios/plugins \
  97. --datadir=%{_prefix}/share/nagios \
  98. --sysconfdir=/etc/nagios \
  99. --localstatedir=/var/log/nagios
  100. make all
  101. %install
  102. [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
  103. install -d -m 0755 ${RPM_BUILD_ROOT}/etc/init.d
  104. install -d -m 0755 ${RPM_BUILD_ROOT}/etc/nagios
  105. install -d -m 0755 ${RPM_BUILD_ROOT}/usr/sbin
  106. install -d -m 0755 ${RPM_BUILD_ROOT}/usr/lib/nagios/plugins
  107. # install templated configuration files
  108. cp nrpe.cfg ${RPM_BUILD_ROOT}/etc/nagios/nrpe.cfg
  109. cp init-script ${RPM_BUILD_ROOT}/etc/init.d/nrpe
  110. cp src/nrpe ${RPM_BUILD_ROOT}/usr/sbin
  111. cp src/check_nrpe ${RPM_BUILD_ROOT}/usr/lib/nagios/plugins
  112. %clean
  113. rm -rf $RPM_BUILD_ROOT
  114. %files
  115. %defattr(755,root,root)
  116. /etc/init.d/nrpe
  117. %{_prefix}/sbin/nrpe
  118. %dir /etc/nagios
  119. %defattr(644,root,root)
  120. %config(noreplace) /etc/nagios/*.cfg
  121. %defattr(755,%{nsusr},%{nsgrp})
  122. %doc Changelog LEGAL README
  123. %files plugin
  124. %defattr(755,root,root)
  125. %{_prefix}/lib/nagios/plugins
  126. %defattr(755,%{nsusr},%{nsgrp})
  127. %doc Changelog LEGAL README
  128. %changelog
  129. * Sat Dec 28 2002 James 'Showkilr' Peterson <showkilr@showkilr.com>
  130. - First RPM build (1.5-1)