Gentoo Archives: gentoo-commits

From: Patrick Lauer <patrick@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-analyzer/zabbix/, net-analyzer/zabbix/files/3.0/init.d/, ...
Date: Fri, 28 Oct 2016 12:43:54
Message-Id: 1477658627.bd58a7f4f0adb2758e755c4eb35c9b32c6dfd01f.patrick@gentoo
1 commit: bd58a7f4f0adb2758e755c4eb35c9b32c6dfd01f
2 Author: Patrick Lauer <patrick <AT> gentoo <DOT> org>
3 AuthorDate: Fri Oct 28 10:17:20 2016 +0000
4 Commit: Patrick Lauer <patrick <AT> gentoo <DOT> org>
5 CommitDate: Fri Oct 28 12:43:47 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bd58a7f4
7
8 net-analyzer/zabbix: Add init script for JMX proxy
9
10 Package-Manager: portage-2.3.2
11
12 .../zabbix/files/3.0/conf.d/zabbix-jmx-proxy | 12 +
13 .../zabbix/files/3.0/init.d/zabbix-jmx-proxy | 33 +++
14 net-analyzer/zabbix/zabbix-3.2.1-r1.ebuild | 329 +++++++++++++++++++++
15 3 files changed, 374 insertions(+)
16
17 diff --git a/net-analyzer/zabbix/files/3.0/conf.d/zabbix-jmx-proxy b/net-analyzer/zabbix/files/3.0/conf.d/zabbix-jmx-proxy
18 new file mode 100644
19 index 00000000..6aa3cf9
20 --- /dev/null
21 +++ b/net-analyzer/zabbix/files/3.0/conf.d/zabbix-jmx-proxy
22 @@ -0,0 +1,12 @@
23 +# Configuration variables for the zabbix jmx proxy
24 +
25 +
26 +# LISTEN_IP="0.0.0.0"
27 +# LISTEN_PORT=10052
28 +# START_POLLERS=5
29 +# TIMEOUT=3
30 +
31 +# uncomment to enable remote monitoring of the standard JMX objects on the Zabbix Java Gateway itself
32 +# JAVA_OPTIONS="$JAVA_OPTIONS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345
33 +# -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
34 +
35
36 diff --git a/net-analyzer/zabbix/files/3.0/init.d/zabbix-jmx-proxy b/net-analyzer/zabbix/files/3.0/init.d/zabbix-jmx-proxy
37 new file mode 100755
38 index 00000000..5722814
39 --- /dev/null
40 +++ b/net-analyzer/zabbix/files/3.0/init.d/zabbix-jmx-proxy
41 @@ -0,0 +1,33 @@
42 +#!/sbin/openrc-run
43 +
44 +LISTEN_IP=${LISTEN_IP:-127.0.0.1}
45 +LISTEN_PORT=${LISTEN_PORT:-10052}
46 +START_POLLERS=${START_POLLERS:-5}
47 +TIMEOUT=${TIMEOUT:-3}
48 +
49 +PID_FILE="/run/zabbix-jmx-proxy"
50 +
51 +
52 +start() {
53 + ZABBIX_OPTIONS="-Dzabbix.pidFile=$PID_FILE \
54 + -Dzabbix.listenIP=$LISTEN_IP \
55 + -Dzabbix.listenPort=$LISTEN_PORT \
56 + -Dzabbix.startPollers=$START_POLLERS \
57 + -Dzabbix.timeout=$TIMEOUT \
58 + -Dsun.rmi.transport.tcp.responseTimeout=${TIMEOUT}000"
59 +
60 + JAVA_OPTIONS="-server $JAVA_OPTIONS -Dlogback.configurationFile=logback-console.xml"
61 +
62 + cd /opt/zabbix_java
63 +
64 + CLASSPATH="lib"
65 + for jar in lib/*.jar bin/*.jar; do
66 + CLASSPATH="$CLASSPATH:$jar"
67 + done
68 +
69 + start-stop-daemon -m --background --pidfile $PID_FILE -- java $JAVA_OPTIONS -classpath $CLASSPATH $ZABBIX_OPTIONS com.zabbix.gateway.JavaGateway
70 +}
71 +
72 +stop() {
73 + start-stop-daemon --stop --pidfile $PID_FILE
74 +}
75
76 diff --git a/net-analyzer/zabbix/zabbix-3.2.1-r1.ebuild b/net-analyzer/zabbix/zabbix-3.2.1-r1.ebuild
77 new file mode 100644
78 index 00000000..cc5db77
79 --- /dev/null
80 +++ b/net-analyzer/zabbix/zabbix-3.2.1-r1.ebuild
81 @@ -0,0 +1,329 @@
82 +# Copyright 1999-2016 Gentoo Foundation
83 +# Distributed under the terms of the GNU General Public License v2
84 +# $Id$
85 +
86 +EAPI="6"
87 +
88 +# needed to make webapp-config dep optional
89 +WEBAPP_OPTIONAL="yes"
90 +inherit flag-o-matic webapp java-pkg-opt-2 user systemd toolchain-funcs
91 +
92 +DESCRIPTION="ZABBIX is software for monitoring of your applications, network and servers"
93 +HOMEPAGE="http://www.zabbix.com/"
94 +MY_P=${P/_/}
95 +MY_PV=${PV/_/}
96 +SRC_URI="http://prdownloads.sourceforge.net/zabbix/${MY_P}.tar.gz"
97 +LICENSE="GPL-2"
98 +SLOT="0"
99 +WEBAPP_MANUAL_SLOT="yes"
100 +KEYWORDS="~amd64 ~x86"
101 +IUSE="+agent java curl frontend ipv6 xmpp ldap libxml2 mysql openipmi oracle postgres proxy server ssh ssl snmp sqlite odbc static"
102 +REQUIRED_USE="|| ( agent frontend proxy server )
103 + proxy? ( ^^ ( mysql oracle postgres sqlite odbc ) )
104 + server? ( ^^ ( mysql oracle postgres sqlite odbc ) )
105 + static? ( !oracle !snmp )"
106 +
107 +COMMON_DEPEND="snmp? ( net-analyzer/net-snmp )
108 + ldap? (
109 + net-nds/openldap
110 + =dev-libs/cyrus-sasl-2*
111 + net-libs/gnutls
112 + )
113 + mysql? ( >=virtual/mysql-5.0.3 )
114 + sqlite? ( >=dev-db/sqlite-3.3.5 )
115 + postgres? ( dev-db/postgresql:* )
116 + oracle? ( >=dev-db/oracle-instantclient-basic-10.0.0.0 )
117 + xmpp? ( dev-libs/iksemel )
118 + libxml2? ( dev-libs/libxml2 )
119 + curl? ( net-misc/curl )
120 + openipmi? ( sys-libs/openipmi )
121 + ssh? ( net-libs/libssh2 )
122 + java? ( virtual/jdk:* )
123 + odbc? ( dev-db/unixODBC )
124 + ssl? ( dev-libs/openssl:=[-bindist] )"
125 +
126 +RDEPEND="${COMMON_DEPEND}
127 + proxy? ( net-analyzer/fping )
128 + server? ( net-analyzer/fping
129 + app-admin/webapp-config )
130 + java? (
131 + >=virtual/jre-1.4
132 + dev-java/slf4j-api
133 + )
134 + frontend? (
135 + >=dev-lang/php-5.3.0[bcmath,ctype,sockets,gd,truetype,xml,session,xmlreader,xmlwriter,nls,sysvipc,unicode]
136 + || ( dev-lang/php[apache2] dev-lang/php[cgi] dev-lang/php[fpm] )
137 + mysql? ( dev-lang/php[mysqli] )
138 + odbc? ( dev-lang/php[odbc] )
139 + oracle? ( dev-lang/php[oci8-instant-client] )
140 + postgres? ( dev-lang/php[postgres] )
141 + sqlite? ( dev-lang/php[sqlite] )
142 + media-libs/gd[png]
143 + app-admin/webapp-config )"
144 +DEPEND="${COMMON_DEPEND}
145 + static? (
146 + ldap? (
147 + net-nds/openldap[static-libs]
148 + =dev-libs/cyrus-sasl-2*[static-libs]
149 + net-libs/gnutls[static-libs]
150 + )
151 + mysql? ( >=virtual/mysql-5.0.3[static-libs] )
152 + sqlite? ( >=dev-db/sqlite-3.3.5[static-libs] )
153 + postgres? ( dev-db/postgresql:*[static-libs] )
154 + libxml2? ( dev-libs/libxml2[static-libs] )
155 + curl? ( net-misc/curl[static-libs] )
156 + ssh? ( net-libs/libssh2[static-libs] )
157 + odbc? ( dev-db/unixODBC[static-libs] )
158 + )
159 + virtual/pkgconfig"
160 +
161 +S=${WORKDIR}/${MY_P}
162 +
163 +ZABBIXJAVA_BASE="opt/zabbix_java"
164 +
165 +pkg_setup() {
166 + if use oracle; then
167 + if [ -z "${ORACLE_HOME}" ]; then
168 + eerror
169 + eerror "The environment variable ORACLE_HOME must be set"
170 + eerror "and point to the correct location."
171 + eerror "It looks like you don't have Oracle installed."
172 + eerror
173 + die "Environment variable ORACLE_HOME is not set"
174 + fi
175 + if has_version 'dev-db/oracle-instantclient-basic'; then
176 + ewarn
177 + ewarn "Please ensure you have a full install of the Oracle client."
178 + ewarn "dev-db/oracle-instantclient* is NOT sufficient."
179 + ewarn
180 + fi
181 + fi
182 +
183 + if use frontend; then
184 + webapp_pkg_setup
185 + fi
186 +
187 + enewgroup zabbix
188 + enewuser zabbix -1 -1 /var/lib/zabbix/home zabbix
189 +}
190 +
191 +java_prepare() {
192 + cd "${S}/src/zabbix_java/lib"
193 + rm -v *.jar || die
194 +
195 + java-pkg_jar-from slf4j-api
196 +}
197 +
198 +src_prepare() {
199 + default
200 +}
201 +
202 +src_configure() {
203 + econf \
204 + $(use_enable server) \
205 + $(use_enable proxy) \
206 + $(use_enable agent) \
207 + $(use_enable ipv6) \
208 + $(use_enable static) \
209 + $(use_enable java) \
210 + $(use_with ldap) \
211 + $(use_with snmp net-snmp) \
212 + $(use_with mysql) \
213 + $(use_with postgres postgresql) \
214 + $(use_with oracle) \
215 + $(use_with sqlite sqlite3) \
216 + $(use_with xmpp jabber) \
217 + $(use_with curl libcurl) \
218 + $(use_with openipmi openipmi) \
219 + $(use_with ssh ssh2) \
220 + $(use_with libxml2) \
221 + $(use_with odbc unixodbc) \
222 + $(use_with ssl openssl) \
223 + || die "econf failed"
224 +}
225 +
226 +src_compile() {
227 + if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]; then
228 + emake AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" || die "emake failed"
229 + fi
230 +}
231 +
232 +src_install() {
233 + dodir \
234 + /etc/zabbix \
235 + /var/lib/zabbix \
236 + /var/lib/zabbix/home \
237 + /var/lib/zabbix/scripts \
238 + /var/lib/zabbix/alertscripts \
239 + /var/lib/zabbix/externalscripts \
240 + /var/log/zabbix
241 +
242 + keepdir \
243 + /etc/zabbix \
244 + /var/lib/zabbix \
245 + /var/lib/zabbix/home \
246 + /var/lib/zabbix/scripts \
247 + /var/lib/zabbix/alertscripts \
248 + /var/lib/zabbix/externalscripts \
249 + /var/log/zabbix
250 +
251 + if use server; then
252 + insinto /etc/zabbix
253 + doins "${FILESDIR}/3.0"/zabbix_server.conf
254 + doinitd "${FILESDIR}/3.0"/init.d/zabbix-server
255 + dosbin src/zabbix_server/zabbix_server
256 + fowners zabbix:zabbix /etc/zabbix/zabbix_server.conf
257 + fperms 0640 /etc/zabbix/zabbix_server.conf
258 + dodir /usr/share/zabbix
259 + /bin/cp -R "${S}/database/" "${D}"/usr/share/zabbix/
260 + systemd_dounit "${FILESDIR}/zabbix-server.service"
261 + systemd_newtmpfilesd "${FILESDIR}/zabbix-server.tmpfiles" zabbix-server.conf
262 + fi
263 +
264 + if use proxy; then
265 + doinitd "${FILESDIR}/3.0"/init.d/zabbix-proxy
266 + dosbin src/zabbix_proxy/zabbix_proxy
267 + insinto /etc/zabbix
268 + doins "${FILESDIR}/3.0"/zabbix_proxy.conf
269 + dodir /usr/share/zabbix
270 + /bin/cp -R "${S}/database/" "${D}"/usr/share/zabbix/
271 + systemd_dounit "${FILESDIR}/zabbix-proxy.service"
272 + systemd_newtmpfilesd "${FILESDIR}/zabbix-proxy.tmpfiles" zabbix-proxy.conf
273 + fi
274 +
275 + if use agent; then
276 + insinto /etc/zabbix
277 + doins "${FILESDIR}/3.0"/zabbix_agentd.conf
278 + doinitd "${FILESDIR}/3.0"/init.d/zabbix-agentd
279 + dosbin src/zabbix_agent/zabbix_agentd
280 + dobin \
281 + src/zabbix_sender/zabbix_sender \
282 + src/zabbix_get/zabbix_get
283 + fowners zabbix:zabbix /etc/zabbix/zabbix_agentd.conf
284 + fperms 0640 /etc/zabbix/zabbix_agentd.conf
285 + systemd_dounit "${FILESDIR}/zabbix-agentd.service"
286 + systemd_newtmpfilesd "${FILESDIR}/zabbix-agentd.tmpfiles" zabbix-agentd.conf
287 + fi
288 +
289 + fowners zabbix:zabbix \
290 + /etc/zabbix \
291 + /var/lib/zabbix \
292 + /var/lib/zabbix/home \
293 + /var/lib/zabbix/scripts \
294 + /var/lib/zabbix/alertscripts \
295 + /var/lib/zabbix/externalscripts \
296 + /var/log/zabbix
297 + fperms 0750 \
298 + /etc/zabbix \
299 + /var/lib/zabbix \
300 + /var/lib/zabbix/home \
301 + /var/lib/zabbix/scripts \
302 + /var/lib/zabbix/alertscripts \
303 + /var/lib/zabbix/externalscripts \
304 + /var/log/zabbix
305 +
306 + dodoc README INSTALL NEWS ChangeLog \
307 + conf/zabbix_agentd.conf \
308 + conf/zabbix_proxy.conf \
309 + conf/zabbix_agentd/userparameter_examples.conf \
310 + conf/zabbix_agentd/userparameter_mysql.conf \
311 + conf/zabbix_server.conf
312 +
313 + if use frontend; then
314 + webapp_src_preinst
315 + cp -R frontends/php/* "${D}/${MY_HTDOCSDIR}"
316 + webapp_configfile \
317 + "${MY_HTDOCSDIR}"/include/db.inc.php \
318 + "${MY_HTDOCSDIR}"/include/config.inc.php
319 + webapp_src_install
320 + fi
321 +
322 + if use java; then
323 + dodir \
324 + /${ZABBIXJAVA_BASE} \
325 + /${ZABBIXJAVA_BASE}/bin \
326 + /${ZABBIXJAVA_BASE}/lib
327 + keepdir /${ZABBIXJAVA_BASE}
328 + exeinto /${ZABBIXJAVA_BASE}/bin
329 + doexe src/zabbix_java/bin/zabbix-java-gateway-${MY_PV}.jar
330 + exeinto /${ZABBIXJAVA_BASE}/lib
331 + doexe \
332 + src/zabbix_java/lib/logback-classic-0.9.27.jar \
333 + src/zabbix_java/lib/logback-console.xml \
334 + src/zabbix_java/lib/logback-core-0.9.27.jar \
335 + src/zabbix_java/lib/logback.xml \
336 + src/zabbix_java/lib/android-json-4.3_r3.1.jar \
337 + src/zabbix_java/lib/slf4j-api-1.6.1.jar
338 + fowners -R zabbix:zabbix /${ZABBIXJAVA_BASE}
339 + doinitd "${FILESDIR}"/3.0/init.d/zabbix-jmx-proxy
340 + doconfd "${FILESDIR}"/3.0/conf.d/zabbix-jmx-proxy
341 + fi
342 +}
343 +
344 +pkg_postinst() {
345 + if use server || use proxy ; then
346 + elog
347 + elog "You may need to configure your database for Zabbix,"
348 + elog "if you have not already done so. "
349 + elog
350 +
351 + zabbix_homedir=$(egethome zabbix)
352 + if [ -n "${zabbix_homedir}" ] && \
353 + [ "${zabbix_homedir}" != "/var/lib/zabbix/home" ]; then
354 + ewarn
355 + ewarn "The user 'zabbix' should have his homedir changed"
356 + ewarn "to /var/lib/zabbix/home if you want to use"
357 + ewarn "custom alert scripts."
358 + ewarn
359 + ewarn "A real homedir might be needed for configfiles"
360 + ewarn "for custom alert scripts (e.g. ~/.sendxmpprc when"
361 + ewarn "using sendxmpp for Jabber alerts)."
362 + ewarn
363 + ewarn "To change the homedir use:"
364 + ewarn " usermod -d /var/lib/zabbix/home zabbix"
365 + ewarn
366 + fi
367 + fi
368 +
369 + if use server; then
370 + elog
371 + elog "For distributed monitoring you have to run:"
372 + elog
373 + elog "zabbix_server -n <nodeid>"
374 + elog
375 + elog "This will convert database data for use with Node ID"
376 + elog "and also adds a local node."
377 + elog
378 + fi
379 +
380 + elog "--"
381 + elog
382 + elog "You may need to add these lines to /etc/services:"
383 + elog
384 + elog "zabbix-agent 10050/tcp Zabbix Agent"
385 + elog "zabbix-agent 10050/udp Zabbix Agent"
386 + elog "zabbix-trapper 10051/tcp Zabbix Trapper"
387 + elog "zabbix-trapper 10051/udp Zabbix Trapper"
388 + elog
389 +
390 + if use server || use proxy ; then
391 + # check for fping
392 + fping_perms=$(stat -c %a /usr/sbin/fping 2>/dev/null)
393 + case "${fping_perms}" in
394 + 4[157][157][157])
395 + ;;
396 + *)
397 + ewarn
398 + ewarn "If you want to use the checks 'icmpping' and 'icmppingsec',"
399 + ewarn "you have to make /usr/sbin/fping setuid root and executable"
400 + ewarn "by everyone. Run the following command to fix it:"
401 + ewarn
402 + ewarn " chmod u=rwsx,g=rx,o=rx /usr/sbin/fping"
403 + ewarn
404 + ewarn "Please be aware that this might impose a security risk,"
405 + ewarn "depending on the code quality of fping."
406 + ewarn
407 + ;;
408 + esac
409 + fi
410 +}