forked from zhuzhibo0/sslcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecktask.py
50 lines (43 loc) · 1.19 KB
/
checktask.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
46
47
48
49
50
#!/usr/bin/env python
# encoding:utf-8
'''
Created on 2016��5��17��
@author: zhuzb
'''
import urllib2
import urllib
import sys
import argparse
import django
import logging
import requests
import json
import os
import time
os.environ.setdefault('DJANGO_SETTINGS_MODULE','sslcloud.settings')
import django
django.setup()
from sslcheck.models import checktask
from setting.models import server_setting
def main():
glbcfg=server_setting.objects.all();
for i in glbcfg:
master = i.master_address+':'+str(i.port)
break
while(1):
time.sleep(1)
alltask =checktask.objects.all()
print '#'
for i in alltask:
curtime = time.time()
if curtime - i.lastcheck > i.frequency*60:
cmd= os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+'/src/checkasync.py '
cmd+=' -m '+i.module + ' -d '+i.domain
cmd+=' -s '+master
cmd+=' -i '+str(i.project_id)
print 'python '+cmd + '&'
os.system('python '+cmd + '&')#.read()
# i.lastcheck=curtime
# i.save()
if __name__ == '__main__':
main()