-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatch.py
36 lines (24 loc) · 816 Bytes
/
watch.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
#!/usr/bin/env python
import time, os, smtplib
DELAY = 60
path = "~/.watch/"
def outputFile(command, seconds, path):
return "> " + path + command + "." + seconds + ".txt"
def sendEmail(to, subject, content):
#TODO
pass
if not os.path.isdir("~/.watch/"):
print "Making .watch/"
os.system("mkdir -p ~/.watch/")
while 1:
seconds = str(int(time.time()))
cmd = "free -m " + outputFile("free", seconds, path)
#print cmd + "\n"
os.system(cmd)
cmd = "echo 'show full processlist' | mysql " + outputFile("mysqlproclist", seconds, path)
os.system(cmd)
cmd = "ps aux " + outputFile("ps", seconds, path)
os.system(cmd)
cmd = "curl -s http://localhost/server-status " + outputFile("serverstatus", seconds, path)
os.system(cmd)
time.sleep(DELAY)