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
36
37
38
39
40
41
42
43
|
#!/bin/bash
remote=$1
server=`echo $remote | cut -d ':' -f 1`
if [ "$server" == "$remote" ]; then
port=`/opt/scripts/nagios_ssh_port.sh $server`
else
port=`echo $remote | cut -d ':' -f 2`
fi
shift
params=""
for param in "$@"; do
params="$params \"$param\""
done
output=`ssh -p $port root@$server /opt/scripts/check_adei_control.sh $params`
last_line=`echo "$output" | tail -1`
status=`echo $last_line | cut -d ' ' -f 1`
#echo -n ${last_line#$status} GB
if [ $status -eq 1 ]; then
echo OK
else
lines=`echo "$output" | wc -l`
if [ $lines -gt 1 ]; then
echo "$output" | head -n 1 | tr -d '\n'
echo " ... "
else
echo "$output" | head -n 1
fi
echo "------------------"
echo "$output" | head -n -1
fi
if [ "$status" -eq 0 ]; then
exit "2"
elif [ "$status" -eq 1 ]; then
exit "0"
else
exit "1"
fi
|