mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-07 00:57:22 +02:00
nsd-control parser update, zone transfer status (#607)
* add more parsing functionality for transfering state * add additional/conditional fields into the schema --------- Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
This commit is contained in:
@ -28,9 +28,13 @@ Schema:
|
|||||||
"zone": string
|
"zone": string
|
||||||
"status": {
|
"status": {
|
||||||
"state": string,
|
"state": string,
|
||||||
|
"pattern": string, # Additional
|
||||||
|
"catalog-member-id": string, # Additional
|
||||||
"served-serial": string,
|
"served-serial": string,
|
||||||
"commit-serial": string,
|
"commit-serial": string,
|
||||||
"wait": string
|
"notified-serial": string, # Conditional
|
||||||
|
"wait": string,
|
||||||
|
"transfer": string # Conditional
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -89,7 +93,7 @@ def _process(proc_data):
|
|||||||
|
|
||||||
List of Dictionaries. Structured to conform to the schema.
|
List of Dictionaries. Structured to conform to the schema.
|
||||||
"""
|
"""
|
||||||
int_list = {'verbosity', 'ratelimit', 'wait'}
|
int_list = {'verbosity', 'ratelimit', 'wait', 'transfer'}
|
||||||
|
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
for key in entry:
|
for key in entry:
|
||||||
@ -229,6 +233,20 @@ def parse(data: str, raw: bool = False, quiet: bool = False):
|
|||||||
raw_output.append(zonename)
|
raw_output.append(zonename)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if line.startswith('notified-serial:'):
|
||||||
|
linedata = line.split(': ', maxsplit=1)
|
||||||
|
notified = linedata[1].strip('"').rstrip('"')
|
||||||
|
zstatus.update({'notified-serial': notified})
|
||||||
|
continue
|
||||||
|
|
||||||
|
if line.startswith('transfer:'):
|
||||||
|
linedata = line.split(': ', maxsplit=1)
|
||||||
|
transfer = linedata[1].strip('"').rstrip('"')
|
||||||
|
zstatus.update({'transfer': transfer})
|
||||||
|
zonename.update({'status': zstatus})
|
||||||
|
raw_output.append(zonename)
|
||||||
|
continue
|
||||||
|
|
||||||
# stats
|
# stats
|
||||||
if line.startswith('server') or line.startswith('num.') or line.startswith('size.') or line.startswith('time.') or line.startswith('zone.'):
|
if line.startswith('server') or line.startswith('num.') or line.startswith('size.') or line.startswith('time.') or line.startswith('zone.'):
|
||||||
itrparse = True
|
itrparse = True
|
||||||
|
@ -1 +1 @@
|
|||||||
[{"zone":"sunet.se","status":{"state":"ok","served-serial":"2023091302 since 2023-09-14T00:50:11","commit-serial":"2023091302 since 2023-09-14T07:04:05","wait":"27023 sec between attempts"}},{"zone":"catz.sunet.se","status":{"pattern":"example.catalog","catalog-member-id":"4b6f6ce2de5929e4.zones.example.catalog.","state":"ok","served-serial":"1705484863 since 2024-01-17T13:06:02","commit-serial":"1705484863 since 2024-01-17T13:06:02","wait":"21341 sec between attempts"}}]
|
[{"zone":"sunet.se","status":{"state":"ok","served-serial":"2023091302 since 2023-09-14T00:50:11","commit-serial":"2023091302 since 2023-09-14T07:04:05","wait":"27023 sec between attempts"}},{"zone":"sunet.dev","status":{"state":"refreshing","served-serial":"2023095893 since 2024-10-10T10:10:35","commit-serial":"2023095893 since 2024-10-18T10:00:45","notified-serial":"2023095880 since 2024-10-19T06:11:35","transfer":"TCP connected to 192.168.1.100"}},{"zone":"catz.sunet.se","status":{"pattern":"example.catalog","catalog-member-id":"4b6f6ce2de5929e4.zones.example.catalog.","state":"ok","served-serial":"1705484863 since 2024-01-17T13:06:02","commit-serial":"1705484863 since 2024-01-17T13:06:02","wait":"21341 sec between attempts"}}]
|
||||||
|
@ -3,6 +3,12 @@ zone: sunet.se
|
|||||||
served-serial: "2023091302 since 2023-09-14T00:50:11"
|
served-serial: "2023091302 since 2023-09-14T00:50:11"
|
||||||
commit-serial: "2023091302 since 2023-09-14T07:04:05"
|
commit-serial: "2023091302 since 2023-09-14T07:04:05"
|
||||||
wait: "27023 sec between attempts"
|
wait: "27023 sec between attempts"
|
||||||
|
zone: sunet.dev
|
||||||
|
state: refreshing
|
||||||
|
served-serial: "2023095893 since 2024-10-10T10:10:35"
|
||||||
|
commit-serial: "2023095893 since 2024-10-18T10:00:45"
|
||||||
|
notified-serial: "2023095880 since 2024-10-19T06:11:35"
|
||||||
|
transfer: "TCP connected to 192.168.1.100"
|
||||||
zone: catz.sunet.se
|
zone: catz.sunet.se
|
||||||
pattern: example.catalog
|
pattern: example.catalog
|
||||||
catalog-member-id: 4b6f6ce2de5929e4.zones.example.catalog.
|
catalog-member-id: 4b6f6ce2de5929e4.zones.example.catalog.
|
||||||
|
Reference in New Issue
Block a user