ajrbyers / mondroid

Simple monitoring system written in Python/Django using requests.
GNU General Public License v2.0
0 stars 0 forks source link

Change DownTime to Status and group Up and Down times #10

Closed ajrbyers closed 9 years ago

ajrbyers commented 9 years ago

Replace the DownTime model with a status model that groups up times and downtimes together something along the lines of:

class Status(models.Model):
    monitor = models.ForeignKey(Monitor)
    start = models.ForeignKey(Check, related_name='start')
    finish = models.ForeignKey(Check, related_name='finish')
    up = models.BooleanField(help_text='True for up, False for down')

These could be created by the management command reading in the checks from the fetcher log (a la https://github.com/ajrbyers/mondroid/issues/9) and are simply created when the status_code alternates between up and down. We can then display on the dashboard UP and DOWN periods very simply.

We could also record the Checks in-between, or we can assume that the checks are part of that particular status

lsh-0 commented 9 years ago

In issue https://github.com/ajrbyers/mondroid/issues/4 I describe a magical (undefined) function that returns the datastructure we would need to do these sorts of calculations. Because that information can be derived from the data in the database, it shouldn't really be stored in the database. Like storing a person's age rather than their date of birth.

I'll write an implementation tomorrow illustrating what I mean. I'm thinking it might even be possible to get a similar datastructure using raw SQL and aggregates.

ajrbyers commented 9 years ago

Luke to implement magic function:

downtime_between(now, then) ... [[<Check 2014-12-05 21:05>, <Check 2014-12-05 21:00>, <Check 2014-12-05 20:55> ...], ... [<Check 2014-12-05 20:05>, <Check 2014-12-05 20:10>], ... [...]]

lsh-0 commented 9 years ago

I have a couple of ideas scratched out for this and a third one just popped into my head while considering what I've done for the 'time in state' function now attached to the Monitor model.

ajrbyers commented 9 years ago

I'm closing this issue as the original premise is gone and the function being considered above is should be addressed as part of https://github.com/ajrbyers/mondroid/issues/7