1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/ntpq.md

235 lines
4.8 KiB
Markdown
Raw Permalink Normal View History

[Home](https://kellyjonbrazil.github.io/jc/)
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.ntpq"></a>
2020-07-30 16:20:24 -07:00
2020-03-10 14:18:55 -07:00
# jc.parsers.ntpq
2022-01-25 17:07:47 -08:00
2022-03-04 13:27:39 -08:00
jc - JSON Convert `ntpq -p` command output parser
2020-03-10 14:18:55 -07:00
2020-08-05 13:32:59 -07:00
Usage (cli):
2020-03-10 14:18:55 -07:00
2022-01-25 18:03:34 -08:00
$ ntpq -p | jc --ntpq
2020-08-05 16:51:58 -07:00
2022-08-15 13:51:48 -07:00
or
2020-08-05 16:51:58 -07:00
2022-01-25 18:03:34 -08:00
$ jc ntpq -p
2020-03-10 14:18:55 -07:00
2020-08-05 13:32:59 -07:00
Usage (module):
2022-01-25 18:03:34 -08:00
import jc
result = jc.parse('ntpq', ntpq_command_output)
2022-01-18 15:38:03 -08:00
2021-04-08 15:52:49 -07:00
Schema:
2022-01-25 18:03:34 -08:00
[
{
"state": string, # space/~ converted to null
"remote": string,
"refid": string,
"st": integer,
"t": string,
"when": integer, # - converted to null
"poll": integer,
"reach": integer,
"delay": float,
"offset": float,
"jitter": float
},
]
Examples:
$ ntpq -p | jc --ntpq -p
[
{
"remote": "44.190.6.254",
"refid": "127.67.113.92",
"st": 2,
"t": "u",
"when": 1,
"poll": 64,
"reach": 1,
"delay": 23.399,
"offset": -2.805,
"jitter": 2.131,
"state": null
},
{
"remote": "ntp.wdc1.us.lea",
"refid": "130.133.1.10",
"st": 2,
"t": "u",
"when": null,
"poll": 64,
"reach": 1,
"delay": 93.053,
"offset": -0.807,
"jitter": 2.839,
"state": null
},
{
"remote": "clock.team-cymr",
"refid": "204.9.54.119",
"st": 2,
"t": "u",
"when": null,
"poll": 64,
"reach": 1,
"delay": 70.337,
"offset": -2.909,
"jitter": 2.6,
"state": null
},
{
"remote": "mirror1.sjc02.s",
"refid": "216.218.254.202",
"st": 2,
"t": "u",
"when": 2,
"poll": 64,
"reach": 1,
"delay": 29.325,
"offset": 1.044,
"jitter": 4.069,
"state": null,
}
]
$ ntpq -pn| jc --ntpq -p
[
{
"remote": "44.190.6.254",
"refid": "127.67.113.92",
"st": 2,
"t": "u",
"when": 66,
"poll": 64,
"reach": 377,
"delay": 22.69,
"offset": -0.392,
"jitter": 2.085,
"state": "+"
},
{
"remote": "108.59.2.24",
"refid": "130.133.1.10",
"st": 2,
"t": "u",
"when": 63,
"poll": 64,
"reach": 377,
"delay": 90.805,
"offset": 2.84,
"jitter": 1.908,
"state": "-"
},
{
"remote": "38.229.71.1",
"refid": "204.9.54.119",
"st": 2,
"t": "u",
"when": 64,
"poll": 64,
"reach": 377,
"delay": 68.699,
"offset": -0.61,
"jitter": 2.576,
"state": "+"
},
{
"remote": "72.5.72.15",
"refid": "216.218.254.202",
"st": 2,
"t": "u",
"when": 63,
"poll": 64,
"reach": 377,
"delay": 22.654,
"offset": 0.231,
"jitter": 1.964,
"state": "*"
}
]
$ ntpq -pn| jc --ntpq -p -r
[
{
"s": "+",
"remote": "44.190.6.254",
"refid": "127.67.113.92",
"st": "2",
"t": "u",
"when": "66",
"poll": "64",
"reach": "377",
"delay": "22.690",
"offset": "-0.392",
"jitter": "2.085"
},
{
"s": "-",
"remote": "108.59.2.24",
"refid": "130.133.1.10",
"st": "2",
"t": "u",
"when": "63",
"poll": "64",
"reach": "377",
"delay": "90.805",
"offset": "2.840",
"jitter": "1.908"
},
{
"s": "+",
"remote": "38.229.71.1",
"refid": "204.9.54.119",
"st": "2",
"t": "u",
"when": "64",
"poll": "64",
"reach": "377",
"delay": "68.699",
"offset": "-0.610",
"jitter": "2.576"
},
{
"s": "*",
"remote": "72.5.72.15",
"refid": "216.218.254.202",
"st": "2",
"t": "u",
"when": "63",
"poll": "64",
"reach": "377",
"delay": "22.654",
"offset": "0.231",
"jitter": "1.964"
}
]
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.ntpq.parse"></a>
2022-03-05 12:15:14 -08:00
### parse
2022-01-25 17:07:47 -08:00
2020-03-10 14:18:55 -07:00
```python
2022-01-25 17:07:47 -08:00
def parse(data, raw=False, quiet=False)
2020-03-10 14:18:55 -07:00
```
Main text parsing function
2022-01-25 18:03:34 -08:00
Parameters:
2020-03-10 14:18:55 -07:00
2022-01-25 18:03:34 -08:00
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
2020-03-10 14:18:55 -07:00
2022-01-25 18:03:34 -08:00
Returns:
2020-03-10 14:18:55 -07:00
2022-01-25 18:03:34 -08:00
List of Dictionaries. Raw or processed structured data.
2020-03-10 14:18:55 -07:00
2022-01-25 19:18:54 -08:00
### Parser Information
Compatibility: linux, freebsd
2023-12-21 14:55:21 -08:00
Source: [`jc/parsers/ntpq.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ntpq.py)
2022-07-16 20:52:19 -07:00
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)