summaryrefslogtreecommitdiff
path: root/src/op_mode/show_ntp.sh
blob: 4b59b801e72e5d836d81a144a5be28e69560c6d2 (plain)
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
#!/bin/sh

sourcestats=0
tracking=0

while [[ "$#" -gt 0 ]]; do
    case $1 in
        --sourcestats) sourcestats=1 ;;
        --tracking) tracking=1 ;;
        *) echo "Unknown parameter passed: $1" ;;
    esac
    shift
done

if ! ps -C chronyd &>/dev/null; then
    echo NTP daemon disabled
    exit 1
fi

PID=$(pgrep chronyd | head -n1)
VRF_NAME=$(ip vrf identify ${PID})

if [ ! -z ${VRF_NAME} ]; then
    VRF_CMD="sudo ip vrf exec ${VRF_NAME}"
fi

if [ $sourcestats -eq 1 ]; then
    $VRF_CMD chronyc sourcestats -v
elif [ $tracking -eq 1 ]; then
    $VRF_CMD chronyc tracking -v
else
    echo "Unknown option"
fi