#! /bin/bash
var=` /sbin/ifconfig -a |grep"inet"|awk'{print $2}'|awk -F ':''{print $2}'`;
vip="vip";
result=$(echo $var |grep"${vip}");if["$result"!=""]thenecho"$s1 include $s2"elseecho"$1 not include $s2"fi
5.1 CTI
CTI
#!/bin/shwhiletruedo
time=$(date"+%Y-%m-%d %H:%M:%S")
var=` /sbin/ifconfig -a |grep"inet"|awk'{print $2}'|awk -F ':''{print $2}'`;
vip="100.70.88.148";
result=$(echo ${var}|grep"${vip}");if["$result"!=""]thenecho"[""${time}""]":${var}>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
echo"[""${time}""]":${vip}>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
echo"[""${time}""]": result value: ${result}>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
echo"[""${time}""]": Virtual IP is on this host. Running CTI Service!>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
sn=`ps -ef |grep rainnytech.exe |grep -v grep`if["${sn}"=""]thenecho"[""${time}""]": Virtual IP is on this host. CTI Service is not running!>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
cd /var/rainny/cti/rainnyinfo/
echo"[""${time}""]": Restart CTI Service!>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
nohup mono rainnytech.exe &echo"[""${time}""]": Restart CTI Service has been completed!>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
echo"[""${time}""]": ctiserver is restart >>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
elseecho"[""${time}""]": Virtual IP is on this host. ctiserver is running >>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
fielseecho"[""${time}""]":${var}>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
echo"[""${time}""]":${vip}>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
echo"[""${time}""]": result value: ${result}>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
echo"[""${time}""]": Virtual IP is not on this host. stop CTI Service!>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
pid=`ps -ef |grep"rainnytech.exe"|grep -v grep|awk'{print $2}'`if["${pid}"=""]thenecho"[""${time}""]": ctiserver is not running, not need to restart!>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
elseecho"[""${time}""]": ctiserver is running, stop ctiserver!>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
kill -9 "${pid}"echo"[""${time}""]": Stoping ctiserver has been completed!>>/var/rainny/cti/rainnyinfo/ctiwatchdog.log
fifisleep 7
done
5.2 FS
#!/bin/shwhiletruedo
time=$(date"+%Y-%m-%d %H:%M:%S")
var=` /sbin/ifconfig -a |grep"inet"|awk'{print $2}'|awk -F ':''{print $2}'`;
vip="100.70.88.147";
result=$(echo ${var}|grep"${vip}");if["$result"!=""]thenecho"[""${time}""]":${var}echo"[""${time}""]":${vip}echo"[""${time}""]":${var}>>/var/rainny/cti/log/freeswitch.log
echo"[""${time}""]":${vip}>>/var/rainny/cti/log/freeswitch.log
echo"[""${time}""]": result value: ${result}>>/var/rainny/cti/log/freeswitch.log
echo"[""${time}""]": vip is on this host!echo"[""${time}""]": VIP is on this host, restart FreeSWITCH Service!>>/var/rainny/cti/log/freeswitch.log
sn=`ps -ef |grep freeswitch |grep -v grep`if["${sn}"=""]thenecho"[""${time}""]": VIP is on this host, FreeSWITCH is not running >>/var/rainny/cti/log/freeswitch.log
cd /usr/local/freeswitch/bin
echo"[""${time}""]": Restart FreeSWITCH >>/var/rainny/cti/log/freeswitch.log
./freeswitch -nonat -nc
echo"[""${time}""]": restart completed >>/var/rainny/cti/log/freeswitch.log
echo"[""${time}""]": freeswitch is restart >>/var/rainny/cti/log/freeswitch.log
elseecho"[""${time}""]": freeswitch is running >>/var/rainny/cti/log/freeswitch.log
fielseecho"[""${time}""]":${var}echo"[""${time}""]":${vip}echo"[""${time}""]":${var}>>/var/rainny/cti/log/freeswitch.log
echo"[""${time}""]":${vip}>>/var/rainny/cti/log/freeswitch.log
echo"[""${time}""]": result value: ${result}>>/var/rainny/cti/log/freeswitch.log
echo"[""${time}""]":!echo"[""${time}""]": vip is not on this host!echo"[""${time}""]": VIP is not on this host, stop FreeSWITCH Service!>>/var/rainny/cti/log/freeswitch.log
pid=`ps -ef |grep"freeswitch"|grep -v grep|awk'{print $2}'`if["${pid}"=""]thenecho"[""${time}""]": FreeSWITCH Service is Not Running >>/var/rainny/cti/log/freeswitch.log
elseecho"[""${time}""]": Shutdown FreeSWITCH >>/var/rainny/cti/log/freeswitch.log
kill -9 "${pid}"echo"[""${time}""]": FreeSWITCH Service has been closed >>/var/rainny/cti/log/freeswitch.log
fifisleep 7
done