david/openvpnstatus
david
/
openvpnstatus
Archived
1
0
Fork 0
This repository has been archived on 2020-12-06. You can view files and clone it, but cannot push or open issues or pull requests.
openvpnstatus/openvpnstatus.py

42 lines
861 B
Python

class openvpnstatus(object):
"""read the openvpn-status.log file"""
def __init__(self):
self.update()
def update(self):
"""read file"""
import os
self.connections = []
self.routes = []
f = open("openvpn-status.log", "r")
state = 0
for line in f:
if "Updated" in line:
state = 1
continue
elif "ROUTING" in line:
state = 2
continue
elif "GLOBAL" in line:
state = 0
break
if state == 1:
fields = line.split(",")
self.connections.append(fields)
elif state == 2:
fields = line.split(",")
self.routes.append(fields)
f.close()
#end of file