/rpm/SPECS/jmxtrans.spec

http://jmxtrans.googlecode.com/ · Unknown · 112 lines · 88 code · 24 blank · 0 comment · 0 complexity · 0d8f27336980f9ecf07a126e9b8b9dc7 MD5 · raw file

  1. Name: jmxtrans
  2. Version: %{VERSION}
  3. Release: %{RELEASE}
  4. Summary: JMX Transformer - more than meets the eye
  5. Group: Applications/Communications
  6. URL: http://http://code.google.com/p/jmxtrans//
  7. Vendor: Jon Stevens
  8. Packager: Henri Gomez <henri.gomez@gmail.com>
  9. License: OpenSource Software by Jon Stevens
  10. BuildArch: noarch
  11. Source0: %{JMXTRANS_SOURCE}
  12. Source1: jmxtrans.init
  13. BuildRoot: %{_tmppath}/build-%{name}-%{version}-%{release}
  14. Requires(pre): /usr/sbin/groupadd
  15. Requires(pre): /usr/sbin/useradd
  16. %define xuser jmxtrans
  17. %define xapp jmxtrans
  18. %define xappdir %{_usr}/share/%{xapp}
  19. %define xlibdir %{_var}/lib/%{xapp}
  20. %define xlogdir %{_var}/log/%{xapp}
  21. %define xconf %{_sysconfdir}/sysconfig/%{xapp}
  22. %description
  23. jmxtrans is very powerful tool which reads json configuration files of servers/ports and jmx domains - attributes - types.
  24. Then outputs the data in whatever format you want via special 'Writer' objects which you can code up yourself.
  25. It does this with a very efficient engine design that will scale to querying thousands of machines.
  26. %prep
  27. %setup -q -n %{xapp}-%{version}
  28. %build
  29. %install
  30. # Prep the install location.
  31. rm -rf $RPM_BUILD_ROOT
  32. mkdir -p $RPM_BUILD_ROOT%{xappdir}
  33. mkdir -p $RPM_BUILD_ROOT%{xlibdir}
  34. mkdir -p $RPM_BUILD_ROOT%{xlogdir}
  35. mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/init.d
  36. mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
  37. # remove source (unneeded here)
  38. rm -rf src/com
  39. cp -rf * $RPM_BUILD_ROOT%{xappdir}
  40. cp %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/init.d/%{xapp}
  41. # ensure shell scripts are executable
  42. chmod 755 $RPM_BUILD_ROOT%{xappdir}/*.sh
  43. %clean
  44. rm -rf $RPM_BUILD_ROOT
  45. %pre
  46. /usr/sbin/useradd -c "JMXTrans" \
  47. -s /sbin/nologin -r -d %{xappdir} %{xuser} 2> /dev/null || :
  48. %post
  49. if [ $1 = 1 ]; then
  50. /sbin/chkconfig --add %{xapp}
  51. # get number of cores so we can set number of GC threads
  52. CPU_CORES=$(cat /proc/cpuinfo | grep processor | wc -l)
  53. NEW_RATIO=8
  54. # defaults for JVM
  55. HEAP_SIZE="512"
  56. HEAP_NUMBER=$(echo $HEAP_SIZE|sed 's/[a-zA-Z]//g')
  57. NEW_SIZE=$(expr $HEAP_SIZE / $NEW_RATIO)
  58. # populate sysconf file
  59. echo "# configuration file for package %{xapp}" > %{xconf}
  60. echo "export JAR_FILE=\"/usr/share/jmxtrans/jmxtrans-all.jar\"" >> %{xconf}
  61. echo "export LOG_DIR=\"/var/log/%{xapp}\"" >> %{xconf}
  62. echo "export SECONDS_BETWEEN_RUNS=60" >> %{xconf}
  63. echo "export JSON_DIR=\"%{xlibdir}\"" >> %{xconf}
  64. echo "export HEAP_SIZE=${HEAP_SIZE}" >> %{xconf}
  65. echo "export NEW_SIZE=${NEW_SIZE}" >> %{xconf}
  66. echo "export CPU_CORES=${CPU_CORES}" >> %{xconf}
  67. echo "export NEW_RATIO=${NEW_RATIO}" >> %{xconf}
  68. echo "export LOG_LEVEL=debug" >> %{xconf}
  69. fi
  70. %preun
  71. if [ $1 = 0 ]; then
  72. /sbin/service %{xapp} stop > /dev/null 2>&1
  73. /sbin/chkconfig --del %{xapp}
  74. rm -f %{xconf}
  75. fi
  76. %posttrans
  77. /sbin/service %{xapp} condrestart >/dev/null 2>&1 || :
  78. %files
  79. %defattr(-,root,root)
  80. %attr(0755, root, root) %{_sysconfdir}/init.d/%{xapp}
  81. #%config(noreplace) %{_sysconfdir}/sysconfig/%{xapp}
  82. %config(noreplace) %{xlibdir}
  83. %attr(0755,%{xuser}, %{xuser}) %{xlogdir}
  84. %{xappdir}/*
  85. %doc %{xappdir}/README.html
  86. %changelog
  87. * Wed Jul 19 2011 Henri Gomez <henri.gomez@gmail.com> - 223-1
  88. - Initial RPM package to be used and build with ci systems.