blob: bbd6a0b517e5384f9551d5b751b1611ac63519b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import socket
def job(device, stat_type):
f = open('/sys/class/net/' + device + '/statistics/' + stat_type, 'r')
value = f.read()
ivalue = int(value.replace("\n", ""))
f.close()
return {'hostname': socket.gethostname(), 'device': device, 'stat_type': stat_type, 'value': ivalue}
if __name__ == "__main__":
from pprint import pprint
pprint(job("eth1", "rx_bytes"))
|