diff options
author | coderick14 | 2017-05-24 14:08:52 +0530 |
---|---|---|
committer | coderick14 | 2017-05-24 14:08:52 +0530 |
commit | d5b5a4a5af947b32c9b517a1ac3711dc78929e35 (patch) | |
tree | 1f5d284f8d3f9e4ff509911fcbbe6b16f265edd5 | |
parent | 9a1614dfa9cd3df20710a2c36ee07ec8a988588b (diff) | |
download | SBHS-2018-Rpi-d5b5a4a5af947b32c9b517a1ac3711dc78929e35.tar.gz SBHS-2018-Rpi-d5b5a4a5af947b32c9b517a1ac3711dc78929e35.tar.bz2 SBHS-2018-Rpi-d5b5a4a5af947b32c9b517a1ac3711dc78929e35.zip |
Add cron module
-rw-r--r-- | maintenance/__init__.py | 0 | ||||
-rw-r--r-- | maintenance/admin.py | 6 | ||||
-rw-r--r-- | maintenance/apps.py | 8 | ||||
-rw-r--r-- | maintenance/health_monitor.py (renamed from health_monitor.py) | 4 | ||||
-rw-r--r-- | maintenance/migrations/__init__.py | 0 | ||||
-rw-r--r-- | maintenance/models.py | 6 | ||||
-rw-r--r-- | maintenance/tests.py | 6 | ||||
-rw-r--r-- | maintenance/views.py | 6 | ||||
-rw-r--r-- | requirements.txt | 3 | ||||
-rw-r--r-- | sbhs_server/settings.py | 7 |
10 files changed, 42 insertions, 4 deletions
diff --git a/maintenance/__init__.py b/maintenance/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/maintenance/__init__.py diff --git a/maintenance/admin.py b/maintenance/admin.py new file mode 100644 index 0000000..13be29d --- /dev/null +++ b/maintenance/admin.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.contrib import admin + +# Register your models here. diff --git a/maintenance/apps.py b/maintenance/apps.py new file mode 100644 index 0000000..4262aa8 --- /dev/null +++ b/maintenance/apps.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class MaintenanceConfig(AppConfig): + name = 'maintenance' diff --git a/health_monitor.py b/maintenance/health_monitor.py index aa19cb1..87946b2 100644 --- a/health_monitor.py +++ b/maintenance/health_monitor.py @@ -1,6 +1,6 @@ import os, serial, smtplib from time import sleep -from sbhs_server.settings import online_mids, ADMIN_EMAIL +from sbhs_server.credentials import ADMIN_EMAIL from sbhs_server.helpers import mailer MAX_PORTS = 256 @@ -68,7 +68,7 @@ def main(): msg = "Nothing out of order was detected on the server. :)" #thread.start_new_thread(mailer.email, (ADMIN_EMAIL, "Health report of SBHS Server", msg)) mailer.email(ADMIN_EMAIL, "Health report of SBHS Server", msg) - print msg + #print msg if __name__ == "__main__": main() diff --git a/maintenance/migrations/__init__.py b/maintenance/migrations/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/maintenance/migrations/__init__.py diff --git a/maintenance/models.py b/maintenance/models.py new file mode 100644 index 0000000..1dfab76 --- /dev/null +++ b/maintenance/models.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models + +# Create your models here. diff --git a/maintenance/tests.py b/maintenance/tests.py new file mode 100644 index 0000000..5982e6b --- /dev/null +++ b/maintenance/tests.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.test import TestCase + +# Create your tests here. diff --git a/maintenance/views.py b/maintenance/views.py new file mode 100644 index 0000000..e784a0b --- /dev/null +++ b/maintenance/views.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.shortcuts import render + +# Create your views here. diff --git a/requirements.txt b/requirements.txt index 323eaed..600139a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ appdirs==1.4.3 backports-abc==0.5 certifi==2017.4.17 Django==1.11.1 +django-crontab==0.7.1 django-taggit==0.18.1 django-undelete==0.1 oauthlib==2.0.2 @@ -9,7 +10,7 @@ packaging==16.8 pkg-resources==0.0.0 PyJWT==1.5.0 pyparsing==2.2.0 -pyserial==2.7 +pyserial==3.0 python-openid==2.2.5 python-social-auth==0.2.19 pytz==2017.2 diff --git a/sbhs_server/settings.py b/sbhs_server/settings.py index 15dc8ae..7161f29 100644 --- a/sbhs_server/settings.py +++ b/sbhs_server/settings.py @@ -63,6 +63,7 @@ INSTALLED_APPS = ( #'yaksh', 'taggit', #'corsheaders' + 'django_crontab', 'account', 'myadmin', @@ -184,6 +185,10 @@ TEMPLATES = [ }, ] +CRONJOBS = [ + ('2 * * * *', 'maintenance.health_monitor.main', '>> /tmp/health_monitor.log'), +] + import warnings warnings.filterwarnings( 'ignore', r"DateTimeField .* received a naive datetime", @@ -270,6 +275,6 @@ print "No of machines online : ", len(online_mids) import sys print >>sys.stderr, online_mids[1:33] #srikant #srikant -#f = open('/tmp/online_mids', 'w') +#f = open(os.path.join(BASE_DIR, 'maintenance/online_mids.txt'), 'w') #f.write(online_mids) #f.close() |