Commit b85f57d7 authored by Elia Ponzio's avatar Elia Ponzio
Browse files

Updates

parent ae459c17
from django.contrib import admin
from cynomys.models import Deltas
# Register your models here.
class DeltaAdmin(admin.ModelAdmin):
model = Deltas
list_display = ('task', 'success', 'timestamp', 'latest_check', 'return_value')
admin.site.register(Deltas, DeltaAdmin)
import os
from celery import Celery
import subprocess
# Set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
......@@ -20,3 +22,34 @@ app.autodiscover_tasks()
@app.task(bind=True)
def debug_task(self):
print(f'Request: {self.request!r}')
@app.task()
def helloworld():
print("Oh Hai world!")
@app.task()
def ping(host, timeout):
response = subprocess.run(["ping", "-c", "1", "-w", timeout, host])
print("ping from " + host + " with return value: " + str(response.returncode))
if response.returncode:
pass
@app.task()
def http_check():
pass
@app.task()
def l4_check():
pass
@app.task()
def notify_email():
pass
@app.task()
def notify_webhook():
pass
# Generated by Django 3.2.4 on 2021-06-24 13:13
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('django_celery_beat', '0016_auto_20210624_1313'),
]
operations = [
migrations.CreateModel(
name='Deltas',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('timestamp', models.DateTimeField(auto_now=True)),
('success', models.BooleanField(blank=True, null=True)),
('latest_check', models.DateTimeField(auto_now=True)),
('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_celery_beat.periodictask')),
],
),
]
# Generated by Django 3.2.4 on 2021-06-24 13:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cynomys', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='deltas',
name='return_value',
field=models.CharField(blank=True, max_length=100),
),
]
from django.db import models
from django_celery_beat.models import PeriodicTask
# Create your models here.
class Deltas(models.Model):
task = models.ForeignKey(PeriodicTask, on_delete=models.CASCADE)
timestamp = models.DateTimeField(auto_now=True)
success = models.BooleanField(null=True, blank=True)
latest_check = models.DateTimeField(auto_now=True)
return_value = models.CharField(max_length=100, blank=True)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment