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