1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:18:12 +00:00

Kernel: Record network statistics and expose as JSON

This is comprised of five small changes:

* Keep a counter for tx/rx packets/bytes per TCP socket
* Keep a counter for tx/rx packets/bytes per network adapter
* Expose that data in /proc/net_tcp and /proc/netadapters
* Convert /proc/netadapters to JSON
* Fix up ifconfig to read the JSON from netadapters
This commit is contained in:
Conrad Pankoff 2019-08-08 12:32:35 +10:00 committed by Andreas Kling
parent 061c092fae
commit 7ed54d86d5
7 changed files with 88 additions and 20 deletions

View file

@ -33,6 +33,11 @@ public:
bool has_queued_packets() const { return !m_packet_queue.is_empty(); }
u32 packets_in() const { return m_packets_in; }
u32 bytes_in() const { return m_bytes_in; }
u32 packets_out() const { return m_packets_out; }
u32 bytes_out() const { return m_bytes_out; }
protected:
NetworkAdapter();
void set_interface_name(const StringView& basename);
@ -45,4 +50,8 @@ private:
IPv4Address m_ipv4_address;
SinglyLinkedList<KBuffer> m_packet_queue;
String m_name;
u32 m_packets_in { 0 };
u32 m_bytes_in { 0 };
u32 m_packets_out { 0 };
u32 m_bytes_out { 0 };
};