From 69c220cda3d8c0a95327630f5752dad36cb82261 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Tue, 17 Jul 2018 12:34:04 +0200 Subject: Squashed commit --- jobs/sys_network.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 jobs/sys_network.py (limited to 'jobs/sys_network.py') diff --git a/jobs/sys_network.py b/jobs/sys_network.py new file mode 100755 index 0000000..bbd6a0b --- /dev/null +++ b/jobs/sys_network.py @@ -0,0 +1,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")) -- cgit v1.2.1