Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
White Rabbit Switch - Software
Manage
Activity
Members
Labels
Plan
Issues
98
Issue boards
Milestones
Wiki
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
White Rabbit Switch - Software
Commits
7e075846
Commit
7e075846
authored
3 months ago
by
Adam Wujek
Browse files
Options
Downloads
Patches
Plain Diff
[FEATURE:
#295
] rootfs/etc/init.d/system_clock_monitor: support multiple ntp servers
Signed-off-by:
Adam Wujek
<
dev_public@wujek.eu
>
parent
c981841c
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
userspace/rootfs_override/etc/init.d/system_clock_monitor
+18
-8
18 additions, 8 deletions
userspace/rootfs_override/etc/init.d/system_clock_monitor
with
18 additions
and
8 deletions
userspace/rootfs_override/etc/init.d/system_clock_monitor
+
18
−
8
View file @
7e075846
...
...
@@ -45,7 +45,7 @@ writeMsg() {
#
debug
()
{
if
[[
$verbose
==
1
]]
;
then
echo
$1
>
&1|
tee
-a
$debugLogFile
eval
echo
$1
>
&1|
tee
-a
$debugLogFile
eval echo
$1
$LOGPIPE
fi
}
...
...
@@ -179,11 +179,21 @@ read_ntp_server()
local
server
=
$3
local
retries
=
2
local
offset
=
-1
debug
"NTP server=
$server
"
server_list
=
""
OIFS
=
$IFS
# support comma, semicolon, space as server delimiter
IFS
=
',; '
for
i
in
$server
;
do
# assembly list of servers prefixed with -p
server_list
=
"
$server_list
-p
$i
"
done
IFS
=
$OIFS
debug
"NTP server=
$server_list
"
for
i
in
`
seq
$retries
`
;
do
# Manual retries
killNTPD 10
ntpRes
=
$(
$ntpTool
-n
-w
-q
-d
-p
$server
2>&1
)
ntpRes
=
$(
$ntpTool
-n
-w
-q
-d
$server
_list
2>&1
)
if
[
-n
"
$ntpRes
"
]
;
then
decodeOffset offset
"
$ntpRes
"
if
[
$?
-eq
0
]
;
then
...
...
@@ -200,10 +210,10 @@ read_ntp_server()
fi
eval echo
"Retry
$i
/
$retries
: Cannot extract offset from NTP message."
$LOGPIPE
else
eval echo
"Retry
$i
/
$retries
: NTP query failed, unable to contact server
(
$server
)."
$LOGPIPE
eval echo
"Retry
$i
/
$retries
: NTP query failed, unable to contact server
\(
s
\)
\
(
$server
\
)
."
$LOGPIPE
fi
done
eval echo
"ERROR: could not reach NTP server
'
$S
'
after
$retries
retries"
$LOGPIPE
eval echo
"ERROR: could not reach NTP server
\(
s
\)
\(
$server
\)
after
$retries
retries"
$LOGPIPE
eval
$__result
=
"1"
}
...
...
@@ -234,7 +244,7 @@ else
eval
LOGPIPE
=
\"
2
\>\&
1
\|
logger
-t
$prefix
-p
$WRS_LOG
\"
fi
debug
"Script started with options
\
"
$@
\"
"
debug
"Script started with options
\
\\"
$*
\\
\"
"
# Read options
if
[
"$#"
-eq
1
]
&&
[
"
$1
"
==
"-s"
]
;
then
...
...
@@ -309,7 +319,7 @@ if [ "$CONFIG_SNMP_SYSTEM_CLOCK_MONITOR_ENABLED" = "y" ] ; then
exit
1
fi
read_ntp_server result
$threshold
$ntpServer
read_ntp_server result
$threshold
"
$ntpServer
"
if
((
result
!=
0
))
;
then
writeMsg
"ntp_error"
$systemClockMonitoringStatus
writeMsg
"0"
$systemClockMonitoringDrift
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment