|
|
1c3a77 |
#!/bin/bash
|
|
|
1c3a77 |
|
|
|
1c3a77 |
if [ -r /etc/zabbix/zabbix_java_gateway.conf ]; then
|
|
|
1c3a77 |
. /etc/zabbix/zabbix_java_gateway.conf
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
|
|
|
1c3a77 |
if [ -z $GATEWAY_HOME ]; then
|
|
|
1c3a77 |
GATEWAY_HOME="/usr/share/zabbix-java-gateway"
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
|
|
|
1c3a77 |
if [ -r "/etc/sysconfig/zabbix-java-gateway" ]; then
|
|
|
1c3a77 |
. /etc/sysconfig/zabbix-java-gateway
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
|
|
|
1c3a77 |
if [ -n "$PID_FILE" -a -f "$PID_FILE" ]; then
|
|
|
1c3a77 |
PID=`cat "$PID_FILE"`
|
|
|
1c3a77 |
if ps -p "$PID" > /dev/null 2>&1; then
|
|
|
1c3a77 |
echo "Zabbix Java Gateway is already running"
|
|
|
1c3a77 |
exit 1
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
rm -f "$PID_FILE"
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
|
|
|
1c3a77 |
JAVA=${JAVA:-java}
|
|
|
1c3a77 |
JAVA_OPTIONS="-server $JAVA_OPTIONS"
|
|
|
1c3a77 |
JAVA_OPTIONS="$JAVA_OPTIONS -Dlogback.configurationFile=/etc/zabbix/zabbix_java_gateway_logback.xml"
|
|
|
1c3a77 |
|
|
|
1c3a77 |
cd $GATEWAY_HOME
|
|
|
1c3a77 |
|
|
|
1c3a77 |
CLASSPATH="lib"
|
|
|
1c3a77 |
for jar in lib/*.jar bin/*.jar; do
|
|
|
1c3a77 |
CLASSPATH="$CLASSPATH:$jar"
|
|
|
1c3a77 |
done
|
|
|
1c3a77 |
|
|
|
1c3a77 |
if [ -n "$PID_FILE" ]; then
|
|
|
1c3a77 |
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dzabbix.pidFile=$PID_FILE"
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
if [ -n "$LISTEN_IP" ]; then
|
|
|
1c3a77 |
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dzabbix.listenIP=$LISTEN_IP"
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
if [ -n "$LISTEN_PORT" ]; then
|
|
|
1c3a77 |
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dzabbix.listenPort=$LISTEN_PORT"
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
if [ -n "$START_POLLERS" ]; then
|
|
|
1c3a77 |
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dzabbix.startPollers=$START_POLLERS"
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
if [ -n "$TIMEOUT" ]; then
|
|
|
1c3a77 |
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dzabbix.timeout=$TIMEOUT"
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
|
|
|
1c3a77 |
tcp_timeout=${TIMEOUT:=3}000
|
|
|
1c3a77 |
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dsun.rmi.transport.tcp.responseTimeout=$tcp_timeout"
|
|
|
1c3a77 |
|
|
|
1c3a77 |
COMMAND_LINE="$JAVA $JAVA_OPTIONS -classpath $CLASSPATH $ZABBIX_OPTIONS com.zabbix.gateway.JavaGateway"
|
|
|
1c3a77 |
|
|
|
1c3a77 |
if [ -n "$PID_FILE" ]; then
|
|
|
1c3a77 |
|
|
|
1c3a77 |
# check that the PID file can be created
|
|
|
1c3a77 |
|
|
|
1c3a77 |
touch "$PID_FILE"
|
|
|
1c3a77 |
if [ $? -ne 0 ]; then
|
|
|
1c3a77 |
echo "Zabbix Java Gateway did not start: cannot create PID file"
|
|
|
1c3a77 |
exit 1
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
|
|
|
1c3a77 |
# start the gateway and output pretty errors to the console
|
|
|
1c3a77 |
|
|
|
1c3a77 |
STDOUT=`$COMMAND_LINE & echo $! > "$PID_FILE"`
|
|
|
1c3a77 |
if [ -n "$STDOUT" ]; then
|
|
|
1c3a77 |
echo "$STDOUT"
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
|
|
|
1c3a77 |
# verify that the gateway started successfully
|
|
|
1c3a77 |
|
|
|
1c3a77 |
PID=`cat "$PID_FILE"`
|
|
|
1c3a77 |
ps -p "$PID" > /dev/null 2>&1
|
|
|
1c3a77 |
if [ $? -ne 0 ]; then
|
|
|
1c3a77 |
echo "Zabbix Java Gateway did not start"
|
|
|
1c3a77 |
rm -f "$PID_FILE"
|
|
|
1c3a77 |
exit 1
|
|
|
1c3a77 |
fi
|
|
|
1c3a77 |
|
|
|
1c3a77 |
else
|
|
|
1c3a77 |
exec $COMMAND_LINE
|
|
|
1c3a77 |
fi
|