-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsshMon.py
More file actions
39 lines (31 loc) · 765 Bytes
/
sshMon.py
File metadata and controls
39 lines (31 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python
__author__ = 'Royce'
import os
import logging
from time import sleep
from libs.LifxControl import LifxControl
#logging.captureWarnings(True)
Control = LifxControl()
auth_log = '/var/log/auth.log'
def tail(f, n):
stdin, stdout = os.popen2("tail -n " + str(n) + " " + f + "|grep closed")
stdin.close()
lines = stdout.readlines()
stdout.close()
return lines
monitoring = True
ip = []
while monitoring:
sleep(5)
auth_tail = tail(auth_log, 1)
print auth_tail
if auth_tail:
if ip:
if ip[-1] == auth_tail[-1]:
print "No change"
else:
ip.append(auth_tail[0])
print "Pulse Lights!"
Control.pulseAll("red")
else:
ip = []