3 # Copyright (C) 2008, 2009 Nicira Networks, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
20 SECCHAN_PID=/var/run/secchan.pid
21 SECCHAN_SOCK=/var/run/secchan.mgmt
22 LOG_FILE=/var/log/openflow/monitor
27 echo usage: $0 options
30 echo " -h Show this message"
31 echo " -p PID file for secchan (default: $SECCHAN_PID)"
32 echo " -s Unix socket for secchan (default: $SECCHAN_SOCK)"
33 echo " -l File to log messages (default: $LOG_FILE)"
34 echo " -i Interval to send probes in seconds (default: $INTERVAL)"
35 echo " -c Number of failed probes before reboot (default: $FAIL_THRESH)"
39 echo `date +"%b %d %X"`:$1
40 echo `date +"%b %d %X"`:$1 >> $LOG_FILE
44 while getopts "hp:s:l:i:c:" OPTION; do
72 echo "Unknown option: ${OPTION}"
77 if [ ! -f $SECCHAN_PID ]; then
78 log "No secchan pid file: ${SECCHAN_PID}"
79 echo "No secchan pid file: ${SECCHAN_PID}"
82 if [ ! -S $SECCHAN_SOCK ]; then
83 log "No secchan sock file: ${SECCHAN_SOCK}"
84 echo "No secchan sock file: ${SECCHAN_SOCK}"
87 if [ ! -d `dirname $LOG_FILE` ]; then
88 mkdir -p `dirname $LOG_FILE`
93 log "===== Starting Monitor ===="
95 # Only check for liveness if the secchan's PID file exists. The PID
96 # file is removed when secchan is brought down gracefully.
97 if [ -f $SECCHAN_PID ]; then
98 pid=`cat $SECCHAN_PID`
99 if [ -d /proc/$pid ]; then
100 # Check if the secchan and datapath still can communicate
101 if [ -S $SECCHAN_SOCK ]; then
102 ovs-ofctl probe -t 2 unix:$SECCHAN_SOCK
103 if [ $? -ne 0 ]; then
104 log "datapath probe failed"
112 log "secchan probe failed"
117 if [ $SECCHAN_DOWN -ge $FAIL_THRESH ]; then
118 log "Failed to probe secchan after ${SECCHAN_DOWN} tries...rebooting!"
122 if [ $DP_DOWN -ge $FAIL_THRESH ]; then
123 log "Failed to probe datapath after ${DP_DOWN} tries...rebooting!"