-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmonitor.py
executable file
·45 lines (37 loc) · 925 Bytes
/
monitor.py
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
39
40
41
42
43
44
45
#! /usr/bin/python
path = '/usr/src/gstreamer-phone'
import sys
if not path in sys.path:
sys.path.append(path)
from socket import gethostbyname
from subprocess import Popen, PIPE
from shlex import split
from time import sleep
from log import *
from ring import *
def pidof(name):
return Popen(split('pidof '+name), stdout=PIPE).communicate()[0].strip()
def ps_aux():
return Popen(split('ps aux'), stdout=PIPE).communicate()[0].strip()
if __name__ == '__main__':
established = False
ringing = False
anrufanfangton()
while True:
if 'ssh root@' in ps_aux():
if pidof('gst-launch-0.10') != '' or pidof('gst-launch-1.0') != '':
if not established:
anrufanfangton()
established = True
else:
established = False
klingelton()
ringing = True
else:
if established:
anrufendeton()
established = False
elif ringing:
keinfreizeichenton()
ringing = False
sleep(1)