Cant't reach to get realtime information of my network

54 Views Asked by At

I want to fetch realtime information of my network as shown in image , my code is in python in that i import osquery model and when i change network that output also have to change

network informatoin table of my PC

I reached hear only

import osquery

instance=osquery.SpawnInstance()
instance.open()
result=instance.client.query("SELECT (CASE family WHEN 2 THEN 'IP4' WHEN 10 THEN 'IP6' ELSE family END) AS family, (CASE protocol WHEN 6 THEN 'TCP' WHEN 17 THEN 'UDP' ELSE protocol END) AS protocol, local_address, local_port, remote_address, remote_port FROM process_open_sockets WHERE family IN (2, 10) AND protocol IN (6, 17)")
print(result.response[0])

can anyone help me??

1

There are 1 best solutions below

0
On

You appear to be querying the process_open_sockets table, which is about "Processes which have open network sockets on the system".

I'm not sure what tables, if any, contain the configured information for the network interface. You'd need to peruse https://osquery.io/schema/ to find something appropriate.