1212## GNU General Public License for more details.
1313
1414
15- from tabulate import tabulate
16- from mktxp .cli .output .base_out import BaseOutputProcessor
15+ from mktxp .processor .output import BaseOutputProcessor
1716from mktxp .datasource .dhcp_ds import DHCPMetricsDataSource
1817
1918
@@ -35,17 +34,22 @@ def clients_summary(router_entry):
3534 dhcp_by_server [server ].append (dhcp_lease_record )
3635 else :
3736 dhcp_by_server [server ] = [dhcp_lease_record ]
37+
38+ output_entry = BaseOutputProcessor .OutputDHCPEntry
39+ output_table = BaseOutputProcessor .output_table (output_entry )
3840
39- num_records = 0
40- output_table = []
41+ output_records = 0
42+ lease_records = len ( dhcp_lease_records )
4143 for key in dhcp_by_server .keys ():
4244 for record in dhcp_by_server [key ]:
4345 record ['host_name' ] = BaseOutputProcessor .dhcp_name (router_entry , record , drop_comment = True )
44- output_table .append (BaseOutputProcessor .OutputDHCPEntry (** record ))
45- num_records += 1
46- output_table .append ({})
47- print ()
48- print (tabulate (output_table , headers = "keys" , tablefmt = "github" ))
49- print (tabulate ([{0 :'DHCP Clients:' , 1 :num_records }], tablefmt = "text" ))
50-
51-
46+ output_table .add_row (output_entry (** record ))
47+ output_records += 1
48+ if output_records < lease_records :
49+ output_table .add_row (output_entry ())
50+
51+ print (output_table .draw ())
52+
53+ for server in dhcp_by_server .keys ():
54+ print (f'{ server } clients: { len (dhcp_by_server [server ])} ' )
55+ print (f'Total DHCP clients: { output_records } ' , '\n ' )
0 commit comments