#!/bin/bash
#monitor java&nginx
basepath=$(cd `dirname $0`; pwd)
echo "$(date) run monitor" >> $basepath/run_monitor.log
j=$(netstat -anp|grep :8443|grep java)
if [ -z "$j" ]; then
echo "$(date) restart vcm" >> $basepath/monitor.log
source /etc/profile
cd $basepath/webapps/
java -jar -Dapp.home="$basepath/webapps" vcm.jar
fi
n=$(netstat -anp|grep :443|grep nginx)
if [ -z "$n" ]; then
echo "$(date) restart nginx" >> $basepath/monitor.log
systemv=$(lsb_release -a | grep Ubuntu)
if [ -z "$systemv" ]; then
Nginx/nginxhome/sbin/nginx
else
cd $basepath/Nginx/nginxhome/sbin
./nginx
fi
fi