|
@@ -11,8 +11,8 @@ sock = socket.socket()
|
|
|
last_timestamp = 0
|
|
|
|
|
|
def logging(message, level = syslog.LOG_INFO):
|
|
|
- #GLOP#syslog.syslog(level, message)
|
|
|
- print message
|
|
|
+ syslog.syslog(level, message)
|
|
|
+ #print message
|
|
|
|
|
|
|
|
|
def read_vpn_acct_file(filename):
|
|
@@ -47,7 +47,6 @@ def send_to_carbon(metrics):
|
|
|
header = struct.pack("!L", len(payload))
|
|
|
message = header + payload
|
|
|
sock.sendall(message)
|
|
|
- #GLOP#print metrics
|
|
|
|
|
|
|
|
|
def process_vpn_file(filename, old_tstamp = 0):
|
|
@@ -140,14 +139,14 @@ if __name__ == '__main__':
|
|
|
last_timestamp = 0
|
|
|
|
|
|
# https://github.com/seb-m/pyinotify/blob/master/python2/examples/daemon.py
|
|
|
- logging("Starting to watch %s directory..." % (options.directory))
|
|
|
+ logging("Starting to watch %s directory..." % (options.directory, ))
|
|
|
wm = pyinotify.WatchManager()
|
|
|
handler = VPNAcctHandler()
|
|
|
notifier = pyinotify.Notifier(wm, handler)
|
|
|
wm.add_watch(options.directory, pyinotify.IN_CLOSE_WRITE)
|
|
|
|
|
|
try:
|
|
|
- notifier.loop(daemonize=False, callback=on_loop, pid_file='/tmp/pyinotify.pid', stdout='/tmp/pyinotify.log') #GLOP#
|
|
|
+ notifier.loop(daemonize=True, callback=on_loop, pid_file='/var/run/pyinotify.pid', stdout='/var/log/pyinotify.log')
|
|
|
except pyinotify.NotifierError, err:
|
|
|
print >> sys.stderr, err
|
|
|
|