File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ if [ -z " $2 " ]; then
4+ echo " $0 min_servers diff_in_sec"
5+ fi
6+
7+ min_servers=" ${1:- 3} "
8+ max_diff=" ${2:- 0.01} "
9+
10+ result=" $( chronyc tracking 2>&1 ) "
11+ ret=" $? "
12+ if [ " $ret " != " 0" ]; then
13+ echo " ERROR: >>>$result <<<" >&2
14+ exit 1
15+ fi
16+
17+ chronyc -c tracking| awk -F, -v " diff_in_sec=${max_diff} " ' {abs_val = ($5 >= 0) ? $5 : -$5; if (abs_val > diff_in_sec){exit 1}else{exit 0}}'
18+ ret=" $? "
19+ if [ " $ret " != " 0" ]; then
20+ echo " ERROR: time diff to high (>$max_diff )" >&2
21+ chronyc tracking >&2
22+ exit 2
23+ fi
24+
25+ chronyc -c sources| awk -F, -v " min_servers=$min_servers " ' $2 ~ /\+|*/ {count=count+1}END{if (count >= min_servers){exit 0}else{exit 1}}'
26+ ret=" $? "
27+ if [ " $ret " != " 0" ]; then
28+ echo " ERROR: not enough active servers (<$min_servers )" >&2
29+ chronyc sources >&2
30+ exit 2
31+ fi
32+
33+ echo " OK"
34+ exit 0
35+
You can’t perform that action at this time.
0 commit comments