diff options
Diffstat (limited to 'jobs/sys_network.py')
-rwxr-xr-x | jobs/sys_network.py | 15 |
1 files changed, 15 insertions, 0 deletions
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")) |