-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmonitor
More file actions
executable file
·32 lines (27 loc) · 747 Bytes
/
monitor
File metadata and controls
executable file
·32 lines (27 loc) · 747 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
#!/usr/bin/python
import subprocess
import sys
import pipes
import time
try:
(process, host) = sys.argv[1:]
except ValueError:
print "Usage: monitor [process] [host]"
sys.exit()
output = 'Checking...'
while len(output) > 0:
try:
print output
output = subprocess.check_output("clear; ssh {host} 'ps aux | grep {process} | grep -v grep'"\
.format(process=process,host=host), shell=True)
time.sleep(5)
except subprocess.CalledProcessError:
output = ''
except KeyboardInterrupt:
sys.exit()
while True:
try:
subprocess.call('say {process} is complete 2>/dev/null'.format(process=process), shell=True)
time.sleep(15)
except:
sys.exit()