温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

rpmbuild使用---创建nrpe,nagios-plugins软件包

发布时间:2020-06-29 15:45:25 来源:网络 阅读:973 作者:vbbb625 栏目:移动开发

nagios客户端一般需要nagios-plugins,nrpe,为了方便与puppet结合,所以最好把源码打包成软件包

spec文件内容如下:
nrpe.spec:
 
  1. %define name nrpe 
  2. %define version 2.13 
  3. %define release 10 
  4. %define nsusr nagios 
  5. %define nsgrp nagios 
  6. %define nsport 5666 
  7.  
  8. # Reserve option to override port setting with: 
  9. # rpm -ba|--rebuild --define 'nsport 5666' 
  10. %{?port:%define nsport %{port}} 
  11.  
  12. # Macro that print mesages to syslog at package (un)install time 
  13. %define nnmmsg logger -t %{name}/rpm 
  14.  
  15. Summary: Host/service/network monitoring agent for Nagios 
  16. URL: http://www.nagios.org 
  17. Name: %{name} 
  18. Version: %{version} 
  19. Release: %{release} 
  20. License: GPL 
  21. Group: Application/System 
  22. Source0: %{name}-%{version}.tar.gz 
  23. BuildRoot: %{_tmppath}/%{name}-buildroot 
  24. Prefix: %{_prefix} 
  25. Prefix: /usr/local/nagios 
  26. Requires: bash, grep, nagios-plugins,xinetd 
  27. PreReq: /usr/bin/logger, chkconfig, sh-utils, shadow-utils, sed, initscripts, fileutils, mktemp 
  28.  
  29. %description 
  30. Nrpe is a system daemon that will execute various Nagios plugins 
  31. locally on behalf of a remote (monitoring) host that uses the 
  32. check_nrpe plugin.  Various plugins that can be executed by the  
  33. daemon are available at: 
  34.  
  35. %prep 
  36. %setup -q 
  37.  
  38. %pre 
  39. if [ $? -eq 2 ] ; then 
  40.     /usr/sbin/groupadd %{nsgrp} || %nnmmsg Unexpected error adding group "%{nyysgrp}". Aborting install process. 
  41. fi 
  42.  
  43. # Create `nagios' user on the system if necessary 
  44. if [ $? -eq 2 ] ; then 
  45.     /usr/sbin/useradd -d %{nsgrp} -s /bin/nologin -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \ 
  46.         %nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process. 
  47. fi 
  48.  
  49. %post 
  50. if [ "$1" = 1 ]; then 
  51.   chown -R "%{nsusr}":"%{nsgrp}" %{_prefix} 
  52.   chkconfig --add xinetd 
  53.   chkconfig xinetd on 
  54.   echo "nrpe         5666/tcp             #nrpe" >> /etc/services 
  55.   /sbin/service xinetd restart > /dev/null 2>&1 
  56. fi 
  57.  
  58. %preun 
  59. if [ "$1" = 0 ]; then 
  60.   /bin/rm /etc/xinetd.d/nrpe -f 
  61.   sed -i '/^nrpe.*/d' /etc/services 
  62. fi 
  63.  
  64. %postun 
  65. if [ "$1" = 0 ]; then 
  66.     /sbin/service xinetd restart >/dev/null 2>&1 || : 
  67. fi 
  68.  
  69. %build 
  70. export PATH=$PATH:/usr/sbin 
  71. CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \ 
  72. ./configure \ 
  73.     --with-init-dir=/etc/init.d \ 
  74.     --with-nrpe-port=%{nsport} \ 
  75.     --with-nrpe-user=%{nsusr} \ 
  76.     --with-nrpe-group=%{nsgrp} \ 
  77.     --prefix=%{_prefix} \ 
  78.     --exec-prefix=%{_prefix}/bin \ 
  79.     --bindir=%{_prefix}/bin \ 
  80.     --sbindir=%{_prefix}/lib/nagios/cgi \ 
  81.     --libexecdir=%{_prefix}/libexec \ 
  82.     --datadir=%{_prefix}/share \ 
  83.     --sysconfdir=/etc/nagios \ 
  84.     --localstatedir=/var/log/nagios \ 
  85.     --enable-command-args 
  86.  
  87. make all 
  88.  
  89. %install 
  90. [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT 
  91. install -d -m 0755 ${RPM_BUILD_ROOT}/etc/xinetd.d 
  92. install -c -m 0755 -d ${RPM_BUILD_ROOT}/usr/local/nagios/libexec 
  93. install -c -m 0755 src/check_nrpe ${RPM_BUILD_ROOT}/usr/local/nagios/libexec 
  94. install -c -m 0755 -d ${RPM_BUILD_ROOT}/usr/local/nagios/bin 
  95. install -c -m 0755 src/nrpe ${RPM_BUILD_ROOT}/usr/local/nagios/bin 
  96. install -c -m 0755 -d ${RPM_BUILD_ROOT}/usr/local/nagios/etc 
  97. install -c -m 0755 sample-config/nrpe.cfg ${RPM_BUILD_ROOT}/usr/local/nagios/etc/nrpe.cfg 
  98. install -c -m 0644 sample-config/nrpe.xinetd ${RPM_BUILD_ROOT}/etc/xinetd.d/nrpe 
  99. sed -i 's#server_args.*#server_args     = -c %{_prefix}/etc/nrpe.cfg --inetd#' ${RPM_BUILD_ROOT}/etc/xinetd.d/nrpe 
  100. %clean 
  101. rm -rf $RPM_BUILD_ROOT 
  102.  
  103. %files 
  104. %defattr(755,root,root) 
  105. %{_prefix}/bin/nrpe 
  106. %defattr(644,root,root) 
  107. %config(noreplace) /usr/local/nagios/etc/*.cfg 
  108. %config(noreplace) /etc/xinetd.d/nrpe 
  109. %defattr(755,%{nsusr},%{nsgrp}) 
  110. %doc Changelog LEGAL README  
  111. %doc %{_prefix}/libexec 
  112.  
  113. %changelog 
  114. * Wed Apr 3 2013 xxx build - 2.13-10 <xxx@xxx.com> 
  115. - fixed nrpe.cfg relocation to sample-config 
nagios-plugins.spec
 
  1. # Macros 
  2. %define isaix %(test "`uname -s`" = "AIX" && echo "1" || echo "0") 
  3. %define islinux %(test "`uname -s`" = "Linux" && echo "1" || echo "0") 
  4. %define isredhatfamily %(test -f /etc/redhat-release && echo "1" || echo "0") 
  5.  
  6. %if %{isaix} 
  7.     %define _prefix /usr/local/nagios 
  8. #   %define _defaultdocdir %{_datadir}/doc 
  9. %else 
  10.     %define _libexecdir %{_exec_prefix}/libexec 
  11. %endif 
  12. %define _sysconfdir /usr/local/nagios/etc 
  13.  
  14. %define npusr nagios 
  15. %define nphome /home/nagios 
  16. %define npgrp nagios 
  17.  
  18. Name: nagios-plugins 
  19. Version: 1.4.16 
  20. Release: 10 
  21. Summary: Host/service/network monitoring program plugins for Nagios 
  22.  
  23. Group: Applications/System 
  24. License: GPL 
  25. URL: http://nagiosplug.sourceforge.net/ 
  26. Source0: http://dl.sf.net/sourceforge/nagiosplug/%{name}-%{version}.tar.gz 
  27. BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 
  28.  
  29. %define npdir %{_builddir}/%{name}-%{version} 
  30.  
  31. %if %{isaix} 
  32. Prefix: %{_prefix} 
  33. %else 
  34. Prefix: %{_prefix}/lib/nagios/plugins 
  35. %endif 
  36. Packager: Karl DeBisschop <kdebisschop@users.sourceforge.net> 
  37. Vendor: Nagios Plugin Development Group 
  38. Provides: nagios-plugins 
  39.  
  40. %{!?custom:%global custom 0} 
  41. Obsoletes: nagios-plugins-custom nagios-plugins-extras 
  42.  
  43.  
  44. # Requires 
  45. %if %{isaix} 
  46. Requires:   fping  
  47. Requires:   gawk 
  48. Requires:   net-snmp  
  49. Requires:   net-snmp-perl  
  50. Requires:   net-snmp-utils 
  51. Requires:   openldap 
  52. Requires:   openssl 
  53. Requires:   perl 
  54. Requires:   python 
  55. Requires:   openssl 
  56. BuildRequires:  fping  
  57. BuildRequires:  gawk 
  58. BuildRequires:  net-snmp  
  59. BuildRequires:  net-snmp-perl  
  60. BuildRequires:  net-snmp-utils 
  61. BuildRequires:  openldap-devel 
  62. %endif 
  63. %if %{isredhatfamily} 
  64. Requires:   bind-utils 
  65. Requires:   coreutils 
  66. Requires:   fping  
  67. Requires:   gawk 
  68. Requires:   grep 
  69. Requires:   iputils 
  70. Requires:   mysql 
  71. Requires:   net-snmp-utils 
  72. Requires:   ntp 
  73. Requires:   openldap 
  74. Requires:   openssl 
  75. Requires:   openssh-clients 
  76. Requires:   perl 
  77. Requires:   postgresql-libs 
  78. Requires:   procps 
  79. Requires:   python 
  80. Requires:   samba-client 
  81. Requires:   shadow-utils 
  82. Requires:   traceroute 
  83. Requires:   /usr/bin/mailq 
  84. BuildRequires:  bind-utils 
  85. BuildRequires:  coreutils 
  86. BuildRequires:  iputils 
  87. BuildRequires:  mysql-devel 
  88. BuildRequires:  net-snmp-utils 
  89. BuildRequires:  net-tools 
  90. BuildRequires:  ntp 
  91. BuildRequires:  openldap-devel 
  92. BuildRequires:  openssh-clients 
  93. BuildRequires:  openssl-devel 
  94. BuildRequires:  postgresql-devel 
  95. BuildRequires:  procps 
  96. BuildRequires:  samba-client 
  97. BuildRequires:  /usr/bin/mailq 
  98. %endif 
  99.  
  100.  
  101. %description 
  102.  
  103. Nagios is a program that will monitor hosts and services on your 
  104. network, and to email or page you when a problem arises or is 
  105. resolved. Nagios runs on a unix server as a background or daemon 
  106. process, intermittently running checks on various services that you 
  107. specify. The actual service checks are performed by separate "plugin" 
  108. programs which return the status of the checks to Nagios. This package 
  109. contains those plugins. 
  110.  
  111.  
  112. %prep 
  113. %setup -q 
  114.  
  115.  
  116. %build 
  117. %{?isaix: MAKE=gmake} ./configure \ 
  118. --prefix=%{_prefix} \ 
  119. --exec-prefix=%{_exec_prefix} \ 
  120. --libexecdir=%{_libexecdir} \ 
  121. --sysconfdir=%{_sysconfdir} \ 
  122. --datadir=%{_datadir} \ 
  123. #--with-cgiurl=/nagios/cgi-bin 
  124. ls -1 %{npdir}/plugins > %{npdir}/ls-plugins-before 
  125. ls -1 %{npdir}/plugins-root > %{npdir}/ls-plugins-root-before 
  126. ls -1 %{npdir}/plugins-scripts > %{npdir}/ls-plugins-scripts-before 
  127. make %{?_smp_mflags} 
  128. ls -1 %{npdir}/plugins > %{npdir}/ls-plugins-after 
  129. ls -1 %{npdir}/plugins-root > %{npdir}/ls-plugins-root-after 
  130. ls -1 %{npdir}/plugins-scripts > %{npdir}/ls-plugins-scripts-after 
  131. %pre 
  132. # Create `nagios' group on the system if necessary 
  133. %if %{isaix} 
  134. lsgroup %{npgrp} > /dev/null 2> /dev/null 
  135. if [ $? -eq 2 ] ; then 
  136.     mkgroup %{npgrp} || %nnmmsg Unexpected error adding group "%{npgrp}". Aborting install process. 
  137. fi 
  138. %endif 
  139. %if %{islinux} 
  140. getent group %{npgrp} > /dev/null 2> /dev/null 
  141. if [ $? -ne 0 ] ; then 
  142.     groupadd %{npgrp} || %nnmmsg Unexpected error adding group "%{npgrp}". Aborting install process. 
  143. fi 
  144. %endif 
  145.  
  146. # Create `nagios' user on the system if necessary 
  147. %if %{isaix} 
  148. lsuser %{npusr} > /dev/null 2> /dev/null 
  149. if [ $? -eq 2 ] ; then 
  150.     useradd -d %{nphome} -s /bin/nologin -c "%{npusr}" -g %{npgrp} %{npusr} || \ 
  151.         %nnmmsg Unexpected error adding user "%{npusr}". Aborting install process. 
  152. fi 
  153. %endif 
  154. %if %{islinux} 
  155. getent passwd %{npusr} > /dev/null 2> /dev/null 
  156. if [ $? -ne 0 ] ; then 
  157.     useradd -r -d %{nphome} -s /bin/nologin -c "%{npusr}" -g %{npgrp} %{npusr} || \ 
  158.         %nnmmsg Unexpected error adding user "%{npusr}". Aborting install process. 
  159. fi 
  160. %endif 
  161.  
  162. %post 
  163.  chown -R "%{npusr}":"%{npgrp}" %{_prefix} 
  164.  
  165. %install 
  166. rm -rf $RPM_BUILD_ROOT 
  167. make AM_INSTALL_PROGRAM_FLAGS="" DESTDIR=${RPM_BUILD_ROOT} install 
  168. build-aux/install-sh -c  -d ${RPM_BUILD_ROOT}%{_sysconfdir} 
  169. build-aux/install-sh -c  -m 664 command.cfg ${RPM_BUILD_ROOT}%{_sysconfdir} 
  170. %find_lang %{name} 
  171. echo "%defattr(755,%{npusr},%{npgrp})" >> %{name}.lang 
  172. comm -13 %{npdir}/ls-plugins-before %{npdir}/ls-plugins-after | egrep -v "\.o$|^\." | gawk -v libexecdir=%{_libexecdir} '{printf( "%s/%s\n", libexecdir, $0);}' >> %{name}.lang 
  173. echo "%defattr(755,root,root)" >> %{name}.lang 
  174. comm -13 %{npdir}/ls-plugins-root-before %{npdir}/ls-plugins-root-after | egrep -v "\.o$|^\." | gawk -v libexecdir=%{_libexecdir} '{printf( "%s/%s\n", libexecdir, $0);}' >> %{name}.lang 
  175. echo "%defattr(755,%{npusr},%{npgrp})" >> %{name}.lang 
  176. comm -13 %{npdir}/ls-plugins-scripts-before %{npdir}/ls-plugins-scripts-after | egrep -v "\.o$|^\." | gawk -v libexecdir=%{_libexecdir} '{printf( "%s/%s\n", libexecdir, $0);}' >> %{name}.lang 
  177. echo "%{_libexecdir}/utils.pm" >> %{name}.lang 
  178. echo "%{_libexecdir}/utils.sh" >> %{name}.lang 
  179.  
  180. %clean 
  181. rm -rf $RPM_BUILD_ROOT 
  182.  
  183.  
  184. %files -f %{name}.lang 
  185. %doc CODING COPYING FAQ INSTALL LEGAL README REQUIREMENTS SUPPORT THANKS 
  186. %doc ChangeLog  
  187. %if ! %{isaix} 
  188. %{_datadir}/locale/de/LC_MESSAGES/nagios-plugins.mo 
  189. %{_datadir}/locale/fr/LC_MESSAGES/nagios-plugins.mo 
  190. /usr/local/nagios/libexec/check_ldaps 
  191. /usr/local/nagios/etc/command.cfg 
  192. %endif 
  193.  
  194. %changelog 
  195. * Wed Apr 3 2013 xxx build   - 1.4.16-10 <xxx@xxx.com>  
  196. - Initial Package 
 
 
 
 
 
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI