Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

get_ntp_stats() doesn't support parsing 'when' #4

Open
ggiesen opened this issue Jun 10, 2020 · 0 comments
Open

get_ntp_stats() doesn't support parsing 'when' #4

ggiesen opened this issue Jun 10, 2020 · 0 comments

Comments

@ggiesen
Copy link
Owner

ggiesen commented Jun 10, 2020

We don't yet support parsing 'when' for get_ntp_stats() because Last Update Time is returned as an absolute time, not a relative time. To solve this, we have to get the current system time and then calculate a relative time. This will never be perfect because the current system time is not displayed within the same command, and we will have a variable delay between executing commands ('show sntp server' and 'show clock')

CLI output:

nvansswi1#show sntp server  

Server Host Address:               66.135.108.133
Server Type:                       IPv4
Server Stratum:                    2
Server Reference Id:               NTP Bits: 0x44c6efdc
Server Mode:                       Server
Server Maximum Entries:            8
Server Current Entries:            2

SNTP Servers
------------

Host Address: 66.135.102.133
Address Type: IPv4
Priority: 1
Version: 4
Port: 123
**Last Update Time: Jun 10 20:34:48 2020**
Last Attempt Time: Jun 10 21:07:55 2020
Last Update Status: Success
Total Unicast Requests: 183689
Failed Unicast Requests: 130

Host Address: 66.135.108.133
Address Type: IPv4
Priority: 1
Version: 4
Port: 123
**Last Update Time: Jun 10 22:09:53 2020**
Last Attempt Time: Jun 10 22:12:01 2020
Last Update Status: Success
Total Unicast Requests: 137398
Failed Unicast Requests: 130

nvansswi1#show clock

15:27:41 PDT(UTC-7:00) Jun 10 2020
Time source is SNTP

Code section:

        ntp_stats = []
        for server in show_sntp_stats:
            if server['status'] == 'Success':
                synchronized = True
            else:
                synchronized = False
            ntp_stats.append(
                {
                    'remote': server['server_ip'],
                    # Not supported
                    'referenceid': '',
                    'synchronized': synchronized,
                    # Not supported
                    'stratum': -1,
                    # We only support parsing unicast servers right now
                    'type': 'u',
**                    # We don't support parsing this right now
                    'when': '',**
                    # Not supported
                    'hostpoll': -1,
                    # Not supported
                    'reachability': -1,
                    # Not supported
                    'delay': -0.0,
                    # Not supported
                    'offset': -0.0,
                    # Not supported
                    'jitter': -0.0,
                }
            )
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant