-
Notifications
You must be signed in to change notification settings - Fork 1
/
Network.py
58 lines (50 loc) · 2.13 KB
/
Network.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import psutil
from time import sleep
from os import system
class Network:
def __init__(self):
self.Data = psutil.net_io_counters()
self.bytes_sent = self.Data.bytes_sent
self.bytes_recv = self.Data.bytes_recv
self.packets_sent = self.Data.packets_sent
self.packets_recv = self.Data.packets_recv
self.errin = self.Data.errin
self.errout = self.Data.errout
self.dropin = self.Data.dropin
self.dropout = self.Data.dropout
def show(self):
showData = None
while True:
showData = psutil.net_io_counters()
system("clear")
print("Byte Sent = ",showData.bytes_sent,", Byte Recieved = ",showData.bytes_recv,", Packet Sent = ",showData.packets_sent,", Packet Recieved = ",showData.packets_recv)
sleep(1)
self.bytes_sent = showData.bytes_sent
self.bytes_recv = showData.bytes_recv
self.packets_sent = showData.packets_sent
self.packets_recv = showData.packets_recv
self.errin = showData.errin
self.errout = showData.errout
self.dropin = showData.dropin
self.dropout = showData.dropout
def showAll(self):
showData = None
while True:
system("clear")
showData = psutil.net_io_counters()
print("Byte Sent = ", showData.bytes_sent, ", Byte Received = ", showData.bytes_recv, ", Packet Sent = ",showData.packets_sent, ", Packet Received = ", showData.packets_recv)
print("Errors While Receiving = ", showData.errin, ", Errors While Sending = ", showData.errout)
print("Incoming packets which were dropped = ", showData.dropin,", Outgoing packets which were dropped = ", showData.dropout)
sleep(1)
self.bytes_sent = showData.bytes_sent
self.bytes_recv = showData.bytes_recv
self.packets_sent = showData.packets_sent
self.packets_recv = showData.packets_recv
self.errin = showData.errin
self.errout = showData.errout
self.dropin = showData.dropin
self.dropout = showData.dropout
return
n = Network()
print()
n.showAll()