-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_ntpstratum.sh
More file actions
executable file
·60 lines (48 loc) · 846 Bytes
/
check_ntpstratum.sh
File metadata and controls
executable file
·60 lines (48 loc) · 846 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# Script check NTP Stratum
TARGETHOST=$1
WARNINVAL=$2
CRITICVAL=$3
STRATUM=""
STAT=""
if [ -z "$TARGETHOST" ]
then
TARGETHOST="127.0.0.1"
fi
if [ -z "$WARNINVAL" ]
then
WARNINVAL="6"
fi
if [ -z "$CRITICVAL" ]
then
CRITICVAL="10"
fi
echolot () {
echo "$STAT NTP Stratum is: $STRATUM"
}
if ! ntpdc -nc sysinfo $TARGETHOST 2> /dev/null | grep stratum > /dev/null 2>&1
then
STAT="Critical"
STRATUM="not determined"
echolot
exit 2
fi
STRATUM="$(ntpdc -nc sysinfo $TARGETHOST | grep stratum | awk '{printf $2}' | xargs echo)"
if [ "$STRATUM" -lt "$WARNINVAL" ]
then
STAT="OK"
echolot
exit 0
fi
if [ "$STRATUM" -ge "$WARNINVAL" ] && [ "$STRATUM" -lt "$CRITICVAL" ]
then
STAT="Warning"
echolot
exit 1
fi
if [ "$STRATUM" -gt "$WARNINVAL" ] && [ "$STRATUM" -ge "$CRITICVAL" ]
then
STAT="Critical"
echolot
exit 2
fi