Skip to content
Snippets Groups Projects

Timesync

Merged Gasser Martin (mg20u947) requested to merge timesync into master
1 file
+ 10
5
Compare changes
  • Side-by-side
  • Inline
+ 10
5
@@ -14,6 +14,8 @@
# 2018-10-26 v1.0 <axel.hahn@iml.unibe.ch>
# 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
# 2020-05-13 v1.2 <axel.hahn@iml.unibe.ch> update pre detect output of timedatectl
# 2021-08-19 v1.3 <martin.gasser@iml.unibe.ch> update for chrony with timedatectl
# ======================================================================
. `dirname $0`/inc_pluginfunctions
@@ -36,16 +38,16 @@ fi
# ph.execIfReady "timedatectl status | grep '^NTP synchronized'" >/dev/null
# echo ----- output of timedatectl status >$tmpfile
# timedatectl status >>$tmpfile
ph.execIfReady "timedatectl status >$tmpfile; grep '^NTP synchronized' $tmpfile >/dev/null"
ph.execIfReady "timedatectl show >$tmpfile; grep '^NTPSynchronized' $tmpfile >/dev/null"
cat $tmpfile | grep "^NTP synchronized" >/dev/null
cat $tmpfile | grep "^NTPSynchronized" >/dev/null
if [ $? -ne 0 ]; then
ph.setStatus "unknown"
# ph.status "timesync: timedatectl has no line NTP synchronized ... maybe your OS ${myos} is not supported"
ph.status "timesync: timedatectl has no line NTP synchronized"
cat $tmpfile
else
cat $tmpfile | grep "^NTP synchronized: yes" >/dev/null
cat $tmpfile | grep "^NTPSynchronized=yes" >/dev/null
if [ $? -eq 0 ]; then
ph.status "timesync: a timesync service is active on this ${myos} host"
else
@@ -66,6 +68,9 @@ fi
if [ -f /etc/chrony.conf ]; then
sSyncService="chronyd"
fi
if [ -f /etc/chrony/chrony.conf ]; then
sSyncService="chronyd"
fi
if [ -z $sSyncService ]; then
echo "REMARK: no sync service detected ... or this sensu check does not support it" >>$tmpfile
else
@@ -78,7 +83,7 @@ fi
# output & exit
# ----------------------------------------------------------------------
cat $tmpfile | grep "^NTP synchronized"
cat $tmpfile | grep "^NTPSynchronized"
echo
cat $tmpfile
@@ -86,4 +91,4 @@ rm -f $tmpfile
ph.exit
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
\ No newline at end of file
Loading