-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_fastd
More file actions
36 lines (33 loc) · 789 Bytes
/
check_fastd
File metadata and controls
36 lines (33 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
fastd=/usr/local/bin/fastd
instance=$1
config=/etc/fastd/$instance/fastd.conf
out=/tmp/fastd.out
upwait=8
downwait=1
if [ -z "$instance" ]
then
echo "Usage: $0 <instance-name>"
exit 2
fi
killall fastd 2>/dev/null
$fastd -c $config 2>$out &
sleep $upwait
killall fastd 2>/dev/null
sleep $downwait
#cat $out
established=$(cat $out | grep " established" | wc -l)
if [ $established == 1 ]
then
line=$(cat $out | grep " established")
line=$(echo $line | awk -F"--- " '{print $2'})
echo "OK - $line"
exit 0
fi
line=$(cat $out | grep -v "starting" | grep -v "terminating" | grep -v "bound" | awk -F"--- " '{print $2}' | sed -e 's/\\n/ /g' | sed -e 's/Info: //g' )
if [ -z $line ]
then
line="No establish confirmation for $instance"
fi
echo "CRITICAL - $line"
exit 2